Optimize: Effect/Shader output cache?

thx sebavan, engine.alphaMode = 0 I think, what should I set this too? Lots of options

it is not on engine directly it is the options you are passing to the constructor the third parameter options has a property called alpha that should be true if you intend to composite your scene and the rest of the dom.

        let textureSize = { width: this._width, height: this._height };
        let textureOptions = {
            generateMipMaps: false,
            generateDepthBuffer: false,
            generateStencilBuffer: false,
            samplingMode: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,
            type: Constants.TEXTURETYPE_UNSIGNED_INT
        };

        this.texture = this._engine.createRenderTargetTexture(textureSize, textureOptions);

    this._engine.bindFramebuffer(this.texture);
    this._engine.clear(this.clearColor ? this.clearColor : this._scene.clearColor, true, false, false);

^ those are the statement’s I’m calling, the clearColor is (1,0,0,0) and actually clears as (1,0,0)

We would need to have a repro in the playground for this as I am not able to repro. Would it be possible for you to create a small repro ?

lol I hate GitHub, not sure how to easily make an example of this

In the playground ? https://playground.babylonjs.com/

Not sure how to create a texture for a material from an internaltexture object though, Babylon.js Playground

I set the color in that PG as red with alpha of 1 just to see if it would show up

This works as expected:
https://playground.babylonjs.com/#AEV28A#3

As you can see in Spector.js (first FBO is red no alpha second is full alpha):

I did not create the full material to focus only on the clear and Spector.js is enough to understand what is rendered.

Well that’s cool, spector.js … I’ll investigate further now that I can potentially find where things are going wrong

https://spector.babylonjs.com/ you can find the browser extensions from there.

Yeah I had bing’d it already and got it installed, thx for that tip :wink:

soooooo, All my frame buffers in spector show up correct, however my canvas is red, no transparency. even in the commands all the red clears are with alpha 0

sepector…
image

actual…
image

I’ll assume the texture is correct then since spector is displaying it correctly… and I’ll try to find somewhere else it could be going wrong.

it means the background of you canvas is red in your page

I wish, it’s set as black

you would really need to share a repro for this :frowning: cause if the alpha option is true the page background black and spector shows it as transparent I run out of ideas.

found the specific engine.clear() which is causing the issue, I’m almost at the absolute root cause

Seems I was inappropriately clearing the canvas frame buffer, still not sure why the clear color even though specified as (1,0,0,0) was not transparent though… it was changing the black to red on that clear call, I commented it out and it works fine as expected

1 Like

Progress update: render group bitmap caching is working great :smile: I’ll probably make a PR this week after a few more refinements to it. Each render group for the scene can be marked for caching or not, and each group can be updated independently at this moment.

I was thinking the cache will need to be tied to the camera, incase there are multiple camera’s per scene with their view displayed at the same time, and one camera might move and the other not. Also should be easy for me to add the caching to RenderTargetTextures render groups as well.

1 Like