andrewj {l Wrote}:I have run mesh_viewer and your tangent lines (green and blue) looks correct to me.
Where in the code are the red lights (etc) added? I'd like to see the results with a single white light.
Thanks for trying it.
The code to tint things red green and blue is in the shader, in share/snis/shader/textured-cubemap-and-lit-per-pixel.shader. It's for trying to debug... the per-pixel normal's x,y,z is mapped to r,g,b (at 85%, 15% is diffuse lighting). The following change will make the lighting more "ordinary". You can right-drag the mouse while holding down the CTRL key to move the light around.
- {l Code}: {l Select All Code}
diff --git a/share/snis/shader/textured-cubemap-and-lit-per-pixel.shader b/share/snis/shader/textured-cubemap-and-lit-per-pixel.shader
index 407d496..9344fc9 100644
--- a/share/snis/shader/textured-cubemap-and-lit-per-pixel.shader
+++ b/share/snis/shader/textured-cubemap-and-lit-per-pixel.shader
@@ -108,8 +108,8 @@ varying mat3 tbn;
gl_FragColor = textureCube(u_AlbedoTex, v_TexCoord);
gl_FragColor.rgb *= diffuse;
- gl_FragColor.rgb *= diffuse * 0.15;
- gl_FragColor.rgb += 0.85 * pixel_normal;
+ //gl_FragColor.rgb *= diffuse * 0.15;
+ //gl_FragColor.rgb += 0.85 * pixel_normal;
//gl_FragColor.rgb = pixel_normal;
/* tint with alpha pre multiply */
the "gl_FragColor.rgb *= diffuse;" is correct (if the value of diffuse were correct.)
There's a mistake in the code I now see... The last two lines below were intended to put in 15% of the color as "ordinary" lighting and 85% as the normal mapped to RGB for debugging. So for my intended effect, either the first line should be active, or the last two, but not all three.
- {l Code}: {l Select All Code}
gl_FragColor.rgb *= diffuse;
gl_FragColor.rgb *= diffuse * 0.15;
gl_FragColor.rgb += 0.85 * pixel_normal;
It seems almost correct, but not quite. For example, with the light in the upper left, this looks right (I think -- it is actually surprisingly hard to tell if it's *really* right):
But this, with the model rotated 180 degrees about the axis coming out of the screen, doesn't look right
(for example the left hand side of the lips and mouth are lit, but should be in shadow, and the right hand side of the back of the head is in shadow, but should be lit. The lighting seems to be ok as the light moves in the vertical axis, but wrong as the light moves in the horizontal axis -- when the model is inverted.)