PBR texture splatting (up to 64 textures)

Hi, couldn’t find it in the doc, so forced to ask here. I have to make a fairly large terrain and am considering options. May I know if PBR texture splatting is supported in babylonjs ? Average textures used should be around 16 but I reckon it might go up to 64 max.

A link would be nice, thanks in advance.

This is not supported in the PBR at all, I guess you could use the terrain material Terrain - Babylon.js Documentation for this but it does not support as many textures.

Ah, ok. Good to know. I’ll look elsewhere then. Thanks for info, cheers !

um, stumbled upon this while browsing the src: PBRCustomMaterial. I should be able to write my own custom fragment and vertex shaders with PBR, right? Asking cos I think it should be possible to load a splatmap and texture atlases, compute the right textures via vertex.fx.

https://www.babylonjs-playground.com/#0GG6MR#27

Quick test, but yh…pbr custom material is working! Now, let’s see if I can get some pbr texture splatting to work.

2 Likes

https://www.babylonjs-playground.com/#0GG6MR#28

Super ugly proof of concept borrowing codes from terrainMaterial. Tried with albedo only. Note: Mixing colors is not the correct way for splatting textures. Super happy it works, now I can go make my own, rawr!

4 Likes

I want to inject custom codes for pbr custom material to read a roughness atlas map as a microsurfacetexture but I don’t see an easy way. What should I do?

Raise a PR for the fragment shader to have new #defines? or bite the bullet and rewrite the entire reflections calculations in CUSTOM_FRAGMENT_BEFORE_FOG?

new #define are fine to me

1 Like

PR raised. Local build and validation passed. But PR check keeps throwing lint error. I’m using notepadd++, is this an issue?

Run npm run build in your tools/gulp folder and it will fix the lining automatically :slight_smile:

Yes, it finally passed !

Congrats!! I’ll merge asap

1 Like

Yo @phaselock did you ever get texture atlas working … if so can I see your shader code for that… are you using fract???

yh, it works. erm, I don’t think I can share the codes. But yh, its using fract somewhere. Perhaps I can share bjs-side screenshots after its done.

Hope it helps.

I am trying to add support to the Unity Exporter For terrains… My Splatmap Shader gets the common GLSL EDGE SEAMS issue when using fract especally with a TEXTURE ATLAS…

I would love to see how your dealing with that :slight_smile:

I put up a SS here: Custommaterial and importmesh as I found a bug with pbrcustommaterial.

Its a very early prototype and the splatmap isn’t done yet as the terrain assignments are not yet complete. My use case is all square tiles hence the tiled look. I don’t see any obvious edge seams from my side. Using 1k splatmap, diffuse, normals, roughness and macro texture for testing purposes right now.

Hope it helps.

I’m interested in how you managed to fix the issue mentioned by @MackeyK24 as well.
I’ve been doing some experimenting for the past few days, as I needed some more juice for my terrain. I’m using an atlas for my textures, as well as an atlas for my splatmaps, giving me 12 out of 16 different texture tiles in this example: https://www.babylonjs-playground.com/#LIVRIY#37
I’m only using the RGB channels in the splat atlas, so only 3 texture tiles/splat tile. But it’s good enough for me :stuck_out_tongue:
Only real issue is the aliasing/edge issue, although I can live with that as long as I have those extra textures to play with.

1 Like

Hi, pls take a look at this: https://www.babylonjs-playground.com/#LIVRIY#38
comment and uncomment line 26/27 to see the difference.
Does this help?

1 Like

Thank you for your input. I’ve now been at it for 10 days straight!! without getting satisfying results. Having linear interpolation + atlassing + working mipmaps is just too damn hard :stuck_out_tongue:
My terrain requires loads of textures, so atlassing is a must, and at the same time, without mipmaps, or even decent mipmaps, it all looks terrible. My current stage of the terrain gives me a raging headache after 20 minutes, but it’s better than a blant and boring visual feel. I tried everything. Generating my own mipmaps(Using dds as it seems there might be a bug with ktx containers and mipmaps), all the samplingmodes, the 4-tap algo, half texel, repeated padding, various implementations and ported examples. I guess I’ll wait for Babylon to implement array textures or for someone else smarter than me to implement atlassing. I know a couple of guys are on top of it. It’s just a shame throwing away Webgl1 support, but damn :stuck_out_tongue:

Hi, sorry to hear that. Did the fix in the pg solve the edge seams? It looked well on my screen.

What still seems to be the problem ? Lemme know, thks !