Dear all,

How do use a different material and different colors on the front and back side of the polygons?

I have a simple quadrangle with colors (and secondary colors -> where are these used?") set. I

would like to render the front and back side of this polygon differently, e.g. with a general material

on the front (not using the colors on the vertices) and using the colors from the vertices on the back

side: I tried the code below. When I change values for the front side (for example setting

ColorMaterial to GL_DIFFUSE) this always seems to affect both sides.

----------------------------------------------------------------------------------------------------------------------------------------------------

MaterialChunkPtr matChunk = MaterialChunk::create();

beginEditCP(matChunk);{

  // Front

  matChunk->setDiffuse(Color4f(0.0, 1.0, 0.0, 1.0));

  matChunk->setEmission(Color4f(0.0, 0.0, 0.0, 1.0));

  matChunk->setSpecular(Color4f(0.0, 0.0, 0.0, 1.0));

  matChunk->setAmbient(Color4f(0.0, 1.0, 0.0, 1.0));

  matChunk->setColorMaterial(GL_NONE);

  matChunk->setLit(true);

  //Back

  matChunk->setBackDiffuse(Color4f(0.0, 0.0, 1.0, 1.0));

  matChunk->setBackEmission(Color4f(0.0, 0.0, 0.0, 1.0));

  matChunk->setBackSpecular(Color4f(0.0, 0.0, 0.0, 1.0));

  matChunk->setBackAmbient(Color4f(0.0, 0.0, 1.0, 1.0));

  matChunk->setBackColorMaterial(GL_DIFFUSE);

}endEditCP(matChunk);

ChunkMaterialPtr mat = ChunkMaterial::create();

beginEditCP(mat);{

  mat->addChunk(TwoSidedLightingChunk::create());

  mat->addChunk(matChunk);

}endEditCP(mat);

-----------------------------------------------------------------------------------------------------

I also tried to use a SimpleMaterial for the front. Then I added a MaterialChunk where I

set another SimpleMaterial as BackMaterial. I could have different material on the back

and front but found it difficult to predict the result .......

What is the right way to do what I want ? What is the secondary Color for and how do

I make use of it?

 

Any help would be appreciated.

Kind regards,

Bjoern Zehner

Reply via email to