Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OpenGL Lighting Issue
#2
(09-23-2024, 12:47 PM)aadityap0901 Wrote: While I was coding the new QB_Blocks rewrite, I decided to add GL Light.
Eventually it worked someway, but I can't figure out why did this happen:

[Image: 09232024180833.png]
It does not occur in flat worlds.
Can somebody explain? How can I fix it?
Hi !

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.
Reply


Messages In This Thread
OpenGL Lighting Issue - by aadityap0901 - 09-23-2024, 12:47 PM
RE: OpenGL Lighting Issue - by MasterGy - 09-23-2024, 01:22 PM
RE: OpenGL Lighting Issue - by aadityap0901 - 09-23-2024, 02:45 PM
RE: OpenGL Lighting Issue - by MasterGy - 09-23-2024, 02:58 PM
RE: OpenGL Lighting Issue - by MasterGy - 09-23-2024, 03:40 PM
RE: OpenGL Lighting Issue - by aadityap0901 - 09-24-2024, 10:01 AM
RE: OpenGL Lighting Issue - by Petr - 09-24-2024, 07:31 PM
RE: OpenGL Lighting Issue - by aadityap0901 - 09-25-2024, 12:00 PM
RE: OpenGL Lighting Issue - by aadityap0901 - 09-26-2024, 04:05 PM
RE: OpenGL Lighting Issue - by Petr - 09-27-2024, 08:14 AM
RE: OpenGL Lighting Issue - by aadityap0901 - 09-27-2024, 12:31 PM
RE: OpenGL Lighting Issue - by aadityap0901 - 10-02-2024, 12:57 PM



Users browsing this thread: 1 Guest(s)