How to project a texture on a surface/terrain?

Hi all,
I’d like to project a texture to a surface/terrain and I wonder that is there any easy way to do in PlayCanvas or should I write a custom shader for it?

For example;


Hi @Ertugrul_Cetin! You can use a spotlight with cookie for this.

https://developer.playcanvas.com/en/tutorials/light-cookies/

3 Likes

Wow that was fast, thank you so much!

1 Like

@Albertos is there any solution without light cookie? because when I use light cookie and the ambient light is too intense the image is not seen clearly that I projected also it receives shadows.

You can probably use a material with a texture on a plane entity. Then you can use a raycast to set the position of the entity based, on the result.point of the raycast. You can use the normals of the raycast result to set a correct rotation. You need also make sure that you render the entity on top of the result.entity (not sure how to achieve this part).

This has a link to project with a decal implementation … perhaps you could use that, if your image needs to “follow” the terrain.

If your terrain is flat, or you can move the image higher to avoid it, you could do what @Albertos suggested.

2 Likes

You may also want to look into this thread that shows how to do decals on a mesh: Spray/Decal Script