diffren/shader/geom_frag.glsl

32 lines
831 B
Plaintext
Raw Normal View History

#version 460 core
// Note: orm = occlusion/roughness/metallic
layout (location = 0) out vec3 g_position;
layout (location = 1) out vec3 g_albedo;
layout (location = 2) out vec3 g_normal;
layout (location = 3) out vec3 g_orm;
in VS_OUT {
vec3 viewPos;
vec2 texcoord;
mat3 TBN;
} fs_in;
layout (location = 1) uniform sampler2D tex_albedo;
layout (location = 2) uniform sampler2D tex_normal;
layout (location = 3) uniform sampler2D tex_orm;
void main() {
// Just sample albedo and occlusion/roughness/metallic
g_albedo = texture(tex_albedo, fs_in.texcoord).rgb;
g_orm = texture(tex_orm, fs_in.texcoord).rgb;
g_position = fs_in.viewPos;
// Normal mapping
vec3 normal = texture(tex_normal, fs_in.texcoord).rgb;
normal = normal * 2.0 - 1.0;
g_normal = normalize(fs_in.TBN * normal);
}