Babylon.js icon indicating copy to clipboard operation
Babylon.js copied to clipboard

New SpriteMap Materials

Open Pryme8 opened this issue 4 years ago • 18 comments

So constantly people are asking for shadow and special effect support for the sprite map.

I was thinking of working on some extensions of the CustomMaterial and the PBRCustomMaterial to accommodate this.

https://forum.babylonjs.com/t/sprite-maps-and-light/21167 shows a really rudimentary hacky proof of concept. The correct way would be to actually rebuild the SpriteMap class to use a CustomStandardMaterial extension and then make a secondary PBR version. That way backwards compatibility is not broken and the power of all our materials will be leveraged.

Figured making a request for this would be the best way to get the ball rolling and track the progress as I wont be able to focus on this unless I have free time.

  • [x] Create and upload to the public assets a normal map for the tileset
  • [x] Create SpriteMapMaterial class and interfaces
  • [ ] Redo the old SpiteMap to use the new Material
  • [ ] Create a PBR Variance
  • [ ] Create and upload to the public assets the pbr channel textures
  • [ ] Create a PBR demo

Pryme8 avatar Jun 03 '21 23:06 Pryme8

https://playground.babylonjs.com/#ECMXID#22

A little better proof of concept.

Pryme8 avatar Jun 05 '21 01:06 Pryme8

I can prolly wrap this up this week. Work is winding down a little.

Pryme8 avatar Jun 16 '21 05:06 Pryme8

Looks like I'll be able to press forward on this some this weekend. Will post updates when I do.

Pryme8 avatar Jun 19 '21 02:06 Pryme8

Working on this now.

Pryme8 avatar Jun 21 '21 16:06 Pryme8

@deltakosh I need to move #define CUSTOM_FRAGMENT_BEFORE_LIGHTS On the default.fragment.fx from line 229 to line 246, I don't see this causing any regressions or breaking backwards dependencies, but then again it might in some cases.

Would this be ok, or should I define a different custom replace string? Just kind of seems odd that its placed before the specular stuff because the way its setup now you have no way to access that part of the customMaterial.

Pryme8 avatar Jun 21 '21 16:06 Pryme8

I think it makes sense.

sebavan avatar Jun 21 '21 17:06 sebavan

I agree too

deltakosh avatar Jun 21 '21 17:06 deltakosh

Ok thank you!

Pryme8 avatar Jun 21 '21 17:06 Pryme8

That will potentially break code if you move the define...

Currently, people can change uvOffset or vSpecularUV at the location of this define and it will be taken into account in the specular block as it is coming after. If you move the define after the block, that won't work anymore.

I think you should better add a new define instead.

Popov72 avatar Jun 21 '21 18:06 Popov72

Which ever way y'all want, just let me know.

Pryme8 avatar Jun 21 '21 18:06 Pryme8

Yeah after giving it more thoughts, I agree with @Popov72. Let's play it safe and secure

deltakosh avatar Jun 21 '21 18:06 deltakosh

Yes, that's true the change can be made earlier...

I think that's ok to move the define, you should just drop a line in the Breaking changes section about that (I don't think a lot of people have updated uvOffset or vSpecularUV here anyway).

Popov72 avatar Jun 21 '21 18:06 Popov72

Arf!

@deltakosh is the boss so do as he suggested :)

Popov72 avatar Jun 21 '21 18:06 Popov72

Haha, I deleted my comment because I read it and thought I was dumb... then realized it was not.

Ill, add the new define!

Pryme8 avatar Jun 21 '21 18:06 Pryme8

I have this running really well on my local, I just need to redo the SpriteMap class to use the new material now and the standard part of this is done.

It will prolly be a while till I can do the PBR version as work is getting pretty loaded at this point.

Pryme8 avatar Jun 28 '21 17:06 Pryme8

Hi @Pryme8 - Are you still planning to work on it?

thomlucc avatar Jan 11 '22 16:01 thomlucc

https://playground.babylonjs.com/#ECMXID#22

A little better proof of concept.

Really loved that, even more playing with specular, diffuse and intensity of different lights. The possibilities for this are many...

Any specific repo / branch?

gomes042 avatar Aug 09 '22 10:08 gomes042

@Pryme8 - will you have time to do it? Thanks!

thomlucc avatar Oct 27 '22 21:10 thomlucc

I will need to get back to this at some point. Sorry it just kind of fell between the cracks.

Pryme8 avatar Aug 11 '23 16:08 Pryme8

Should we close it ? And we can reopen if needed

deltakosh avatar Jan 09 '24 19:01 deltakosh

Yeah Id close this for now. I have the prototype of it done but just don't really have the time to look at it this second.

Pryme8 avatar Jan 10 '24 18:01 Pryme8