Few question about the SpriteMap

Hi there,

I was testing babylon 4.1 new features and I really like the job done on the SpriteMap (@Pryme8 :+1:)
It’s a really nice evolution and improvement of the SpriteManager. It’s simple and the performance it can deliver are really cool and I managed to get few interesting 2D prototype running with it.

But the are few things I would like to do to continue and get better 2D graphics, and I dont really know how to do that in an efficient way without re-implementing everything manually:

  • Apparently the alpha mode is working but not the alpha parameter above, quite confusing as I was trying to do some fade-in/fade-out
    image
  • I was looking to have 2D sprite normal map and have a basic 2d lights over my maps (Sprite dlight, sprite illuminator, unity 2d light, …)
  • I was looking to have some effect on some layers or spriteMap (example: water deformation on water sprites, heat deformation in hot area or more advanced, a slight ground reflection in humid area)
    (most of the other effect I think about are doable with particles and sprites only)

So:

  • Is there a way to easily reuse existing feature like the spritemap and just overwrite the fragment shader used (or even better change it directly in the node material editor), like adding a 2nd pass ?
  • Or if it’s not possible directly, is there a way to export the texture or a spritemap and apply it on a mesh with a dedicated shader ?

I believe all that is possible. I have like 20 things to do today (on my day off mind you).

Quick question, with the alpha stuff are you having any sorting issues cause that was something I noticed might be a problem later and never really had a chance to test it.

Normal maps was planned, but @Deltakosh told me to hold off on that an let users do it with their own shaders I believe (if I remember that conversation correct). So it support might be hindering on you reusing the elements in the SpriteMap as a custom shader? I could look at adding the support here for lights from the Standard material and have it react to the same light model as everything else if you have a normal map.

I believe you could work out some nifty postpass effects for the water and stuff, maybe if I get some time on one of my days off here Ill try to figure that out, it would be a very cool addition.

No idea about the NME aspect ask @Evgeni_Popov hes a wizard.

AND FINALLY WOOP THANK YOU! I was wondering if anyone was gonna use it, I thought it was a pretty niffy system as no other way could you draw billions of animated spites all with their own timings with like 1 draw call… <3

Is there a way to easily reuse existing feature like the spritemap and just overwrite the fragment shader 3 used (or even better change it directly in the node material editor), like adding a 2nd pass ?

I would have to add an entry point to that, but totally could. Let me get some input about the normal maps and then Ill do a PR for you.

I just realized technically it does not need to be a ShaderMaterial, and I could add an argument to have it return as a procedural textures on a standardMaterial.

When I made this system I had no clue about procedural textures and if I had made this today would have gone that route. Which would give you all the lighting support a d alpha support you would want, plus you could pass the textures to a secondary process and do any effects.

Maybe that should be what PR I do? Hm… or have it return the standardMaterial with all the correct procedural channels bound already for you? Ummm johnny 5 needs input.

Im trying to figure out what’s the best way to get you all those features with the least amount of code change and I gotta keep backwards compatibly intact. I was not ready to think about this today but I’ll try to sneak something in.

Wow such a reply, so quickly on a sunday :+1:
No worries, I’m not in hurry, so far I’m just doing some personal testing for potential future project. I already had 2-3 projects in the past I had to fallback on pixi.js or phaser because the spriteManager was a bit too limited for 2D.
So I’m interested to see how far can BJS go nowadays.

AND FINALLY WOOP THANK YOU! I was wondering if anyone was gonna use it

That was kinda my feeling when using it, I mostly based my tests on the doc and the sample, but I was surprise to not find more about this cool feature in the forum or in the playgrounds

I think most people dont know about this feature or they did not realize what it’s possible to do with it.

Quick question, with the alpha stuff are you having any sorting issues cause that was something I noticed might be a problem later and never really had a chance to test it.

No sorting issues, I just report it because I’m used to play with this alpha property on standard materials, and I was just a bit surprise to realize it was not working here (and double surprised when I realized it was exposed in the editor anyway) :smiley:

Normal maps was planned

Ha cool to know, I’m not the only one. Sometimes, I wonder if I’m not not a weirdo, looking for this kind of feature in BJS. The 2D area still feel kinda young sometimes :stuck_out_tongue:

if I had made this today would have gone that route. Which would give you all the lighting support a d alpha support you would want, plus you could pass the textures to a secondary process and do any effects.

Wow indeed sounds like a super nice proposal, I need to look at those procedural textures too. I already used few of them, but I never really check how they were working underneath.
Being able to use the standard material sound indeed really powerful and would make it really modular.

No, the NME can’t be used to edit shaders for sprite / spritemap.

I don’t know if it’s planned or not, but for the time being the existing javascript code does not allow to overwrite the default fragment code.

I’ve added the updates to make this work as a standard material to my list of stuff to do this week. This will add all the functionality you seek.

Ill let you know when its done. @Kef

Agree this is not planned. Do we think there is a need? Why not simply using meshes with billboarding and regular nme?

2 Likes

Hi David,

Sorry, I realize maybe our discussion was a bit too cryptic with prime, so here is an equivalent of this kind of feature in unity just to illustrate what we are talking about (normal & light for tilemap)

Agree this is not planned, Do we think there is a need

I’m not gonna argue with that, I have no idea what’s you definition of needed or scheduled :zipper_mouth_face:
But sorry for causing any headache :smiley:

Why not simply using meshes with billboarding and regular nme?

Billboard is not really the point here, for tilemap 2d usage most people work with orthogonal camera (to keep the pixel perfect aspect).

The point is really how to reuse the spritemap result which is really good and performant, and make it compatible with other area of BJS like NME, post process, … basically how to connect existing pieces of work together.

And yes obviously everything can be redone with meshes and NME, it just require to reimplement the spritemap and duplicate existing feature :smile:

lol yeah I got it now. Well if @Pryme8 or anyone else want to give a try I would be glad to merge the PR !

I can prolly do a PR to fix all this by the end of the week.

1 Like

I have not forgot about you and am trying to get to these updates. I just have to get to a stopping point with my real work.

2 Likes