Use Skybox material as reflection source


Is it possible to use the Skybox material as the environment map for reflective materials? Ideally this would also work with the PBR pipeline. My understanding is that currently only a TextureCube resource can be used - and in the case of PBR, only the texture cube associated with the Zone is used.

My goals is just interact with the Skybox material (say, something like this):


For instance, in the “ForwardDepth” render path, it looks like the viewport is being sampled for a pass called “Refract”. I don’t know what that does, but it seems close-ish to what I’m after…

    <rendertarget name="depth" sizedivisor="1 1" format="lineardepth" />
    <command type="clear" color="1 1 1 1" depth="1.0" stencil="0" output="depth" />
    <command type="scenepass" pass="depth" output="depth" />
    <command type="clear" color="fog" depth="1.0" stencil="0" />
    <command type="scenepass" pass="base" vertexlights="true" metadata="base" />
    <command type="forwardlights" pass="light" />
    <command type="scenepass" pass="postopaque" />
    <command type="scenepass" pass="refract">
        <texture unit="environment" name="viewport" />
    <command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" />
    <command type="scenepass" pass="postalpha" sort="backtofront" />


Kind of getting the idea now…


So, rather than using some kind of screen space hack, I wrote a reflection probe component. This ties in beautifully with the existing PBR pipeline. Check it out:

Material workflow from Blender
PBR problems

Nice! Is there any slowdown it is hard to say from the video?


Nice! Is there any slowdown it is hard to say from the video?

I haven’t run the profile on this, but qualitatively, no noticeable performance hit. I’m using 1024 px^2 for each cube face, which might not be optimal on all platforms/hardware configs.

Also, I haven’t totally figured out the question of when to update the reflection probe. If nothing is changing, then it is overkill to update every from or even on a fixed update loop. Also, you might just want to have this in the editor and bake the probe to a texture on disk…For now, I’ve just implemented an Update() function that I have tied in to my specific use case.

I was thinking of doing a PR for this - would it be useful to anyone else?


Very nice
For less-shiny (or smaller) objects you wouldn’t need as high a resolution since it gets blurred anyway, but this would still make the objects fit really nice into the environment.
And I guess it would need some interpolation to work well on moving objects?


Too much fun: