Water Blocks 2D shaders : Separation between two blocks

Adri23240Adri23240 Posts: 3Unconfirmed Member

I want to create a minecraft like game and use water block inside the game.
A water block is a tile with a water shader but when a put the block of water beside, i have a discontinuity of the shader.

How can I resolve this probleme ? Thank you
PS : Excuse me for my English, I am not very good :s


  • MegalomaniakMegalomaniak Posts: 2,603Admin

    It's a custom shader? Can we see the code? I'm guessing you have a bump map of some kind for distortion to emulate the refraction and it's mapped over UV's instead of global coordinates.

    You can enable the World Triplanar checkbox on a regular material and then convert it to a shader to get a global/axis aligned mapping for textures. That should help solve it.

    Also your post got stuck in the moderation queue since you haven't confirmed your account via email yet. If you can't find the email with the confirmation link in your inbox then make sure to also check your spam filter/folder.

  • Adri23240Adri23240 Posts: 3Unconfirmed Member

    Yes it's a custom shader from Gonkee on youtube.
    The code is : https://github.com/Gonkee/Gonkees-Shaders/blob/master/water.shader
    I change a little bit the fragment section:
    void fragment(){

    vec2 noisecoord1 = UV * sprite_scale * scale_x;
    vec2 noisecoord2 = UV * sprite_scale * scale_x + 4.0;
    vec2 motion1 = vec2(TIME * 0.3, TIME * -0.4);
    vec2 motion2 = vec2(TIME * 0.1, TIME * 0.5);
    vec2 distort1 = vec2(noise(noisecoord1 + motion1), noise(noisecoord2 + motion1)) - vec2(0.5);
    vec2 distort2 = vec2(noise(noisecoord1 + motion2), noise(noisecoord2 + motion2)) - vec2(0.5);
    vec2 distort_sum = (distort1 + distort2) / 60.0;
    vec4 color = textureLod(SCREEN_TEXTURE, SCREEN_UV + distort_sum, 0.0);
    color = mix(color, blue_tint, 0.3);
    color.rgb = mix(vec3(0.5), color.rgb, 1.4);
    color = color * texture(mask_texture, UV).a;
    COLOR = color;

    My game is a 2D game, so how to enable World Triplanar on a 2D material ?
    Thank you

  • TwistedTwiglegTwistedTwigleg Posts: 2,618Admin

    I’d try replacing the parts with UV in the shader to SCREEN_UV and see what happens. That should, hopefully, make the shader seamless.

    My game is a 2D game, so how to enable World Triplanar on a 2D material ?

    World-Triplanar is only a setting for SpatialMaterials (3D). For 2D, I believe there isn’t any automatic triplanar setting.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file