Can we apply Triplanar Mapping to the Terrain Material?

Hello,

Maybe a dumb question, but would there be a way to extend the current TerrainMaterial shader code with some sort of Triplanar Mapping (maybe using a Material Plugin)?

I see we already got the TriplanarMaterial (Tri-Planar Mapping Material | Babylon.js Documentation) but that doesn’t support the same texture mapping as the TerrainMaterial does.

An example with stretched textures using the TerrainMaterial:

Thanks in advance.

Hello! That should be possible, yes. :smiley:

Hello @Andi just checking in if you need any more help with this?

Hi @carolhmj, thanks for checking in. Honestly, I’m a bit lost on the subject, somehow shader code really flies over my head :smiley:

I haven’t investigated it further, but as far as I could tell it would be quite hard to apply both mix + triplanar because the triplanar texture has to be projected from multiple directions, while the mix only works if projected from the top…

I’ll be banging my head against this one in the future I’m sure.

Actually, I’ve found a really nice tutorial series I wanted to follow up on that explores creating mix + triplanar + other types of modalities here: 3D World Generation: #5 (Texturing): Triplanar Mapping/Infinite Splatting/Blending/Bombing - YouTube

And the code is open sourced: GitHub - simondevyoutube/ProceduralTerrain_Part5

Most likely I’ll try to replicate Simon’s shader in there.

Shader code is definitely a tricky subject, but we’ll be here to help! :smiling_face_with_three_hearts: I’ve briefly seen Simon’s videos before and they seem super good! For shader code, I also really like The Book of Shaders and The Art of Code - YouTube channel, they’ve helped me a lot :slight_smile: And also SpectorJS - Explore and Troubleshoot your WebGL scenes with ease (babylonjs.com) is REALLY useful to debug!

1 Like

Thank you for the suggestions, Simon has a Shader series as well I’m going to look into it next. Somehow I think I need to make peace (aka. learn) the basic Maths involved in Shaders, and actually, just start doing it.

I love how easy is to roll your own shader code in Babylon, huge help from the engine.

1 Like