How to render shiny black balls?

Started by DeX, September 10, 2005, 13:51:41

Previous topic - Next topic

DeX

I've found a problem when trying to render pool balls with a black texture such as the 8 ball. You can see below how my 8 ball appears. The white circle part is reflecting the white specular highlight from my specular lighting but the black part is entirely black.



Also when I don't use a texture but simply set the ball's colour to black then the specular highlights do appear. Does anyone know what settings I can use the have the highlights appear on a black texture?

darkprophet

are you sure the normals are correct on the ball?

DP

DeX

Hi Darkprophet. The ball is rendered using gluSphere so there's no way to set up the normals. I assume this is all done for you by the glu function. Anyway I found out a way of doing it. All I had to do was call this before rendering the ball:

GL11.glLightModeli(GL12.GL_LIGHT_MODEL_COLOR_CONTROL, GL12.GL_SEPARATE_SPECULAR_COLOR);

Apparently this separates the specular lighting from the ambient and diffuse and so it ignores the colour of the texture.

hvor

What glTexEnv function do you use? If you use REPLACE, for example, than texture will replace any information from light. Use MODULATE then. Another issue can be that diffuse light is to strong compared to specular, so speculat doesn't show up very highlighted...
b]Hvor Games[/b]

DeX

Hi hvor,

I don't use any glTexEnv settings so I guess they are at default. I will try to remember those settings though when I set up light textures and other things like that.

hvor

Hm... MODULATE is by default. That SHOULD work. Maybe than it's  the material problem. Try playing with material and light different values
1. strong light, small material values
2. small light, strong material values, etc.


for material:
       GL11.glMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT, (FloatBuffer) temp.asFloatBuffer().put(lightAmbient).flip());
       GL11.glMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_DIFFUSE, (FloatBuffer) temp.asFloatBuffer().put(lightDiffuse).flip());
       GL11.glMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_SPECULAR, (FloatBuffer) temp.asFloatBuffer().put(lightSpecular).flip());
       GL11.glMateriali(GL11.GL_FRONT_AND_BACK, GL11.GL_SHININESS, shininess);



where

   private float   lightAmbient[]  = { 0.5f, 0.6f, 0.9f, 1f };
   private float   lightDiffuse[]  = { 0.6f, 0.4f, 0.9f, 1f };
   private float   lightSpecular[] = { 0.8f, 0.6f, 1f, 1f };
   private int     shininess       = 1;

You see, for example shininess = 1 is VERY shiny, and 100+ is little shiny... Hope it helps. :wink:
b]Hvor Games[/b]

DeX

Those are the kinds of settings that I have been using. The only difference is that I set shininess to 70. I found that 128 was the shiniest and 1 was the least shiny.

Anyway those settings worked fine on anything that didn't have a texture. The problem I had before was that when I gave something a black texture like that 8 ball then the specular highlights disappeared because they were absorbed by the black colour. If I separate the specular component from the ambient an diffuse then the highlight no longer gets absorbed by the texture.

Here's what it looks like now which is pretty much how I want it:


hvor

Yes, it's looking good this time.  So, separate the specular component from the ambient an diffuse .... I must remember this one...
b]Hvor Games[/b]