Baked Environment lighting for moving objects

BGE/UPBGE/RANGE games seems always a bit flat … and this comes maybe because the shadows have only 1 tone wherever you are on the map … 100 feet under ground or standing close to a window

So, i made this material that uses a single texture . I use baked AO to determine the amount of Environment lighting dismissed . So when the character goes into some hole, all the Environment lighting is removed …

20 Textures staked into 1 and i use nodes to convert xyz world space into x,y texture space and ensure a melted transition for each meter on z axis … so the x,y is point-shader but the z is the same for all vertex of the mesh for a given point in Z space.

Yes, the ugliness comes from a 4 samples bake :smile: will bake 32 samples tomorrow to see

https://i.imgur.com/AOHCNhw.mp4

this is what the texture looks like (i put plain colors to help to understand)

20 levels : Z even number on the left, Z odd number on the right . Each square is a x,y plane, 20 planes from 0 to 19 meters high

The texture i used

Hope it helps

3 Likes

40 samples AO bake with Environment lighting set on 2.0 . I add jeans texture on the character so people would understand that Ambiant != Diffuse Color

https://i.imgur.com/lHX5Vi8.mp4

(sorry for the glitchy texture of the castle, it’s due to overlapping planes , dont know how to get ride of them automatically)

https://i.imgur.com/O8wcFkm.mp4

actually , the glitchy texture comes from that Cycle node i use for not having to use an UV map, the problem arises when the plane is perfectly aligned 45,135,225 or 315 degree so the texture can’t make a decision for some cube projection . The solution is to either change a tiny bit the planes orientation , either, blend a bit

even if i’m not craving for attention… I’m a bit surprised this doesn’t get much attention. :thinking:

This is a solution for a HUGE missing feature for a 2022 game engine

do pbr does something like this already ? cubemapping ?

With this technique you can have your characters getting completely dark when you go in dark closed space EVEN if you have put Environment lighting to simulate daytime global light

As the environement lighting is static in the scene, the idea is to make the moving characters having their sensitivity for environment lighting variate according the location on the map.

As fas as i know - yes, but unfortunately im never saw any in depth explanation of this.
Resident Evil 2 Remake, are probably one of the best example of technique of using cubemaps for all ambient lighting.
There’s no any baked lightmaps nor for enviroment nor for the characters and movable objects. Everything is lighted with “true” light sources and cubemaps.

https://aschrein.github.io/2019/08/01/re2_breakdown.html

I think the biggest problem with your technique are numbers of textures or texture size and as i see this, for being able to interpolate between different Z value, we would need to sample those textures/texture twice in the shader.

The second problem is how we actually adressing object location to textures.
Lets say we have a level like this:
The solution will work nice and easy. We take character X and Y, and that gives us UV coord to sample the texture.
We take character Z and (i guess) sample 2 closest Z axis slices and interpolate between them.

But what if we have a level such as this:
Now we have a problem because our point A and B are represent the travel of out character (sphere) from one part of location to another. While we travel, we pass 5 different texture slices and how we supposed to chose which texture we should pick to?
Also we would have certain areas where we simple waste a texture space.
Or what if character can throw something in the window? What and how we would sample if we throw an object into non walkable area. The character cant walk there, but some object are still may appear there.

When i was thinking about solutions like this back in the days, i was imagine something like a proxy mesh of the level which are basically duplicating the floor (walkable area). Those “proxy” mesh are cutted into pieces and tightly packed into one UV space. We sample a UV coordinate of those mesh by raycast and sample the texture where we store the approximate light in those area where we are.
So now we can save texture space, because we only have one, but we have some work for CPU and if we not on a plane and have Z axis - we again need more textures.

no, look,

The material i created has 1 foot on the left and 1 foot on the right. I don’t remember how the material works exactly but it’s about working like some modulo system with a smooth progressive move from bottom to top

Thats why i think the more easy stuff is to rely on a big large rectangular texture that covers the whole map .Up to the game maker to make a map that doesn’t waste space :confused:

We tried something like that before : it was about finding the closest vertex from the ray hit point on a baked floor texture. Problem with this , is that, a tiny little variation in the information in the vertex makes your WHOLE (not a point shader like in materials) character twinkle like a star. And everyone knows how much noise there’s in a baked texture. Horrible ! Ofc, it’s possible to use fake floor with high blurred texture

So after that, i tried with a light probe system. Storing information into a matrix after vertex color baking

But just like with the Ray stuff … it applies to the whole mesh … so it’s not good, pixel-point in Materials is far superior

So, at the end of the day, if i combine what i’ve done in the other thread with the stuff here, i think it would be pretty neat … just have to accept that the map gonna have to be limited in the X,Y space and not too many “Z floors”

1 Like