Crystal Space
Welcome, Guest. Please login or register.
April 23, 2014, 05:46:49 pm

Login with username, password and session length
Search:     Advanced search
8990 Posts in 2037 Topics by 7618 Members
Latest Member: Tymqwaro
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  HELP - RGB colors displayed incorrectly!
« previous next »
Pages: [1] Print
Author Topic: HELP - RGB colors displayed incorrectly!  (Read 3425 times)
Rabraham
Newbie
*
Posts: 20


View Profile Email
« on: January 09, 2008, 04:21:56 pm »

Hello Community,

I have a cs project, and I have a simple CS sphere in my project. I am trying to set the color of the textures for tis sphere.
It looks like the RGB values I use setting the textures color are not the real colors that are rendered on the screen!
For instance the following RGB values display as following (I used MS paint with the color picker to sample the color from the screen):

(0, 0, 0) yields (0, 0, 0) but,
(1, 2, 3) yields (0, 0, 0)
(4, 5, 6) yields (0, 4, 8 )
(7, 8, 9) yields (8, 8, 8 )
(11, 12, 13) yields (8, 12, 16)
(15, 16, 17) yields (16, 16, 16)

more specifically I am interested in the this color
(238, 130, 238) which yields (239, 130, 239)

I have verified that the color depth is 32 bits (tried also with 24), and the weird thing is that when I query CS for the color of the texture I get the same RGB value that it was set to, but on the screen it looks like there is some transformation happening and the RGB value is modified. This happens also when I turn all lights off and set ambient to (1,1,1).

Any Ideas?

Thank you!
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1704


View Profile
« Reply #1 on: January 09, 2008, 04:35:04 pm »

I think you cannot depend on exactly the same color being rendered. There are too many things happening by the OpenGL system and the 3D card (like filtering, AA, and other effects) so that exact colors don't come out exactly the same.

But I also don't think this should be a problem. You cannot really see such small differences.

Greetings,
Logged
Rabraham
Newbie
*
Posts: 20


View Profile Email
« Reply #2 on: January 09, 2008, 05:01:51 pm »

