diff options
Diffstat (limited to 'cwd')
-rw-r--r-- | cwd/assets/altcraft/shaders/frag/face.fs | 10 | ||||
-rw-r--r-- | cwd/assets/altcraft/shaders/frag/light.fs | 16 | ||||
-rw-r--r-- | cwd/assets/altcraft/shaders/vert/light.vs | 11 |
3 files changed, 33 insertions, 4 deletions
diff --git a/cwd/assets/altcraft/shaders/frag/face.fs b/cwd/assets/altcraft/shaders/frag/face.fs index 30d44d2..0eb5a21 100644 --- a/cwd/assets/altcraft/shaders/frag/face.fs +++ b/cwd/assets/altcraft/shaders/frag/face.fs @@ -5,14 +5,16 @@ in VS_OUT { vec3 Color; } fs_in; -out vec4 fragColor; +layout (location = 0) out vec4 color; +layout (location = 1) out vec4 normal; uniform sampler2DArray textureAtlas; void main() { - vec4 color = texture(textureAtlas,fs_in.Texture); - if (color.a < 0.3) + vec4 col = texture(textureAtlas, fs_in.Texture); + if (col.a < 0.3) discard; - fragColor = vec4(color.rgb * fs_in.Color, 1.0); + color = vec4(col.rgb * fs_in.Color, 1.0f); + normal = vec4(1.0f - color.r, 1.0f - color.b, 1.0f, 1.0f); } diff --git a/cwd/assets/altcraft/shaders/frag/light.fs b/cwd/assets/altcraft/shaders/frag/light.fs new file mode 100644 index 0000000..480e265 --- /dev/null +++ b/cwd/assets/altcraft/shaders/frag/light.fs @@ -0,0 +1,16 @@ +#version 330 core + +out vec4 fragColor; + +in vec2 uv; + +uniform sampler2D color; +uniform sampler2D normal; +uniform sampler2D depthStencil; + +void main() { + vec4 c = texture(color, uv); + vec4 n = texture(normal, uv); + float d = texture(depthStencil, uv).r; + fragColor = vec4(c.r, n.r, d - 0.3f, 1.0f); +} diff --git a/cwd/assets/altcraft/shaders/vert/light.vs b/cwd/assets/altcraft/shaders/vert/light.vs new file mode 100644 index 0000000..f837ebe --- /dev/null +++ b/cwd/assets/altcraft/shaders/vert/light.vs @@ -0,0 +1,11 @@ +#version 330 core + +in vec2 pos; +in vec2 uvPos; + +out vec2 uv; + +void main() { + gl_Position = vec4(pos.x, pos.y, 0.0, 1.0); + uv = uvPos; +} |