Create erasable surface


#101

Okay, same line this time can’t read property precision of undefined


#102

Please fix it by yourself. You have to use precision field from graphicsDevice.


#103

Whoops, found that issue. Missed the line where I define graphics device and forgot to move it.


#104

Nice. Does it work now?


#105

Still not scratched if it’s supposed to be, and getting this until WebGl calls too many errors.
[.Offscreen-For-WebGL-0000012FC143BE90]GL ERROR :GL_INVALID_OPERATION : glBlitFramebufferCHROMIUM: src and dst formats differ for color


#106

Try to remove

renderTarget.copy(tempRender, true);

Still errors?


#107

Removing that fixed it.


#108

Try to copy by device.copyRenderTarget instead of that function.


#109

Actually, just removing true from the old function works to. I think the problem was that the color values were different between the two.


#110

Because without both params it does nothing.

image


#111

Okay, so just set to false then so it doesn’t copy those params.


#112

But… You need to copy color! That’s why you use it.


#113

Right, so what do you mean by device.copyRenderTarget, because that doesn’t seem to be a function.
I tried doing it as graphicsDevice.copyRenderTarget


#114

image

It definitely is.


#115

Trying that gives another massive loop of the same error. Debug for the editor says error loading scripts, and console says cannot read property _colorBuffer of undefined


#116

Then there is something wrong with your textures. Try to make their width and height equal?


#117

They are:

var opacity = new pc.Texture(graphicsDevice,
    {
        width: 64,
        height: 32,
        format: pc.PIXELFORMAT_R8_G8_B8_A8
    });
    var tempTexture = new pc.Texture(graphicsDevice,
    {
        width: 64,
        height: 32,
        format: pc.PIXELFORMAT_R8_G8_B8_A8
    });

#118

I meant

width: 64,
height: 64,

#119

Nope, no change there


#120

I don’t know why.

Probably your textures wasn’t initialized. So you have to do it by hands, but it’s not public API though.

Try to set filters. Check example of RenderTarget for that.