65 lines
1.7 KiB
GLSL
65 lines
1.7 KiB
GLSL
#version 430 core
|
|
|
|
in VS_OUT {
|
|
vec3 Position; // world coordinates
|
|
vec3 Normal;
|
|
vec2 Texture;
|
|
} fs_in;
|
|
|
|
layout (location = 10) uniform vec4 EmissionColor;
|
|
layout (location = 11) uniform vec4 AmbientColor;
|
|
layout (location = 12) uniform vec4 DiffuseColor;
|
|
layout (location = 13) uniform vec4 SpecularColor;
|
|
|
|
layout (location = 14) uniform float shininess;
|
|
|
|
layout (location = 15) uniform sampler2D EmissionSampler;
|
|
layout (location = 16) uniform sampler2D AmbientSampler;
|
|
layout (location = 17) uniform sampler2D DiffuseSampler;
|
|
layout (location = 18) uniform sampler2D SpecularSampler;
|
|
|
|
layout (location = 19) uniform ivec4 TextureChannel;
|
|
|
|
layout (location = 0) out vec4 Position;
|
|
layout (location = 1) out vec4 Normal;
|
|
layout (location = 2) out vec4 Color;
|
|
layout (location = 3) out vec4 Block;
|
|
|
|
void main()
|
|
{
|
|
vec4 emission;
|
|
vec4 ambient;
|
|
vec4 diffuse;
|
|
vec4 specular;
|
|
if (TextureChannel.x >= 0) { // emission
|
|
emission = texture(EmissionSampler, fs_in.Texture.xy);
|
|
} else {
|
|
emission = EmissionColor;
|
|
}
|
|
if (TextureChannel.y >= 0) { // ambient
|
|
ambient = texture(AmbientSampler, fs_in.Texture.xy);
|
|
} else {
|
|
ambient = AmbientColor;
|
|
}
|
|
if (TextureChannel.z >= 0) { // diffuse
|
|
diffuse = texture(DiffuseSampler, fs_in.Texture.xy);
|
|
} else {
|
|
diffuse = DiffuseColor;
|
|
}
|
|
if (TextureChannel.w >= 0) { // specular
|
|
specular = texture(SpecularSampler, fs_in.Texture.xy);
|
|
} else {
|
|
specular = SpecularColor;
|
|
}
|
|
|
|
vec3 color = emission.xyz * 0;
|
|
color += ambient.xyz * 0.05;
|
|
color += diffuse.xyz * 1;
|
|
color += specular.xyz * 0 * 0.3;
|
|
|
|
Position = vec4(fs_in.Position, 1.0);
|
|
Normal = vec4(fs_in.Normal, 0.0);
|
|
Color = vec4(color, 1.0);
|
|
Block = vec4(0, 0, 0, 0);
|
|
}
|