GLSL shader: Interpolate between more than two textures

后端 未结 3 1293
傲寒
傲寒 2021-02-03 14:54

I\'ve implemented a heightmap in OpenGL. For now it is just a sine/cosine curved terrain. At the moment I am interpolating between the white \"ice\" and the darker \"stone\" te

3条回答
  •  长情又很酷
    2021-02-03 15:01

    No, according to the GLSL documentation for mix() there are only overloads for interpolation between two parameters.

    Would it be acceptable to you to just interpolate "ice" and "stone" then mix the result with the "grass" texture?

    vec4 ice_color   = texture2D(ice_layer_tex,   texcoord);
    vec4 stone_color = texture2D(stone_layer_tex, texcoord);
    vec4 grass_color = texture2D(grass_layer_tex, texcoord);
    
    vec4 tmp = mix(ice_color, stone_color, pct);
    vec4 final_color = mix(tmp, grass_color, pct);
    

提交回复
热议问题