Dynamic Cubemaps / Reflection Probes / Render To Texture in 2020

This is not a solution, but it might help. In Playcanvas cubemaps that are downloaded are x-axes flipped compared to those that are realtime rendered. At the moment we have flag on the texture (cubemap). This is automatically set when you render to texture using RenderTarget, but I guess not when we reproject cubemap to another cubemap. So for now, for your 6 or so cubemaps you generate, try to set this on them:

cubemapTexture._isRenderTarget = true;

I’m not quite sure where in the code the texture could actually be accessed, seeing that there are 6 renderTargets created in a loop and then immediately the texture is rendered to the cubeMap, which is the only pc.Texture in the code.

    // set up rendering for all 6 faces
    for (var i = 0; i < 6; i++) {

        // render target, connected to cubemap texture face
        var renderTarget = new pc.RenderTarget(this.app.graphicsDevice, this.cubeMap, {
            depth: this.depth,
            face: i

        // create a child entity with the camera for this face
        var e = new pc.Entity("CubeMapCamera_" + i);
        e.addComponent('camera', {
            aspectRatio: 1,
            fov: 90,

            // cubemap will render all layers as setup on Entity's camera
            layers: camera.layers,

            // priority
            priority: camera.priority,

            // copy other camera properties
            clearColor: camera.clearColor,
            clearColorBuffer: camera.clearColorBuffer,
            clearDepthBuffer: camera.clearDepthBuffer,
            clearStencilBuffer: camera.clearStencilBuffer,
            farClip: camera.farClip,
            nearClip: camera.nearClip,
            frustumCulling: camera.frustumCulling,

            // this camera renders into texture target
            renderTarget: renderTarget
        // add the camera as a child entity

        // set up its rotation

I’ve tried it with renderTarget._isRenderTarget = true, I tried setting the cubeMap Texture to _isRenderTarget = true and I tried setting it in the prefilter function, to no avail.
Is there another method to x-flip rendered cubemaps?

those cubemaps created for the reprojection should have that flag set, so the code you based on this creates those textures

I tried setting the flag like you described but it didn’t change anything. Upon further inspection, I noticed that the flag had already be set to true by default, even without me setting it:

how about changing the flag to false on those?
if that doesnt work I’m not sure what the problem is, but as mentioned, it’s on my list to work on this and create some simple API to use this in a way you’re trying to.

I tried that and this is the result:

Guess I’ll be patient, then, and wait for the API rework. Thanks anyways for your time

1 Like

@twe We have identified a bug in the Cubemap box projection from this thread: Cubemaps / Box projection is not working property

A fix is currently in the works which may help your issue

1 Like

The fix has been deployed:

Unfortunately, the fix didn’t solve my issue.
Anyways, thank you for notifying me :wink:


how do i use the that cubemap? it seems not working if i call app.scene.setSkybox(). and if i set it to a material. it just ignore the glossiness value. I tried using pc.prefilterCubemap(options); and get a new texture singleFilteredFixed from options. but it doesn’t help either

see the example here with the source code:

to use it on the material, you need this:

        // use cubemap which is generated by cubemapRenderer instead of global skybox cubemap
        shinyMat.useSkybox = false;
        shinyMat.cubeMap = shinyBall.script.cubemapRenderer.cubeMap;

regarding the prefiiltering of the skydome, see the post above regarding how do viewer does it. It’s still on our list to make a lot simpler, but unfortunately it has not been done yet.

1 Like

A new example is here:

This needs yet unreleased engine, but that should be coming out shortly as well.


Hi, sorry for necroing this post up. I’m super new here, and yes, I came from Unity. Do PlayCanvas has what equivalent of a baked reflection probe now in 2022?

It’s look like solutions presented in this topic (which are already available in the engine) is all runtime based. You have to run the app and have a script grab the continuously(?) rendered cubemap and put it in each reflective material. AKA realtime reflection probe (plus extra steps).

What about the baked side. Can I have the cubemaprenderer thing be part of a lightmap mapper process? Maybe an entity that I put in the scene from editor and it create a cubemap and put it to assets as an image file?

Having -1 knowledge on javascript is also isn’t helping me much…

Hi and welcome!

We have a feature request to do this, but have not got to doing it yet unfortunately: https://github.com/playcanvas/engine/issues/2485

For now, the runtime reflection it is. You can update it during the first frame, and use it from then on as a static one, no need to update it each frame, unless you want dynamic elements captured.

We also have this related ticket: https://github.com/playcanvas/engine/issues/2484

1 Like

Thanks for the information! You save me with the related ticket there, I think I will be asking that question in my mind next once I figure out the question I just asked you. Hope you add these 2 features soon.

1 Like