Advertisement Jump to content
Sign in to follow this  
cebugdev

OpenGL Support multiple lights in Opengl ES 2.0 (no MRT)

This topic is 1790 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

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 )?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!