Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

OpenGL ES GLSL: How to add Light in shaders without gl_Normal calls?



  • I want to add a basic light to a textured object in a shader. Some basic method would be creating a lightvector but i can't use gl_Normal to calculate the light direction. Are there any workarounds? (I'm fairly new to OpenGL ES GLSL and i'm using the newest qt 5.1.1 with ANGLE for windows)



  • You need to write a vertex/fragment shader pair that implements the lighting model you wish to use. I'd suggest something simple like the Phong lighting model to begin with.

    You then need to pass in lighting parameters such as light position, light intensity, etc as uniform variables to the shaders.



  • I already have a shaderpair. I'm trying now with passing the position with uniform variables.


Log in to reply