Deferred lighting, first test

A very boring scene, but with 49 pointlights simulated through deferred shading!

Pardon my ignorance, what is deferred shading?

  1. draw scene normals and depth from main camera view to a texture
  2. for each light, draw a billboarded quad that covers the size+falloff of the light
  3. the quad has a shader that reads normals+depth and calculates how much the pointlight affects each pixel



    cool things are:
  • complexity of the scene isnt affected by lighting, litting time is only dependant on how many pixels to lit in screenspace
  • doing 50 small lights has the same cost as one big light covering the same screen space area
  • all lighting is per pixel



    it’s also possible to render out other properties to use for the lighting stage, like material and so on…



    http://www.beyond3d.com/articles/deflight/

How is the effect coded in JME? In my opinion the engine should automatically decide if it can use shadier lighting each time the program is run using the same light class as regular lights with no extra coding on the users part.



By the way how dose the performance of this method compare to my code?

com.jme.wtil.LightStateController

ah cool…so many differences so it's hard to compare…but probably deferred shading is lots slower when close to lights. but one of the good things is that you get around the max 8 lights, which is nice if you work with "real" meshes that are not evenly cut up in small pieces to allow for different lights…another good thing compared, is that a very complex object is as light to lit as a very simple one with the deferred lighting way…

and i don't know any game that has used it as of today(stalker has some notes about it in gpu gems 2, but that's all i know)…probably cause it's not worth it yet

You said you think jme should know if it should use deferred lighting or not.  I assume your talking about if the scene uses more than one light.  I was just wondering if you guys could implament something bsp/light related.  Could jme do light switching?  Or could you have deferred lighting  make lightmaps that would be pretty cool you would want to precalculate everything thou.  I thought deferred lighting was just a cubemap with the simulated lights on it and you projected the cubemap onto the object.  Sorry for all the noise, it's what I do :smiley:

I don't know if you're still at this forum… but would you mind sharing this code (if you still have it)? I'm interested in trying out deferred rendering in jME and this code would definitely help me  :slight_smile:



Thanks!

/Robert

If you would share the code of that deferred shader it will be very nice… please? :slight_smile:

so many improvements to these techniques today that it would be worth more creating something from scratch (check out light pre-pass for example). with a lot of games having picked up deferred rendering, there are tons of papers out on it (and code).

Yeah I've started to implement it but I was wondering if JME has support for MRT and if has, how to use it.

you just send in a list of textures to the texturerenderer render method and from your pixel shader write to gl_FragData[]

Ok. So I have looked into LWJGLTextureRenderer class and setting multiple targets not work with so there is 1 draw buffer and rendering to more than one target at time causes to render to each texture individually. That would decrease performance of implementation. I've also looked into LWJGLPbufferTextureRender and it's seems to be what I need for implementation. Am I right?

it should render to several rendertargets in one drawcall if the card supports it.

ive been wondering for a long time as to how i would get more than 8 lights in gl, guess i finally got an answer