Hello, I need to create deferred decal (or screen space decal) because I need projecting decal to complicated surface without stretching.
I already create box that following mesh’s face. but after, how to get collision(face?) area?
here’s playgound
https://www.babylonjs-playground.com/#2C8LVE#19
Please help ;(
Reference:
http://martindevans.me/game-development/2015/02/27/Drawing-Stuff-On-Other-Stuff-With-Deferred-Screenspace-Decals/
Hey @deadcat ,
While I’m not sure if this will help, you may be able to rig up something using the DynamicTexture and Image objects. You can find more on DynamicTextures here . I hope this helps!
Thanks for your reply!
but I want using decal because I will make decal seletable but dynamic texture is not
Thank you
Unfortunately deferred decals do not work with a forward rendered like babylon.js. It only works with deferred engines
Maybe you can have a look at how we build the decals to see if you can tweak it to adapt to your needs?
* * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
* * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
* @param name defines the name of the mesh
* @param sourceMesh defines the mesh where the decal must be applied
* @param options defines the options used to create the mesh
* @param scene defines the hosting scene
* @returns the decal mesh
* @see https://doc.babylonjs.com/how_to/decals
*/
public static CreateDecal(name: string, sourceMesh: AbstractMesh, options: { position?: Vector3, normal?: Vector3, size?: Vector3, angle?: number }): Mesh {
var indices = <IndicesArray>sourceMesh.getIndices();
var positions = sourceMesh.getVerticesData(VertexBuffer.PositionKind);
var normals = sourceMesh.getVerticesData(VertexBuffer.NormalKind);
var position = options.position || Vector3.Zero();
var normal = options.normal || Vector3.Up();
var size = options.size || Vector3.One();
var angle = options.angle || 0;
// Getting correct rotation
if (!normal) {
var target = new Vector3(0, 0, 1);
That is sad news I’ll check the source code thanks!