PDA

View Full Version : Lookup-Texture instead of pow causes strange gfx errors



namespace
12-12-2004, 07:42 AM
Hello!

I'm trying to set up simple phong shading with diffuse and specular term.
Everthing looks nice and correct as long as I use pow(specular, exp) to calculate the specularvalue.
Screenshot (http://www.codecreator.net/screen_35.png)

When using a texture as lookup table for specularity I get the same results with some strange sideeffects:

Dull spot where the brightest pixels should be:
Screenshot (http://www.codecreator.net/screen_34.png)

Strange grey lines next to the real specular highlights:
Screenshot (http://www.codecreator.net/screen_38.png)

Heres the lookup texture I use:
Specmap (http://www.codecreator.net/specmap.png)
Every exponent is stored in 5 lines in the texture to prevent the filter from fetching texels that don't belong to the exponent the shader wants.
The values are calculated with a simple for-loop:


for(uint x = 0; x < width; ++x)
{
double p = pow( (float)x / (float)width, power) * 255.0;
line[x] = (uchar)p;
}
Heres the list of things I already tried which didn't work:
o Enabling / Disabling Mipmaps
o Different wrapmodes CLAMP_TO_EDGE, CLAMP, REPEAT
o Different filtermodes (LINEAR, NEAREST)

My GLSL-shaders (comments are in german, but you are familiar with phong, right? ;) ):
Vertexshader (http://www.codecreator.net/bump.glvs)
Pixelshader (http://www.codecreator.net/bump.glfs)

I added some if- and else-statements to doublecheck the shaderoutput:

color.rgb = vec3( texture2D(t_spec, vec2(specular,u_specular_exp)) );
if(color.r > 0.75)
{
color.rgb = vec3(1.0, 0.0, 0.0);
}
else
{
if(specular >= 0.99)
color.rgb = vec3(0.0, 1.0, 0.0);
}The result:
Screenshot (http://www.codecreator.net/screen_42.png)

This tells me that the specular term is calculated correctly (the place where the dull spot is, is colored green) but the values from the texture are smaller than 0.75. :p

So the texture seems to be the problem, but it looks correct to me.
I tested the output by setting the S-coordinate to zero and slowly increased it up to 1.0.
As expected the color-values became bigger, no darker zones like in the dull spot.

I'm really confused.
What is this? A driver bug?
:p

PS:
Geforce 6800 GT
1.5.2 NVIDIA 66.29 (Linux)

namespace
12-13-2004, 11:17 AM
Ok, seems to be a driver bug.
The cards interpolates between the first and last pixel column.
When the first column is painted white all highlights are ok.

Can anyone from nvidia tell me what this is all about?
Is my card broken?