[GSoC 2011 - Accepted] Modern Illumination Techniques

Threads related to Google Summer of Code
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 136

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by spacegaier »

One general note: Please always add important points such as the link to the Ogre fork where you will do your work also to the wiki page, so that those key information are stored at a central place. Thanks!

Regarding compositors: Nothing I am aware of. There is an Ogre sample that deals with compositors, you could have a look at.
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
andrei_radu
Google Summer of Code Student
Google Summer of Code Student
Posts: 55
Joined: Fri Mar 18, 2011 8:37 pm
x 8

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by andrei_radu »

I've looked trough the compositor demo(and the deferred shading demo), but my biggest problem right now is adding a second geometry pass. Is there any sample that does that?

Updated the wiki(will polish it a bit; not quite familiar with wiki syntax). Will also try and keep it updated.
My Google summer of code 2011 topic: Modern Illumination Techniques
My Google summer of code thread
My Google summer of code wiki page
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by Mind Calamity »

The techniques that you mentioned are very impressing, when you complete this project it will be open source and the we will have access to it, right ?

Light techniques in general are really interesting, and I'd love to take a look at how they're implemented, and probably "steal" some code :D .

Good luck!
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 136

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by spacegaier »

Yes, the code will be open-source. There soon should be an Ogre fork, where you can follow it.
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
andrei_radu
Google Summer of Code Student
Google Summer of Code Student
Posts: 55
Joined: Fri Mar 18, 2011 8:37 pm
x 8

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by andrei_radu »

Also be sure to follow the wiki page, I'll start updating my progress there as soon as I get some schoolwork of my hands and start coding.
My Google summer of code 2011 topic: Modern Illumination Techniques
My Google summer of code thread
My Google summer of code wiki page
LBDude
Gnome
Posts: 389
Joined: Mon Jul 26, 2010 10:53 pm
x 22

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by LBDude »

I'm looking forward to following your progress :)
My blog here.
Game twitter here
psx
Gnoblar
Posts: 15
Joined: Thu May 14, 2009 10:35 am

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by psx »

Hi Andrei.
I'm very glad that you have taken this work.
Right now I'm implementing deferred shading (more advanced than in a sample)
and I would like to help you as much as I can.
andrei_radu wrote:I've looked trough the compositor demo(and the deferred shading demo), but my biggest problem right now is adding a second geometry pass. Is there any sample that does that?
ok. You can do it by compositor script, or in code.

Script looks like this

Code: Select all

compositor
{
    technique
    {
        target mrt_output //This renders to GBuffer
        {
            pass render_scene //This renders geometry .. Look at manual
            {
                 material_scheme gb_out_scheme
            }
        }

        target output  //This renders to screen
        {
            pass render_scene  //This renders geometry again
           {
                // You can use
                // different material scheme
                // visibility bit mask
                // queue groups
           }
        }
    }
}
So if you need more info - just ask
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by Noman »

The current deferred shading demo already does more than one geometry pass. After the opaque scene is lit the transparent objects are rendered in normal (forward) mode. Check out "compositor DeferredShading/ShowLit" in the deferred.compositor script.
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by Noman »

Hi,

Coding season is nearly upon us, so it is a good time to read up on mercurial and set up a fork that you will use to develop your project.
I recommend first reading a bit about distributed source control (if you aren't familiar with it). I used http://www.hginit.com as its fairly friendly and simple.
Afterwards, create a user on bitbucket and fork ogre. Some URLs to help you do that :

http://www.ogre3d.org/developers/mercurial
http://www.ogre3d.org/docs/OGREDevelope ... index.html
http://www.ogre3d.org/tikiwiki/Getting+ ... TortoiseHG (if using windows)

The fork name should be Ogre-GSoC2011-ModernIllumination

Once you set it up, try committing something minor (creating a directory for your demo or something) to see that the pipeline is working. Also make sure that the fork compiles (shouldn't be a problem).

Good luck!
andrei_radu
Google Summer of Code Student
Google Summer of Code Student
Posts: 55
Joined: Fri Mar 18, 2011 8:37 pm
x 8

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by andrei_radu »

Hey, as I posted in my proposal, I have exams for the next 3 weeks, so I won't be doing any heavy coding during this period(though I hope to finish deferred lighting asap). In addition to that, my laptop broke, and I'm expecting a new one in 2-3 days, so that's when I'll create the fork. Will update with progress.
Andrei
My Google summer of code 2011 topic: Modern Illumination Techniques
My Google summer of code thread
My Google summer of code wiki page
andrei_radu
Google Summer of Code Student
Google Summer of Code Student
Posts: 55
Joined: Fri Mar 18, 2011 8:37 pm
x 8

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by andrei_radu »

Here's my bitbucket reppo: https://bitbucket.org/andreiradu/ogre-g ... lumination. Got my new comp, and will start working on deferred lighting.
My Google summer of code 2011 topic: Modern Illumination Techniques
My Google summer of code thread
My Google summer of code wiki page
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by Assaf Raman »

Hi, where do we stand with this project?
Watch out for my OGRE related tweets here.
andrei_radu
Google Summer of Code Student
Google Summer of Code Student
Posts: 55
Joined: Fri Mar 18, 2011 8:37 pm
x 8

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by andrei_radu »

Hey, sorry for the lack of updates, I'm in the process of moving, so I don't have a steady internet connection.
I almost finished the shaders for deferred and inferred lighting, and am currently in the process of integrating that. I was thinking of highjacking the current deferred shading plug-in and adding a drop-down that controls the technique used(that way we can do a comparison). Is that ok?
My Google summer of code 2011 topic: Modern Illumination Techniques
My Google summer of code thread
My Google summer of code wiki page
jonim8or
Goblin
Posts: 287
Joined: Mon Dec 08, 2008 4:49 pm
x 10

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by jonim8or »

I'd love to see the Deferred Shading plugin get into the Ogre trunk. At the moment I'm using my own branch of the Ogre project, with deferred shading plugin, and have to regularily synchronize it with Ogre trunk.

Here's my most recent version of the patch. However, it has some problem with Dll's (I always use Ogre_Static)
You do not have the required permissions to view the files attached to this post.
andrei_radu
Google Summer of Code Student
Google Summer of Code Student
Posts: 55
Joined: Fri Mar 18, 2011 8:37 pm
x 8

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by andrei_radu »

I was actually referring to the deferred shading example. Sorry for the confusion.
My Google summer of code 2011 topic: Modern Illumination Techniques
My Google summer of code thread
My Google summer of code wiki page
andrei_radu
Google Summer of Code Student
Google Summer of Code Student
Posts: 55
Joined: Fri Mar 18, 2011 8:37 pm
x 8

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by andrei_radu »

I will probably be late with the first stage. I'm a bit caught in the complexity of the custom rendering passes and material generators. At the moment I've figured out how to generate the material for the lights, but I'm having issues with generating the material for the final pass. One of the main advantages of deferred lighting over DS is that a lot of parameters are passed in this stage in stead of being kept in the G-Buffer(albedo, spec. power, spec. intensity, screen space speed, and pretty much any precomputed lighting). Some of these are not currently used at all.
Should I generate some materials for a couple of permutations, like the current sample does, or should I try finding a more streamlined solution?
I also think I found a bug. The specular exponent is hard coded in the shader, and what is read from the G-Buffer is multiplied(kind of like a specular power).

Code: Select all

float3 light_specular = pow(dot(normal, h),32.0) * lightSpecularColor.rgb;
total_light_contrib += specularity * light_specular;
Is there some explanation for this?
My Google summer of code 2011 topic: Modern Illumination Techniques
My Google summer of code thread
My Google summer of code wiki page
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by Noman »

I think I took those functions from the deferred rendering demo that I inherited in my GSoC project. Different implementation parametrize different parts of the lighting equation. Your proposal is valid, but is it critical for your project?

As for the project, I think its naive to say "probably" will be late, as according to your plan you have both light-pre-pass and inferred lighting done by tomorrow. Good luck with that =)
Of course I'm teasing you, but self-honesty is good.

Tactically speaking :
From what I understand, light pre-pass is made of three steps
A) Render a sort-of G-buffer, storing depth and normals
B) Render the lights to the L-buffer, sampling the G-buffer in order to carry out the lighting equation
C) Render the objects of the scene, sampling the light buffer instead of calculation light equations.

A and B are similar steps to the deferred shading demo. Are you done with them yet? Can we see screenshots of intermediate buffers? (They are very good signs of progress). Maybe some code?
C is actually closer to forward rendering, as the objects are all processed again. The shader complexity here is big, and I'm not sure which approach is best for the demo. Its your call on whether to go for material generation or just manually write enough materials to get the demo working.

Some things that might be helpful :
A and B can probably be achieved by stripping down the deferred shading framework (Only output depth and normal to G-buffer, and have much simpler shaders for the L-buffer)
C will likely be a render_scene instructive in a compositor, with a custom material scheme. In order to have access to the L-buffer in the materials, the best approach would be to use the 'content_type compositor' directive, which will allow you to easily link between the materials that need the L-buffer texture and the texture itself.

Strategically speaking :
You might need to rething your timeline. You now have a better idea of the complexity of your project. Have a look at your proposal and see the items and estimates beyond the current task. Do they still make sense? It is better to make decisions early than to say "I will probably be late with the next task".
andrei_radu
Google Summer of Code Student
Google Summer of Code Student
Posts: 55
Joined: Fri Mar 18, 2011 8:37 pm
x 8

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by andrei_radu »

Well, at the moment the GBuffer renders correctly(Normals+Depth), and the light buffer seems to work fine as well(see the pic, ignore the settings). The GBuffer needs more work for inferred lighting, but nothing major. My main issue now is putting them back together, and I think I'll use a material generator here, and only cover the basic cases that are covered by the initial demo.
Image

Concerning the schedule, I will definitely drop depth peeling, since it's not really useful in the context. I will also leave SSDO for the last 1-2 weeks, and drop it if needed. I'll be able to do a better evaluation after I start working on LPV. Does that sound ok?
My Google summer of code 2011 topic: Modern Illumination Techniques
My Google summer of code thread
My Google summer of code wiki page
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by Noman »

Whether your new schedule is achievable or not is up for you to decide :)
One thing for sure - you should put the pedal to the metal if you want to achieve something meaningful in this GSoC!
andrei_radu
Google Summer of Code Student
Google Summer of Code Student
Posts: 55
Joined: Fri Mar 18, 2011 8:37 pm
x 8

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by andrei_radu »

The last part of deferred & inferred lighting to implement is the second geometry pass. Everything else seems to be working fine.
My issue is that I can't really use a render_scene pass, since I need to set the lightBuffer texture as an input, and as far as I can tell, I can't set an input to a render_scene pass. Modifying this seems a bit daunting, and I don't really see other uses for it. So my current solution is to implement a custom compositor pass for this stage. This has the added advantage that it can be more easily modified to use the culling results from the previous geometry pass. My problem is actually rendering the scene in it. Do I update the viewport, or use _renderScene on the camera, or the sceneManager? Or do I add a render target and let ogre do the rest?(and if so, what's the best way of doing that?).
I've also started thinking about the next step, which would be implementing reflective shadow maps, and have sort of similar questions. I would, obviously like them to be done using compositors, and offer easy integration. Should I add a new 'shadows' option? Something like shadows {on|off|reflective}. Another issue is that this requires shaders, so I'm not sure what the fallback would be. Another option is to implement this as a render_custom pass, but I would like to avoid that(it's easier for a user to modify a script than to add code). Either way, the result of this pass would be extra lights added to the scene. (As a quick reminder, Reflective Shadow Maps render shadowmaps with some extra info besides depth( normal and flux), then sample these maps and generate light sources based on them.
I'd appreciate some input.
My Google summer of code 2011 topic: Modern Illumination Techniques
My Google summer of code thread
My Google summer of code wiki page
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by Noman »

Like I said in the previous post, you can use the compositor content type to reference the L-Buffer texture in your materials.
This allows you to reference an internal texture in a certain compositor in regular materials. This was designed with techniques such as inferred lighting in mind, so it should be right on the money.

You can read more about it here.

As for the reflective shadows :
A) Feel free to add as many options to the deferred shading demo (Which will probably change its name at the end of this GSoC to 'illumination techniques demo' or something similar) as you wish
B) All of the advanced techniques require shaders, so there's no real reason to have fallbacks IMO. It would be nice if the demos ran on shader model 2, but the real advanced stuff might require 3 as well. Don't worry about supporting as much hardware as possible in this stage. Just keep it in CG :)
C) I don't know exactly what reflective shadow maps are (will read a bit about them soon) but you can see how I implemented shadow mapping in the deferred framework by looking at the light-casting custom composition passes.
andrei_radu
Google Summer of Code Student
Google Summer of Code Student
Posts: 55
Joined: Fri Mar 18, 2011 8:37 pm
x 8

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by andrei_radu »

