Jump to content

  • Log In with Google      Sign In   
  • Create Account

OpenGL ES 2.0 Lighting System


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Vincent_M   Members   -  Reputation: 638

Like
0Likes
Like

Posted 07 November 2012 - 12:29 PM

I've been able to write per-pixel lighting shaders that can lighting features such as directional lighting, point lights, spot lights, and normal mapping support, however, I'm stuck on making this flexible.

For example, I'd like to be able to add and remove directional, point, and spot lights from my scene, and be able to push them into my shader. I'm using OpenGL ES 2.0, and my current strategy for this is to recompile my shader every time I enable or disable directional lighting, spot lighting, point lighting, or add or remove one of these lights from the scene. Obviously, this is intended to work for designing levels, and so changing the lighting states or adding and removing lights shouldn't be done in real-time gameplay. Does this sound like a good route so far?

Now, each light takes up a certain amount of uniform and varying variables, so the more lights there are, the more data has to be pushed to the shader. This can be a performance issue if I have more than 1 light on-scene at once. With the iPhone 4S's hardware, I'm only able to compile shaders that have no more than 1 directional light, 1 point light, and 1 spot light since the hardware only supports so many uniform/varying variables. It I use more of these variables than the hardware supports, then it won't compile.

Are there any good articles on designing a lighting system for OpenGL ES 2.0?

Sponsor:

#2 larspensjo   Members   -  Reputation: 1540

Like
0Likes
Like

Posted 08 November 2012 - 07:13 AM

I've been able to write per-pixel lighting shaders that can lighting features such as directional lighting, point lights, spot lights, and normal mapping support, however, I'm stuck on making this flexible.

Maybe have one shader for each lighting type?

Now, each light takes up a certain amount of uniform and varying variables, so the more lights there are, the more data has to be pushed to the shader. This can be a performance issue if I have more than 1 light on-scene at once. With the iPhone 4S's hardware, I'm only able to compile shaders that have no more than 1 directional light, 1 point light, and 1 spot light since the hardware only supports so many uniform/varying variables. It I use more of these variables than the hardware supports, then it won't compile.

I don't know about the performance of your system, but a deferred shader with tiled rendering for the lights could possibly minimize the amount of work for each light.
Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS