Jump to content

Is it possible to apply an emissiveTexture to a multi material?


bentwonk
 Share

Recommended Posts

I have been playing with the worldmonger demo, and want to uses an emissive texture to overlay a grid upon the ground. I can do this with simple ground materials, but not with the more complex multi  material, is it possible to add an emmessive texture to a multi material such as the one used in Worldmonger?

Link to comment
Share on other sites

Hi @bentwonk.  The MultiMaterial class is small and has no .emissiveTexture property.  You CAN, though, use the .emissiveTexture on each/any of the subMaterials... like this:

http://www.babylonjs-playground.com/#1XBLWB#180

(lines 39 and 45)

The Babylon decal feature has been "tried" as an on-ground (and terrain contour-following) "reticle" or target circle, but it had some problems on extremely bumpy grounds.  Also, our decal system is reasonably complicated and cannot be easily moved.  It is better... if re-created in the new place, and not "dragged" or animated across bumpy terrain.

There's another idea/method for putting BLACK grids on ANY section of heightMap, multi-material'd or not - with shadows/shadowGenerators and a spotlight (Our shadows are NOW available with ESM soft-edges and self-shadowing - see recent forum announcement).   (yay!)

Take a look at this playground, if you would.  http://playground.babylonjs.com/#1Z89KY#10

See how the images are only casting shadows... for the non-transparent parts of the image?  This means you could make a transparent-background grid image... and shine a spotlight through it (like the playground), but this light would shine straight down onto your ground... and would be easily position-able and size-able.  You would have a grid made of shadow, if everything goes correctly. 

I think it is limited to black... maybe.  It may have a circular outer ring/border... because spotlights are round.  Could THAT type of grid... work for your project?

With this type of grid, the grid is drawn "over" (atop) all non-terrain mesh, too (if mesh.receiveShadows = true).  It is a light from above, so it crosses EVERYTHING, if wanted.  :)

As far as I know, we have not had great success at sliding-around an image atop a bumpy heightMap.  (having it "terrain follow"... stretching nicely across mountain peaks and through deep valleys). 

A more advanced method... might be to create a second smaller heightMap, and it copies the Y height of each heightMap vertex... from the terrain below.  In other words, as you move-around this smaller "tile" of heightMap, it constantly re-transforms its vertices, matching the terrain contour beneath it.  Then ITS single diffuseTexture or emissiveTexture... could be a transparent-background grid image.

A constantly-transformed grid of "lines" (using Babylon LinesMesh class)... might be able to do a terrain-following grid in the same way, always setting its line "points"... to match the height of the verts beneath.  BUT... our linesMesh produces color-settable thin lines, with no thickness setting, so your grid might look a bit "wirey".  :)

Just some ideas.  Maybe others have more.  Hope this helps.  Issue still open... fellow forum folk.  Ideas welcome.  :)

Link to comment
Share on other sites

Yeah, but I only assembled it from great tools and nice pics... done by others.  It has a strange "mood-feel", eh? 

Adam and Sebavan contributed, too.  Both of them fixed my forgotten .hasAlpha in lines 64 and 72.  :o

I wish I could draw 2d graphics that nice.  I'd be somebody.  :)

But really, it's BJS that makes it all easy.  YOU also contributed, artistically, @Deltakosh.  You answered a forum question:  "How do I put a different image on back side?" ... by suggesting a second plane.  That's when I added the back-side plane to it. 

So, it was a colossal team effort, which was a breeze for me.  Most important for me... is that this PG has helped 2 forum friends, so far, and might do many more.  Yay!  :)  The playground app is the best learning tool EVER, I think.

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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