Jump to content
  • entries
    943
  • comments
    5,899
  • views
    924,372

Environment Probes


Josh

3,479 views

 Share

Note: this is highly experiment and subject to cancellation, change, revision, etc. Now on with the blog...

 

Shadmar and Reepblue have paved the way for this research, and I am experimenting with some of these ideas in Leadwerks.

 

Environment probes in Leadwerks are an experimental entity that creates a vantage point from which a cubemap is generated. The cubemap provides a 360 degree view of the surrounding environment in a single texture. This texture can then be used in the deferred lighting routine to provide more realistic ambient lighting and reflections.

 

Let's start off with the limitations. These are not an end-all be-all solution to global illumination or reflections. Environment probes must be placed by hand, and like a light, only cover a restricted area. The smaller the area, the more accurate they can be, but they will never provide 100% physically accurate reflections. They also do not reflect dynamic objects and can only enhance static lighting. Rendering the cubemaps is a fairly expensive step and should not be performed in real-time.

 

It was fairly simple to implement a new entity type and make it render the surrounding scene into a cubemap. A new parameter was added to the Camera::SetRenderTarget() command to allow the user to specify a cubeface index, from zero to six. The resulting cubemap is displayed on a sphere in the editor.

 

blogentry-1-0-98932900-1460349900_thumb.jpg

 

The next problem is what to do with the generated cubemaps. Source Engine uses the closest environment probe to each object when rendering reflective materials. This results in popping as objects move between different probes. We don't want that.

 

It occurred to me that we could perform an additive step in the ambient light calculation, by uploading the closest 4-8 cubemaps into the ambient light full-screen shader. This is basically like performing a forward rendering though, and I realized it was better for each probe to be rendered on its own, in a deferred step, just like a point light. So now instead of thinking of environment probes as area hints of what reflections should look like, I am now considering them to be "ambient lights".

 

Environment probes / ambient lights would add two types of lighting to the scene. They would first use a low-frequency sample of the cubemap (probably by just using a low-res mipmap) and use this to add ambient light to the scene. This would do things like make a neon sign cast lighting onto the surrounding environment. Another calculation could be performed at the same time for reflective surfaces, possibly using the material's specular term as the reflectivity at each pixel. You would probably want to use pure black ambient light with this, so that the lighting just came from the environment itself.

 

The good of this is that with some extra care, you could create an environment with detailed reflections, more varied ambient lighting, and it would be completely compatible with how we do everything right now.

 

The downside is you will have to place a lot of overlapping environment probes to fill up your map, and it may be tedious to cover every part of the map, and your reflections won't react to dynamic objects or changes in lighting, without expensive re-renders of the cubemaps.

 

If it works out as described above, I see this as an additional tool you can use if wanted, to achieve some kinds of new looks in some maps. It isn't an end-all solution to completely dynamic reflections, but it could be used to enhance some types of maps.

 

More as it develops.

  • Upvote 6
 Share

3 Comments


Recommended Comments

I really hope you go forward with this. Although I've created my own system, I'd be nice to have it an official feature. I also didn't do a real world test (Full playable map with gameplay, etc), so I expect something to pop up with it. (I always do!)

 

Anyway, glad to see you're looking into this and I can't wait to hear more on this. :)

Link to comment

Yeah let me know if I can help.

I think these "free"reflections/refractions are nice to have smile.png

They only cost some texture memory to render.

Also very useful for substance support.

  • Upvote 2
Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...