09-23-2024, 01:22 PM
(09-23-2024, 12:47 PM)aadityap0901 Wrote: While I was coding the new QB_Blocks rewrite, I decided to add GL Light.Hi !
Eventually it worked someway, but I can't figure out why did this happen:
It does not occur in flat worlds.
Can somebody explain? How can I fix it?
I've been working with opengl for the past few months, and I'm still in it now. Based on the image, it seems that there are no normal vectors for the vertices, which determine the direction of the vertices. Since they all have the same (0), the graphic will have a fog effect rather than a light effect. The direction is important because strangely enough, opengl won't determine the direction of plane domes from their location. This is because a plane has 2 sides. when it comes to light effects, it is an important factor where the light source is and in which direction the plane is facing. Imagine that you are inside a cube. the light source comes from outside. What determines that you, who are inside the cube, can see the two opposite sides of the cube? This is the interesting part, because if the normal vectors of the two opposite sides are the same, and also parallel in position, then the two sheets will be equally bright, which makes no sense. That's why we need the normal vector.
In the case of a cube, the normal vectors belonging to the points must be directed relative to the center of the cube.
If you provide the source code, I can try to include it, and then you can set it up yourself and understand it.
Where you create the points, it must be added to create the normal vectors in addition to the vertices.