WIP Indirect Lighting

Today I’ve been toying around with some Volume Lighting and Indirect Lighting, it’s just starting to fall together which inspired me to do a quick share…



http://imgur.com/download/0SR92

http://imgur.com/download/x5qsK



The scene is

1x unlit white capsule

0x jME lights

1x a single bright omni light (which is just a PointLight that isn’t added to the rootNode),

1x my voxel terrain with the custom volume lighting.





The scene uses a super bright point of light with next to no falloff so there is loads of light to bounce around, and the scene is black so there is no light creeping into the shadows giving the false impression of global illumination.



There is no BSR or PSSM, shadows are just cast where the light gets blocked, the system is really nice like that.



http://imgur.com/download/sTsJ7(No Indirect Lighting)



The indirect lighting is generated in a single pass during mesh creation, and uses both Radiosty (light ‘bouncing’ off, and picking up the colour from, nearby surfaces) and Global Illumination (more or less Ambient Occlusion… if you think about right after the sun goes down (or right before it rises) it’s still super bright outside, and you can see everything, but there are no shadows everything is just lit up… we normally fake this by adding some ambient lighting to our scene then applying an AO pass wich basically darkens areas that are close to each other).



All this gets baked at runtime into the vertex colours of the mesh, which get’s used to light the diffuse colours, so once generated it runs really very fast as there are no lighting calculations to make. Generation/baking time is currently a half as quick as without the lighting(? perhaps), it’s fast enough to stream in, and even if it wasn’t (very slow cpu for example), it can be pre-calculated during level loading.



http://imgur.com/download/IBwvn



I have done no work at all on updating meshes, or light buffer updates so I can’t say how well dynamic lights will work, my guess is probably pretty crap at this early stage :wink:



It is still really early days but it’s looking promising. The scene is running from a single point light to get things rolling, but behind the scenes, the mesh is being lit by a volume of light that fills all the empty space, and that volume can contain any amount of light… so the concept of a “point of light” is no longer applicable, you can still have a single point of light or 2, or 5, or 1000, or light box, or a rope of light, or an object made of light (like a glow stick), and it all runs at the same speed… that speed is mostly governed by accuracy so on a fast rig, the shadows will be sharp and light bleed will be minimal, on a crappy netbook the lighting and shows will be large and chunky.



This clearly has many limitations, the biggest being it will only work on the voxel terrain, however my j3o voxeliser could be utilised to either generate a lo res lighting mesh to apply to an existing model (or even an entire scene, generating a low res voxel version of a scene for lighting is far from a new idea), or non voxel mesh can still be lit with standard dynamic jME lights.



Still very rough, the values are super harsh in the screen shots but I’m trying to show off the effect, not use it subtly as intended… but it’s very early days, well day 1, so promising progress :slight_smile:



Cheers

James

7 Likes

Nice James!

Only problem IMO is that the shadow/light quality will depend of the terrain mesh complexity.

Looks really cool.



There was a time that I thought you’d finish a game before me… :slight_smile: :slight_smile: :slight_smile:

Nice work James!

This reminds me of global illumination technique i learned at a talk by Nikolay Stefanov from Massive. Apparently a variation of it was used in the Uncharted game (not the latest one) and some other mod of it in the sequel.

It’s very good at static lighting, but dynamic lights is slow.



Here is the notes from Nikalays speech if anyone is interrested :slight_smile:

1 Like

Cool

@thetoucher Whoa you really do lots of nice and different stuff, I am liking your posts since the first one probably. :slight_smile:

Anyway, I can only hope that you find enough time to put all this stuff in one really spectacular game (or more really, would be nice :P).

That looks very nice :slight_smile:


All this gets baked at runtime into the vertex colours of the mesh, which get’s used to light the diffuse colours


As you say one needs to use your voxel terrain, would it be hard to transfer to other at runtime generated terrain meshes like blocky-voxel-terrain?

@nehon Cheers, yeah that does suck a but, but since the scene has LOD, so will the shadows. I’m not using the GPU for any serious calculations (except post effects), so when we get tessellation I could ramp the quality up over even past pixel res ? who knows…



@pspeed hahaha thanks, yeah I will never finish anything :wink:



@kwando thanks, great link, thanks for sharing, I got heaps out of it.



@normen u r



@InShadow thanks, I hope so to.



@enum cheers, the way I use this on my terrain could not be directly applied to a larger blocky terrain since the vertexes are too far apart and that’s what defines quiality. You could subdivide the cubes and it would work (we need tesselation, tesselation is the new shader injection), or there is are ways to apply this to any mesh which I’m thinking over (leaning towards light probes).

Well you could dynamically in code wrap a texture over a abitrary object, giving each triangle a part of it with a size related to the real size in the world. (plus leave a border to make sure no bleeding happens)



Then do the radiosity calculation for each texel instead of each vertex. And you would be free from the mesh itself.



Speed would probably be slow, however when done offline and save those lightmap i would perfectly fit static scenes.

@EmpirePhoenix that is essentially what my j3o voxeliser does, but it can also insert that data into the “terrain” to be included in the sim so it can effect the environment / terrain around it… a mesh outside the voxel sim cant easily effect it.



This should all be fine for static objects, dynamic objects I think I will just light with (realtime) probes and use normal shadows cast onto the “terrain”. I may do all shadowing with PSSM and just use this for lighting.