Jump to content

  • Log In with Google      Sign In   
  • Create Account

Support multiple lights in Opengl ES 2.0 (no MRT)


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
3 replies to this topic

#1 cebugdev   Members   -  Reputation: 330

Like
0Likes
Like

Posted 23 February 2014 - 06:59 PM

hi guys,

 

im porting my (Desktop) DirectX 9 based game framework(engine) to OpenGL ES 2.0 (Android) for a game that i am working now,
currently i am on the process of porting the lighting implementation (it uses HLSL) and it utilizes multiple lights with multiple render target (DX uses texture surface), 
 

but i am just wondering since based on what i researched initially, OpenGL ES 2.0 does not support MRT,

So, how can i support multiple lights in OGL ES 2.0?

I see some games in android that is utilizing multiple lights (unless they are using lightmaps).
What are the options for this?
 

Going to Opengl ES 3.0 is not an option as of the moment 'coz the client wants to support as many devices as possbile for the game, unless i'm wrong and OGL ES 3.0 is already available to most if not all Devices?

 

Sorry for the question/confusion, i am fairly new to OpenGL, spent most of my years with Directx 9 and just shifted to DX 11 last year smile.png


Edited by cebugdev, 23 February 2014 - 08:25 PM.


Sponsor:

#2 lask1   Members   -  Reputation: 800

Like
0Likes
Like

Posted 23 February 2014 - 11:16 PM

Ah I remember seeing a post like this on the raspberry pi forums but I can not find where it is sad.png.

 

Does GLES2 support multiple color attatchments? Can you take advantage of a stencil or depth buffer(Maybe not depth... wink.png )?



#3 Chris_F   Members   -  Reputation: 2461

Like
3Likes
Like

Posted 23 February 2014 - 11:31 PM

By "utilizes multiple lights with multiple render target" do you mean to say that it was a deferred renderer?

 

Light Pre-Pass (deferred lighting) doesn't require MRT and neither does forward shading. There is technically no limit to the number of lights either is capable of supporting. If you want to port your engine more or less as it is currently, you could maybe consider targeting OpenGL ES 3.0 instead. It's still pretty new, but there are already phones and tablets that support it, and ES 3.0 has MRT.



#4 Vincent_M   Members   -  Reputation: 744

Like
0Likes
Like

Posted 24 February 2014 - 11:15 PM

The way I got around it was by writing an UberShader system. Basically, you'd write an entire vertex/fragment shader pair that'd take the max amount of lights for global, point and spotlights, then loop through each of them, and additively add to the final fragment color. Looping can be very slow, especially in fragment shaders. This is especially true if this is mobile hardware as it most-likely is.

The advantage of the uber shader was that it could be compiled, and recompiled for however many lights you'd have in the scene. Usually, you'd only want 1 - 2 lights max as shading can get expensive quickly, but with an UberShader, you could only compile certain parts of the shader that type of light. You'll most-likely run into the small limit of varying data that can be passed into the fragment shader if you're doing per-fragment lighting, so 1 - 2 lights will be all you'll be able to afford there.

There can be drawbacks to this system if you ever toggle lights on or off as you'll have to recompile all of the variations of your shaders that rely on dynamic lighting, but it'd be a minor hiccup if this doesn't happen a lot.

Also, if you plan on supporting any Android devices that have NVIDIA's Tegra hardware in it, you may luck out, and get the OpenGL ES 2.0 MRT extension, which would be a nice speed-up for those devices compared to others.




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