G
G
GlowMan2019-05-21 22:58:22
C++ / C#
GlowMan, 2019-05-21 22:58:22

Why does object lighting work incorrectly?

Help please...
Here is the code
5ce4581a4a546769279131.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2019-05-22
@DoYouGot

The last lines of the fragment shader:

"   vec3 specular = specularStrength * spec * lightColor;\n"
"   vec3 result = (ambient + diffuse + specular) * objectColor;\n"
"   FragColor = vec4(objectColor * lightColor, 1.0);\n"

Ctrl + F with result search should help find the error

T
tsarevfs, 2019-05-22
@tsarevfs

Check that the shader is actually applied as expected.
1. If you set FragColor to a constant color, does the picture change?
2. If you change the ...Strenght constants in the shader, does the picture change?
For debugging shaders, it is useful to display the values ​​of intermediate variables as the color of the dot. To do this, they need to scale their values ​​​​in the segment 0..1 which sets the color components. So by the color of the picture it will be possible to understand what kind of value you got.
Well, you should start with something simple. specular component can definitely be removed for a start.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question