Light artifacts

Hi,

I detected light artifacts in my engine when wall consists of two triangles with texture tiling. If wall has lots of triangles then artifacts are minimal.

I made also screenshot:
<div class=“ubbcode-block”><div class=“ubbcode-header”>Click to reveal… <input type=“button” class=“form-button” value=“Show me!” onclick=“toggle_spoiler(this, ‘Yikes, my eyes!’, ‘Show me!’)” />]<div style=“display: none;”>[/QUOTE]</div>

Camera location = light location

Could anyone say what may cause those sharp artifacts?
My shaders are taken from tutorials.

Shaders are incorrect. Post them here.

Guess: the vertex shader computes cos(angle) and interpolates it instead of computing it in the fragment shader.

Thanks for your quick reply.

I just found out that light distortion depends on size of surface. I made some very high walls:
<div class=“ubbcode-block”><div class=“ubbcode-header”>Click to reveal… <input type=“button” class=“form-button” value=“Show me!” onclick=“toggle_spoiler(this, ‘Yikes, my eyes!’, ‘Show me!’)” />]<div style=“display: none;”>

[/QUOTE]</div>
Walls are 8x2000. 8x1 is most correct. Looks like lighting is still per vertex somehow…

I have one shader for any type of light. If you see some other wrong coding in shaders, please let me know :smiley: My performance isnt’t excellent with shaders binded.

I zipped and uploaded my shaders here.

I found a bug in my vertex shader experimentally! Thanks to DmitryM for a hint! :cool:

Row 14:

LightDirection = normalize(Aux);

have to be

LightDirection = Aux;

Yes, that should do it. Be sure to understand why your original code (from what tutorial?) was wrong.

I mixed directional, point and spot lights tutorial codes in here.
There are also ‘aux’ variable normalized in vertex shader. I had spotlight distortions even with clean copy-paste code:
<div class=“ubbcode-block”><div class=“ubbcode-header”>Click to reveal… <input type=“button” class=“form-button” value=“Show me!” onclick=“toggle_spoiler(this, ‘Yikes, my eyes!’, ‘Show me!’)” />]<div style=“display: none;”>

[/QUOTE]</div>

Could anyone look my shaders, why specular light doesn’t work (it’s blinking)? :frowning:
Link to my current shaders

It looks like a very longwinded and convoulted shader. You’re calculating the distance in the vertex shader which means that if your scene isn’t very high-poly, your shader will interpolate the results, causing squints along the edges of polygons and such.

At the moment my scene is very low-poly. Every surface has 4 vertices with texture tiling. So far I have found only ONE shader which has working specular light (even with my low-poly scene) >> LINK
All other shaders on the web failed with specular light.

Unfortunately, I had no luck to implement parts of his code into my shader. Always got white screen. I also don’t understand 100% his code.

I’ll try to calculate distance in fragment program. Anything else that should be in fragment?

Thanks for all of he replies. For the moment only bug is specular lighting and problem lies somewhere in the halfvector calculation.

I get the impression you’re trying to piece this together without really knowing how it all works. And believe me, when I was learning this, I couldn’t find a working shader anywhere.

I think that I finally get rid of artifacts after hours of work :slight_smile:
This tutorial helped me to get correct specular light.

I used dot product of reflect vector and vertex position to calculate specular light.

Vertex shader:


NormalVector = vec3(gl_NormalMatrix * gl_Normal);
VertexPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
LightPosition = vec4(gl_LightSource[0].position);
LightVector = vec3(LightPosition.xyz - VertexPosition.xyz * LightPosition.w);

Fragment shader:


ReflectVector = reflect(normalize(-LightVector), normalize(NormalVector));
RVdotVP = dot(normalize(ReflectVector), normalize(-VertexPosition));
Color += Attenuation * Specular * pow(RdotVP, Shininess);

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.