Thing is I do need the color to display exactly the same as I have a different program (which aparantly I can't modify at the moment) that looks for this specific color and displays video on this specific color. It is not about the visible difference. Suppose I COULD change the code of the other party prgram expecting for that color to expect another color I am still looking for something that won't change inside cs/OpenGL regardless of the platform I will use.
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1704


View Profile
« Reply #3 on: January 09, 2008, 05:02:56 pm »

Thing is I do need the color to display exactly the same as I have a different program (which aparantly I can't modify at the moment) that looks for this specific color and displays video on this specific color. It is not about the visible difference. Suppose I COULD change the code of the other party prgram expecting for that color to expect another color I am still looking for something that won't change inside cs/OpenGL regardless of the platform I will use.

I'm afraid that that will not be possible. But I may be mistaken.

Greetings,
Logged
res
Develazyoper
CS Developer
Full Member
*****
Posts: 206


View Profile Email
« Reply #4 on: January 09, 2008, 05:23:09 pm »

I have verified that the color depth is 32 bits (tried also with 24), and the weird thing is that when I query CS for the color of the texture I get the same RGB value that it was set to, but on the screen it looks like there is some transformation happening and the RGB value is modified. This happens also when I turn all lights off and set ambient to (1,1,1).

Disable texture compression on the texture (set the texture class to "nocompress").
Logged
Rabraham
Newbie
*
Posts: 20


View Profile Email
« Reply #5 on: January 09, 2008, 10:34:05 pm »

I have verified that the color depth is 32 bits (tried also with 24), and the weird thing is that when I query CS for the color of the texture I get the same RGB value that it was set to, but on the screen it looks like there is some transformation happening and the RGB value is modified. This happens also when I turn all lights off and set ambient to (1,1,1).

Disable texture compression on the texture (set the texture class to "nocompress").


Hi res,

thanks for your reply, I tried doing that but it looks like some exception that I can't see occurs or sometuing soesn't work correctly, here's my code:

Code:
string materialSuffix = "material";
string textureSuffix = "texture";

string textureName = newMaterialNameBase + textureSuffix;

// For this to work, we need to remove the existing texture from the engine's
// texture list.  If meshWrapper colors will be used by more than one meshWrappers,
// this will have to change to adding a new texture with a different name.
iTextureWrapper* roomTextureWrapper  = engine->FindTexture(textureName.c_str());
if (roomTextureWrapper != 0)
{
engine->GetTextureList()->Remove(roomTextureWrapper);
}
roomTextureWrapper  = engine->CreateBlackTexture(textureName.c_str(), 256, 256, 0, CS_TEXTURE_3D);

////////////////////////////////////////// Here's my added code for tis suggestion --->       
cout << "\n\n\ADDED PRINTOUTS - ********************" << endl;

const char* textureClass1 = roomTextureWrapper->GetTextureClass();
cout << "\nTexture Class is: " << textureClass1 << endl << endl;

cout << "Setting Texture Class to nocompress ..." << endl;
roomTextureWrapper->SetTextureClass("nocompress");

const char* textureClass2 = roomTextureWrapper->GetTextureClass();
cout << "\n Texture Class is now: " << textureClass2 << endl;

//////////////////////////////////////////


csImageMemory* img = new csImageMemory(256, 256);
img->Clear(*color);
roomTextureWrapper->SetImageFile(img);


                                         
csRef<iTextureManager> txtmgr = g3d->GetTextureManager();
roomTextureWrapper->Register(txtmgr);

csRef<iMaterial> material(engine->CreateBaseMaterial(roomTextureWrapper));
string materialName = newMaterialNameBase + materialSuffix;
iMaterialWrapper* materialWrapper = engine->GetMaterialList()->NewMaterial(material,materialName.c_str());

meshWrapper->GetMeshObject()->SetMaterialWrapper(materialWrapper);



the output is:

ADDED PRINTOUTS - ********************

Texture Class is:

------

After that seems like I lose all printouts and looks like execution exits the current function after setting the result string received by calling GetTextureClass().


Logged
Rabraham
Newbie
*
Posts: 20


View Profile Email
« Reply #6 on: January 11, 2008, 12:03:28 am »

I have verified that the color depth is 32 bits (tried also with 24), and the weird thing is that when I query CS for the color of the texture I get the same RGB value that it was set to, but on the screen it looks like there is some transformation happening and the RGB value is modified. This happens also when I turn all lights off and set ambient to (1,1,1).

Disable texture compression on the texture (set the texture class to "nocompress").


ok I fixed that problem and managed to set the class name, I tried the "nocompress" "normalmap" and teh "lookup" but neither fixed the problem.
The code is similar to the 1 above.
Logged
res
Develazyoper
CS Developer
Full Member
*****
Posts: 206


View Profile Email
« Reply #7 on: January 14, 2008, 09:24:17 pm »

Could you post the new, working code, for verification?
Logged
Rabraham
Newbie
*
Posts: 20


View Profile Email
« Reply #8 on: January 14, 2008, 09:49:29 pm »

Could you post the new, working code, for verification?


Sure, here:

Code:
string materialSuffix = "material";
string textureSuffix = "texture";

string textureName = newMaterialNameBase + textureSuffix;

// For this to work, we need to remove the existing texture from the engine's
// texture list.  If meshWrapper colors will be used by more than one meshWrappers,
// this will have to change to adding a new texture with a different name.
iTextureWrapper* roomTextureWrapper  = engine->FindTexture(textureName.c_str());
if (roomTextureWrapper != 0)
{
engine->GetTextureList()->Remove(roomTextureWrapper);
}
roomTextureWrapper  = engine->CreateBlackTexture(textureName.c_str(), 256, 256, 0, CS_TEXTURE_3D);


// Added Code

const char* textureClass1 = roomTextureWrapper->GetTextureClass();
cout << "Texture Class is: " << textureClass1 << endl; // this prints nothing (textureClass1 is "")

cout << "Setting Texture Class to nocompress ..." << endl; // Did the same also with the options "normalmap" and  "lookup" - didn't work
roomTextureWrapper->SetTextureClass("nocompress");

const char* textureClass2 = roomTextureWrapper->GetTextureClass();
cout << "Texture Class is now: " << textureClass2 << endl; // This prints "nocompress" as expected

// End Added Code

csImageMemory* img = new csImageMemory(256, 256);
img->Clear(*color);
roomTextureWrapper->SetImageFile(img);

csRef<iTextureManager> txtmgr = g3d->GetTextureManager();
roomTextureWrapper->Register(txtmgr);

csRef<iMaterial> material(engine->CreateBaseMaterial(roomTextureWrapper));
string materialName = newMaterialNameBase + materialSuffix;
iMaterialWrapper* materialWrapper = engine->GetMaterialList()->NewMaterial(material,materialName.c_str());

meshWrapper->GetMeshObject()->SetMaterialWrapper(materialWrapper);

Also I tried to set the bit depth to 24 and 32 with the command line option and it didn't help, and when I run with debug it sayd bit depth 32.
Logged
res
Develazyoper
CS Developer
Full Member
*****
Posts: 206


View Profile Email
« Reply #9 on: January 14, 2008, 10:00:14 pm »

Hm okay, I don't see anything wrong with the code...

Another possibility could be that the graphics driver does some unwanted color reduction - but that's rather rare nowadays. Still, what graphics card model do you have?
Logged
Rabraham
Newbie
*
Posts: 20


View Profile Email
« Reply #10 on: January 14, 2008, 10:06:12 pm »

Here:

Graphics Card Manufacturer   Powered by ATI   
Graphics Chipset   Radeon X1300 Series    
Device ID   7187   
Vendor   1002   
      
Subsystem ID   215C   
Subsystem Vendor ID   1458   
      
Bus Type   PCI Express   
Current Bus Setting   PCI Express   
      
BIOS Version   009.012.020.002   
BIOS Part Number   113-AB05900-103   
BIOS Date   2007/01/03   
      
Memory Size   256 MB   
Memory Type   DDR2   
      
Core Clock in MHz   452 MHz   
Memory Clock in MHz   396 MHz   
      
Primary Display   Yes   


Drivers:

Driver Packaging Version   8.343.2-070214a1-043706C-Lenovo   
Provider   ATI Technologies Inc.   
2D Driver Version   6.14.10.6666   
2D Driver File Path   System\CurrentControlSet\Control\Video\{A628FA1D-AC78-4C8C-992B-07253DCEEF68}\0000   
Direct3D Version   6.14.10.0471   
OpenGL Version   6.14.10.6348   
Catalyst┬« Control Center Version   2007.0214.1241.22428

   
Logged
Rabraham
Newbie
*
Posts: 20


View Profile Email
« Reply #11 on: January 14, 2008, 10:08:31 pm »

Another thought  - Maybe I am missing a Plugin?
Current Pkugins loaded at CS startup are:

Code:
csargv[0]="blah";
csargv[1]="-verbose";
object_reg = csInitializer::CreateEnvironment (1, csargv);

  if (!csInitializer::RequestPlugins (object_reg,
                                      CS_REQUEST_VFS,
                                      CS_REQUEST_PLUGIN( "crystalspace.graphics2d.wxgl", iGraphics2D ),
                                      CS_REQUEST_OPENGL3D,
                                      CS_REQUEST_ENGINE,
                                      CS_REQUEST_FONTSERVER,
                                      CS_REQUEST_IMAGELOADER,
                                      CS_REQUEST_LEVELLOADER,
                                      CS_REQUEST_REPORTER,
                                      CS_REQUEST_REPORTERLISTENER,
                                      CS_REQUEST_END))
  {
    csReport (object_reg, CS_REPORTER_SEVERITY_ERROR,
              "crystalspace.application",
              "Can't initialize plugins!");
    return false;
  }
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 8.187 seconds with 14 queries.