Ok, deferred lighting is running, albeit with a couple of bugs. The redness in the image is caused by the specular term(it somehow gets weird values). There's also a slight bug with the tex coords(you can see the LBuffer repeating itself along the edges of the window). And the shadow casting lights don't get rendered. Will get on this tomorrow, and I hope to get the demo ready by the end of the week.
Image

I was talking about adding the RSM option to ogre itself, not the demo. It's a feature that can be used for other effects as well, and it affects the way shadowmaps get rendered. From what I see the deferred demo uses prepareShadowTextures to get the shadow maps. I wouldn't really be able to do that, since I need a shader to be used when rendering the shadowmaps, and each map will be a MRT. The other option is using a custom compositor pass for RSMs.
My Google summer of code 2011 topic: Modern Illumination Techniques
My Google summer of code thread
My Google summer of code wiki page
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by Noman »

Good to see you're making progress! The mid-term isn't far away, and its a good idea to get some good progress in so we are sure that you will get what you planned in time.
since I need a shader to be used when rendering the shadowmaps
I don't really get this point. Ogre already has many shadow techniques that use shaders. Why is this a problem?
and each map will be a MRT
Can you explain into more detail what kind of rendering setup you need to be able to pull it off? Maybe its less (structural) work than you think.
andrei_radu
Google Summer of Code Student
Google Summer of Code Student
Posts: 55
Joined: Fri Mar 18, 2011 8:37 pm
x 8

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by andrei_radu »

RSM is a particular implementation of Instant Radiosity. Instant radiosity works by casting rays from each light source, and finding the intersection with scene geometry. At each intersection point a Virtual Point Light(VPL) is generated. These lights simulate first bounce GI(obviously, the algorithm can work recursively to generate second bounce GI, but definitely not in real time). The problem is that ray tracing is relatively slow and GPU unfriendly, so RSM uses the Z-Buffer as a primitive ray tracer. For each light, a 'fat' shadow-map is generated(it contains depth, normals and flux-a scalar specific to the light type; these need to be MRTs). These shadow-maps are then sampled, and VPLs are generated. These are then used to light the scene. My problem is not using a shader on the shadow receiver, but using a fragment shader on the shadow caster(this might be already possible, but I'm not aware of it). My other problem is generating and deleting a large number of lights(we're talking hundreds, maybe more) each frame in an efficient manner.
This is both a step to achieving LPV, and a nice to have technique on it's own(it's a rather fast and good looking GI technique), though I'm not sure if it will work in real time in Ogre.
My Google summer of code 2011 topic: Modern Illumination Techniques
My Google summer of code thread
My Google summer of code wiki page
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2

Re: [GSoC 2011 - Accepted] Modern Illumination Techniques

Post by Noman »

Using a pixel shader for the shadow caster is standard. Every technique does that. Even the current deferred shading demo does that. (Check out ShadowCaster.___ in the Samples\Media\DeferredShadingMedia directory).

The only problematic part might be to tell Ogre that the shadow maps need to be MRTs. This will require a small change in Ogre. It is up to you to decide whether or not you want to go forward with it. You can also start discussions elsewhere about this specific topic (the normal developer forum might be a good place).