Need help Gabbing cube RTT

So I realized I am kind a dummy, and have been taking the slow route on generating my cubeTextures for my generator by doing it per-face.

Last night it dawned on me that reflection probes can grab a cube texture lickity split. I have been looking at:Babylon.js/reflectionProbe.ts at master · BabylonJS/Babylon.js · GitHub

I see it calls the rtt the cube texture, is that what it is can convert the rtt into a blob then with this process:

 var rtt = new BABYLON.RenderTargetTexture("GPUScreenShot", {
			}, scene, false, false, BABYLON.Constants.TEXTURETYPE_UNSIGNED_INT, false, BABYLON.Texture.NEAREST_SAMPLINGMODE, this.args.isCube);
        rtt.renderList = null
        rtt.samples = 1
        this.isDirty = true
        var self = this
        this.isDirty = false
        this._blob = null

        BABYLON.Tools.DumpFramebuffer(this.args.resolution, this.args.resolution, this.engine, 
				console.log('blob cube!', blob)	 //Do something to make a magic cubeTexture blob			
            let img = new Image()
            this.blob = blob
            let texture = dt
            var ctx = dt.getContext()
            img.onload = function(){
                ctx.drawImage(img, 0, 0)
            img.src = blob
        , 'image/png', 'none');

@sebavan do you have an idea on this?

You could also use texture.readPixels if you prefer the raw data instead ? is that what you are looking for ?

I have found myself with the makings of a GPU based cubeTexture editor which is pretty cool… I am hoping to extend some of its capabilities right now and then add “filters” and some more generators. The whole grabbing the probe thing might save me a bunch of compilation time because I do it incrementally per-face right now and that is kinda heavy on some of the generators (still takes only about 2-3 seconds to render 6x2048pxl images with a huge amount of cycles on the noise generators).

It would be really nice if I could just apply my shaders to a cube that is dedicated to a render probe that just dumps its contents to a cubeTexture upon request.

@sebavan so what you are saying is try rtt.readPixels? I think I was able to get the blob to come up with the DumpFramebuffer tool, but I am not too sure how to convert that to a cubeTexture now? Is this where RawCubeTexture comes into play?

Readpixels reads the data back from a probe to anative array the yes you could use a rawCubeTexture to create a new cube texture from modified rgba array values.

You can take a look at the environment texture tools where we are recreating cube textures from other cube textures by using a post process in between.

Please, link me to that beautiful bean footage!

Well as I started going down this road, I realised the reflection probe does not give me what I expect in output.

The probe is flipped it seems?
and it looks like I cant set the argument invertYAxis

This is kinda interesting, why would the objects traveling through the probe do this?
@sebavan maybe you can explain whats going on for me?

Because the faces colors probably have an issue: (no prob)

I guess their definition is not correct as it breaks my driver

Super odd!

I dropped all the face color stuff out, and it still does it. Then I dropped the emissiveColor and not the face colors and it still did it. Then I dropped both and it stopped. Odd, this does not seem like normal behavior.

Look at this: p.position.normalizeToNew().scale(Math.cos(time)*2.5+0.5)

if cos§ < -1/5 the scale becomes negative and the box will change side each frame giving a blinking feeling as they swap side.

1 Like

and then starts pulsing between negative and positive gotcha.

1 Like