Updated shaders
Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
@@ -52,16 +52,15 @@ layout(location = 0) out vec4 outColor;
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
Material material = MaterialBuffers.materials[ PushConstants.materialBufferIndex ];
|
Material material = MaterialBuffers.materials[ PushConstants.materialBufferIndex ];
|
||||||
mat3 normalMatrix = transpose(inverse(mat3(PushConstants.render_matrix)));
|
|
||||||
|
|
||||||
vec3 out_normal;
|
vec3 out_normal;
|
||||||
// if(material.normalTexture == 0) {
|
if(material.normalTexture == 0) {
|
||||||
// out_normal = normalize(normalMatrix * TBN[2].xyz);
|
out_normal = TBN[2].xyz;
|
||||||
// } else {
|
} else {
|
||||||
vec3 sampled_normal = texture(texSampler[material.normalTexture], uv).rgb;
|
vec3 sampled_normal = texture(texSampler[material.normalTexture], uv).rgb;
|
||||||
sampled_normal = 2.0 * sampled_normal - vec3(1.0);
|
sampled_normal = 2.0 * sampled_normal - vec3(1.0);
|
||||||
out_normal = normalize(normalMatrix * TBN * sampled_normal);
|
out_normal = normalize(TBN * sampled_normal);
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
float intensity = dot(out_normal, normalize(directional_light)) + 0.2;
|
float intensity = dot(out_normal, normalize(directional_light)) + 0.2;
|
||||||
@@ -73,8 +72,8 @@ void main() {
|
|||||||
inColor = texture(texSampler[material.albedoTexture], uv).xyz;
|
inColor = texture(texSampler[material.albedoTexture], uv).xyz;
|
||||||
}
|
}
|
||||||
|
|
||||||
// outColor = vec4(inColor * intensity, 1.0);
|
outColor = vec4(inColor * intensity, 1.0);
|
||||||
// outColor = vec4(inColor, 1.0);
|
// outColor = vec4(inColor, 1.0);
|
||||||
// outColor = vec4(vec3(intensity), 1.0);
|
// outColor = vec4(vec3(intensity), 1.0);
|
||||||
outColor = vec4(out_normal, 1.0);
|
// outColor = vec4(out_normal, 1.0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ void main()
|
|||||||
|
|
||||||
mat3 model = transpose(inverse(mat3(PushConstants.render_matrix)));
|
mat3 model = transpose(inverse(mat3(PushConstants.render_matrix)));
|
||||||
|
|
||||||
vec3 T = normalize(vec3(vertex.tangent));
|
vec3 T = normalize(model * vec3(vertex.tangent));
|
||||||
vec3 N = normalize(vec3(vertex.normal));
|
vec3 N = normalize(model * vec3(vertex.normal));
|
||||||
vec3 B = normalize(vec3(vertex.bitangent));
|
vec3 B = normalize(model * vec3(vertex.bitangent));
|
||||||
/* T = normalize(T - dot(T, N) * N); // Re-orthoganize T with respect to N */
|
/* T = normalize(T - dot(T, N) * N); // Re-orthoganize T with respect to N */
|
||||||
/* vec3 B = normalize(cross(N, T)); */
|
/* vec3 B = normalize(cross(N, T)); */
|
||||||
TBN = mat3(T, B, N);
|
TBN = mat3(T, B, N);
|
||||||
|
|||||||
Reference in New Issue
Block a user