StMark's picture

One step forward

This is the continuation of my last blog, so I made one step further

Just commented out

                GL.Material(MaterialFace.Front, MaterialParameter.Ambient, new Color4(0.3f + 0.7f * c * c, 0.3f + 1.4f * c * c, 0.7f - 0.7f * c * c, 1.0f));
                //GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Diffuse,  new Color4(0.3f + 0.7f * c * c, 0.3f + 1.4f * c * c, 0.7f - 0.7f * c * c, 1.0f));
                //GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Specular, new Color4(0.3f + 0.7f * c * c, 0.3f + 1.4f * c * c, 0.7f - 0.7f * c * c, 1.0f));
                //GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Emission,  new Color4(0.3f + 0.7f * c * c, 0.3f + 1.4f * c * c, 0.7f - 0.7f * c * c, 1.0f));    

and added a normal

                GL.Normal3(0.0f, 0.0f, 1.0f);
                GL.Vertex3(-1.0f, -1.0f, 1.0f);
                GL.Vertex3(1.0f, -1.0f, 1.0f);
                GL.Vertex3(1.0f, 1.0f, 1.0f);
                GL.Vertex3(-1.0f, 1.0f, 1.0f);

and I got the right material. I must think of the material-parameters I commented out but what i really do not understand
until now is the fact that the vector of the normal has a positive z-dir, that means into the screen, so it walks the same
dir as the light vector. If I set z negative the colors look faded.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
StMark's picture

First I changed the light

            float ambientLight = 1.0f;
            float[] lightKa = { ambientLight, ambientLight, ambientLight, 1.0f };  
            GL.Light(LightName.Light0, LightParameter.Ambient, lightKa);
            float[] lightPos = { 0.0f, 0.0f, 10.0f, 1.0f };
            GL.Light(LightName.Light0, LightParameter.Position, lightPos);
            GL.Light(LightName.Light0, LightParameter.SpotDirection, new float[] { 0, 0, -1 });

the light source is in positive z-Direction, that means it is outside the monitor there where you are sitting and
shining directly into the monitor onto the cubes. There is only ambient light.

Now I can use the normal in the right way, you must do it, otherwise the cubes look fade yellow.

GL.Normal3(0.0f, 0.0f, -1.0f);

StMark's picture

With material "Jade" and rotated view

the code

               // Jade
                GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Ambient, new Color4(0.14f,	0.22f,	0.16f,	0.9f));
                GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Diffuse, new Color4(0.54f, 0.89f, 0.63f, 0.9f));
                GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Specular, new Color4(0.32f, 0.32f, 0.32f, 0.9f));
                GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Shininess, 12.8f);

the light

            float diffuseLight = 0.6f;
            float ambientLight = 1.0f;
            float specularLight = 0.7f;
            float[] lightKa = { ambientLight, ambientLight, ambientLight, 1.0f };
            float[] lightKd = { diffuseLight, diffuseLight, diffuseLight, 1.0f };
            float[] lightKs = { specularLight, specularLight, specularLight, 1.0f };
            GL.Light(LightName.Light0, LightParameter.Ambient, lightKa);
            GL.Light(LightName.Light0, LightParameter.Diffuse, lightKd);
            GL.Light(LightName.Light0, LightParameter.Specular, lightKs);
StMark's picture


StMark's picture

now I tried to show the real data, but there was a problem with the light, cause
the objects showed no shades. I changed the Light-parameters and it looked

 float ambientLight = /*1.0f*/0.0f;
            float diffuseLight = /*0.6f*/1.0f;
            float specularLight = /*0.7f*/1.0f;

So the difference is the ambient light. It is switched off now.

real data