Hello.
I wrote a code which generating heightmap and i use four textures for texturing. Almost all working fine except one blending,
one texture on the edge is white or black. I know what it means value is bigger than 1 or equal 0 but i’m almost sure (to 99 percent) i do not pass this values.
My shaders code:
vec3 tx = vec3(0.0, 0.0, 0.0);
tx += texture2D(ground_grass, pass_TextureCoord).rgb * colors.r;
tx += texture2D(ground_rock, pass_TextureCoord).rgb * colors.g;
tx += texture2D(ground_snow, pass_TextureCoord).rgb * colors.b;
tx += texture2D(ground_dirt, pass_TextureCoord).rgb * colors.a;
gl_FragColor = vec4(tx, 1.0);
The problem appearing only for texture which is multiplied by “colors.a” the r, g, b always working fine. I changed textures between each other with different borders and the problem is only with “a” value.
The value of the buffer looks something like this
0.6f, 0.0f, 0.0f, 0.0f,
0.0f, 0.6f, 0.0f, 0.0f,
...
and my binding buffer looks like
vbocId = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbocId);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, colorsBuffer,GL15.GL_STATIC_DRAW);
GL20.glVertexAttribPointer(1, 4, GL11.GL_FLOAT, false, 0, 4);
So i have four values for one vertex which set textures color. I checked array with colors and i never have situation where one sequence have only 0 value or two value (or more) with 0.6f.
So what’s going on with this value “a” in vec4, do any of you had similar problem.
Whether it is possible to shaders changed in some way this “a” value?
I also did a little test I created four buffers which hold values only for one texture. Values are always kept in one position and all works fine.
vec3 tx = vec3(0.0, 0.0, 0.0);
tx += texture2D(ground_dirt, pass_TextureCoord).rgb * colors1.r;
tx += texture2D(ground_grass, pass_TextureCoord).rgb * colors2.r;
tx += texture2D(ground_rock, pass_TextureCoord).rgb * colors3.r;
tx += texture2D(ground_snow, pass_TextureCoord).rgb * colors4.r;
gl_FragColor = vec4(tx, 1.0);
}
Of course the whole mechanism remained unchanged so surely all is set correctly, but it is a significant loss of memory.