64 lines
1.2 KiB
Forth
64 lines
1.2 KiB
Forth
|
#version 460 core
|
||
|
|
||
|
// gbuffer textures
|
||
|
uniform sampler2D s_albedo;
|
||
|
uniform sampler2D s_depth;
|
||
|
uniform sampler2D s_normal;
|
||
|
uniform sampler2D s_material;
|
||
|
uniform sampler2D s_position;
|
||
|
|
||
|
// lights
|
||
|
#define MAX_LIGHT_COUNT 100
|
||
|
#define POINT 0
|
||
|
#define SPOT 1
|
||
|
#define DIRECTIONAL 2
|
||
|
#define AMBIENT 3
|
||
|
|
||
|
struct light_t {
|
||
|
vec3 color;
|
||
|
vec3 position;
|
||
|
vec3 direction;
|
||
|
float intensity;
|
||
|
int type;
|
||
|
};
|
||
|
|
||
|
uniform light_t lights[MAX_LIGHT_COUNT];
|
||
|
uniform int light_count;
|
||
|
|
||
|
uniform vec3 view_pos;
|
||
|
|
||
|
// from vertex shader
|
||
|
in vec3 pos;
|
||
|
in vec2 tex;
|
||
|
|
||
|
out vec4 FragColor;
|
||
|
|
||
|
vec3 albedo;
|
||
|
float depth;
|
||
|
vec3 normal;
|
||
|
vec3 material; // specular, roughness, metalic
|
||
|
vec3 position;
|
||
|
|
||
|
float specular;
|
||
|
float roughness;
|
||
|
float metalic;
|
||
|
|
||
|
void main() {
|
||
|
// albedo, normal
|
||
|
// material, position
|
||
|
albedo = texture(s_albedo, tex*2).rgb;
|
||
|
depth = texture(s_depth, tex*2).x;
|
||
|
normal = normalize(texture(s_normal, tex*2).rgb);
|
||
|
material = texture(s_material, tex*2).xyz;
|
||
|
{
|
||
|
specular = material.x;
|
||
|
roughness = material.y;
|
||
|
metalic = material.z;
|
||
|
}
|
||
|
position = texture(s_position, tex*2).xyz;
|
||
|
|
||
|
FragColor = vec4(
|
||
|
(pos.x < 0 ? (pos.y < 0 ? material : albedo) : (pos.y < 0 ? position : normal)),
|
||
|
1);
|
||
|
}
|