Jump to content

Placing a non-repeatable secondary texture


Recommended Posts


I'm exploring picking options of babylon.js. Doc's example shows how to place the image (first plane) of shot on the second plane. However, if I shoot near the edge of the mesh - texture of the gun shot partly is on the air.

Simple example (with white color instead of shot texture): https://www.babylonjs-playground.com/#YHGBXI#2


This looks like air is damaged, what is impossible. So I am thinking about replacing additional plane with additional texture, which will be on the existing one. I've found a way to get picked face ID, coordinates of globally picked point, coordinates of picked point on the specific face/texture - lines 26-28. But I can't find a way to place a non-repeatable (and with image's original size) secondary texture at that point. By "non-repeatable" I mean to draw it only once on a mesh, in the specific place, not 100 times all around it. Is that possible? This way if I shoot near the edge of an object - I'll see only part of the damage image, what is correct.

Link to comment
Share on other sites

Hi K!  This surely started as "decal hell".  :) 

I'll float/wait, as deltakosh is in the thread with me (HI DK).

Decals along sharp edges/corners... has always been a rough area of town.  But that's not the topic.

I might reply more... soon.

Link to comment
Share on other sites

Oh, yeah, I was thinking that our picking demo http://playground.babylonjs.com/?11 was already using decals, and that kurhlaa removed them.  Duh.  Sorry. Wingnut dummy.

Also, border-of-boxes (picture frame) might hide shot textures that are "hanging in air". 

But yeah, decals might work!  Good idea.

Also, there is a complicated solve.... using dynamicTexture's context2d...


context.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh)

All that dx, dy, dw, dh is for destination.

i.e. Where to place SOME image... onto another image's canvas.  Then you use dynamicTexture.update(). 

I think this image-atop-image stuff was once called 'compositing', but that term might mean something different, these days. :)

I don't have any PG's that show this, but, some adventuresome forumer might try it.  :)  A PG search for 'drawImage' might produce results, too.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...