This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Blending textures

MagicLordMagicLord Posts: 578Unconfirmed
edited January 2018 in 3D

Hi there,

My terrain got an rgb map to mix different textures, i can i use it with Godot 3 ?
Someone made a video about it
https://youtube.com/watch?v=RLAG4RbT-5U

Best Answer

Answers

  • MegalomaniakMegalomaniak Posts: 2,580Admin
    edited January 2018 Accepted Answer

    Sure, splatmapping is an ancient method. You will have to write your own shader to handle this however it is not difficult.
    https://www.gamedev.net/forums/topic/378448-terrain-texture-splatiing-in-ogl/

    edit:
    On the video you linked someone in the comments is already offering a godot 3.0 PoC shader. ;)

  • MagicLordMagicLord Posts: 578Unconfirmed
    edited May 2018

    @Megalomaniak said:
    Sure, splatmapping is an ancient method. You will have to write your own shader to handle this however it is not difficult.
    https://www.gamedev.net/forums/topic/378448-terrain-texture-splatiing-in-ogl/

    edit:
    On the video you linked someone in the comments is already offering a godot 3.0 PoC shader. ;)

    Thank you.

    I added a global normal map and roughness values.

    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, UV*grassres).rgb * grassval; 
    vec3 rocktex = texture(rock, UV*rockres).rgb * rockval; 
    vec3 dirttex = texture(dirt, UV*dirtres).rgb * dirtval; 
    vec3 result = grasstex + rocktex + dirttex;  
    ALBEDO = result; 
    
    vec3 normal = texture(normalmap, UV*normalres).rgb ;
    NORMAL = normal;
    
    METALLIC = texture(normalmap, UV*normalres).b ; 
    ROUGHNESS = texture(normalmap, UV*normalres).r;
    }
    

    Someone made a height blending shader
    https://kinwailo.wordpress.com/2017/05/19/godot-terrain-shader/

  • MegalomaniakMegalomaniak Posts: 2,580Admin

    The way you want to handle the normal, metallic and roughness result should be the same as for the albedo. Right now you are giving each splat a unique albedo however the normal, metallic and roughness are the same values for all splats.

  • emo10001emo10001 Posts: 152Member

    This is super helpful. Ancient method or not, it's exactly what I wanted/needed to do :smile:

    -emo

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.