October 4, 2021, 2:17pm
I found this project example for Texture render :
I created a new Layer in settings, which I applied in my Camera
After that, I copied scripts from the project sample, and on the property set the same string name as my layer
ApplyTexture script is on my UI element, which needs to display everything my camera is rendering
But I have 2 errors, and I can’t figure it out what’s the problem
Does anyway knows how can I fix this , on 2. error when i apply material , it’s not working again
What’s the exact code that is failing in your scripts, on those lines?
I’d say in both cases try and debug if everything executes and references the expected objects.
In the first case if
this.layerName is the expected one, and a pc.Layer reference is returned.
In the second case if the model is loaded (mesh instances are available) and references a material.
Your best friend here is the debugger, you can either set a breakpoint or use the
debugger; statement just before your code executes.
October 5, 2021, 8:39am
There is something in the console, but I don’t really understand any of this stuff
That’s a warning, that’s unrelated. On line 19 the layer name is correct.
Now try to debug the next line,
You can study a tutorial online on how to use the debugger, it’s quite important to resolve this kind of errors.
October 5, 2021, 10:11am
I figure it out, I didn’t set sublayer
The only problem left is, image is not showing anything
My script is on the sprite, set material instead of texture, but it’s still transparent
If anyone has time, I would really appreciate it if you take a look at this project
Sprite is under 2D Canvas “Main 3D Studio”
October 5, 2021, 10:31am
Instead of applying it to the material, it’s better to assign it to the texture of the element:
this.elementEntity.element.texture = colorBuffer;
Example of what looks like you are trying to do here:
October 7, 2021, 11:36am
I forked the project and doing some testing.
Is it possible to make the background transparent from the world, like an only cube to be rendered, not the blue background from the world camera
Test project: PlayCanvas 3D HTML5 Game Engine
October 7, 2021, 11:41am
Yes, you can. You have to make sure that the camera with the render target has a fully transparent clear colour.
October 7, 2021, 11:44am
Also need to make sure that the render texture has an alpha channel.