I test everything but i’m unable to fix it. The blocks has specific properties like specular, ssr. But when i was implementing it i got this error, the background is water and has its own rendering with working specular and ssr.
http://puu.sh/lPS9S/b8c220076f.png
.
I am using Deferred Shading/Lighting, i tested if the error is in the specular/ssr pass but its ok, so its related to the blocks vertex/fragment shader.
Vertex
#version 330 core
in vec3 position;
in vec2 textureCoords;
in vec3 normal;
in vec4 data;//This holds the data about the block(id and bright)
out vec2 pass_textureCoords;
out vec3 surfaceNormal;
out vec4 pass_position;
out vec4 pass_Data;
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform vec3 cameraPos;
void main() {
vec3 pos = position - cameraPos;
vec4 worldPosition = vec4(pos, 1.0);
vec4 positionRelativeToCam = viewMatrix * worldPosition;
gl_Position = projectionMatrix * positionRelativeToCam;
pass_textureCoords = textureCoords;
pass_position = vec4(position, 1.0);
surfaceNormal = normal;
pass_Data = data;
}
Fragment
#version 330 core
in vec2 pass_textureCoords;
in vec3 surfaceNormal;
in vec4 pass_position;
in vec4 pass_Data;
out vec4 [5] out_Color;
uniform sampler2D texture0;
void main(void) {
vec4 data = pass_Data;
float id = data.x;
float bright = data.y;
vec4 textureColour = texture(texture0, pass_textureCoords);
if(textureColour.a < 0.5)
discard;
out_Color[0] = textureColour;
out_Color[1] = vec4(pass_position.xyz,0);
out_Color[2] = vec4(surfaceNormal.xyz,0);
out_Color[3] = vec4(0.0, 0.0, 0.0, 0.0);
out_Color[4] = vec4(0.0, 0.0, 0.0, bright);
if(id == 13 || id == 8){//check if the block needs ssr and add it to the specular/ssr pass
out_Color[3].r = 1.0;
}
}