Hi there,

This is some code to blend textures based on a splatmap. It's perfect for terrains.

` shader_type spatial;

uniform float grassres = 30; uniform float rockres = 30; uniform float dirtres = 30; uniform float normalres = 10; uniform sampler2D grass; uniform sampler2D rock; uniform sampler2D dirt; uniform sampler2D splatmap; uniform sampler2D normalmap;

void fragment(){ float grassval = texture(splatmap, UV).g; float rockval = texture(splatmap, UV).b; float dirtval = texture(splatmap, UV).r; vec3 grasstex = texture(grass, UVgrassres).rgb grassval; vec3 rocktex = texture(rock, UVrockres).rgb rockval; vec3 dirttex = texture(dirt, UVdirtres).rgb dirtval; vec3 result = grasstex + rocktex + dirttex;
ALBEDO = result;

vec3 normal = texture(normalmap, UV*normalres).rgb ; NORMAL = normal;

METALLIC = texture(normalmap, UVnormalres).b ; ROUGHNESS = texture(normalmap, UVnormalres).r; }

`

My level is made of objects like walls and platforms, each will have multiple textures blended together. With the above shader it's too slow because i need create a splat map per object. Instead vertex color should be quicker. How can i get vertex color and pass it to fragment to work on pixels ?

You didn't really need to start a new thread for this, you know? :D

You might even want to start a project thread instead. You can just keep asking questions there and feel free to mention users with @*username* if you have a question for a specific user. For an example by typing @Megalomaniak I get a notification of having been mentioned in this post.

So the splatting shader is made with a terrain(cave-less) like grid plane in mind. Looking at the screenshot from the water thread you would actually be best off instead creating a bunch of cube 'voxels' as essentially prefabs in your choice of 3d DCC and arranging those into your level configurations there. Joining them as one object or a few batches before export so as to minimize the amount of draw calls in the final game.

@Megalomaniak said: You didn't really need to start a new thread for this, you know? :D

You might even want to start a project thread instead. You can just keep asking questions there and feel free to mention users with @*username* if you have a question for a specific user. For an example by typing @Megalomaniak I get a notification of having been mentioned in this post.

So the splatting shader is made with a terrain(cave-less) like grid plane in mind. Looking at the screenshot from the water thread you would actually be best off instead creating a bunch of cube 'voxels' as essentially prefabs in your choice of 3d DCC and arranging those into your level configurations there. Joining them as one object or a few batches before export so as to minimize the amount of draw calls in the final game.

Yeah, i will make less threads.

The level i'm making is not for the 2.5D platformer, it's made of floating rock islands with different shapes and sizes. I need to blend many textures for each island, this can be done using this shader, but this means a new splat map texture per island model. While vertex color is stored in the model data and i could use it to blend textures. Is there some Godot shader example using vertex color ?

5 years later