From f8af4c44d17b94ab814f1784060388afd7a24e03 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sat, 26 Jan 2019 14:54:29 +0500 Subject: Removed previous implementation of Shader --- cwd/shaders/entity.fs | 9 --------- cwd/shaders/entity.vs | 13 ------------- cwd/shaders/face.fs | 49 ------------------------------------------------- cwd/shaders/face.vs | 41 ----------------------------------------- cwd/shaders/fbo.fs | 11 ----------- cwd/shaders/fbo.vs | 11 ----------- cwd/shaders/sky.fs | 51 --------------------------------------------------- cwd/shaders/sky.vs | 17 ----------------- 8 files changed, 202 deletions(-) delete mode 100644 cwd/shaders/entity.fs delete mode 100644 cwd/shaders/entity.vs delete mode 100644 cwd/shaders/face.fs delete mode 100644 cwd/shaders/face.vs delete mode 100644 cwd/shaders/fbo.fs delete mode 100644 cwd/shaders/fbo.vs delete mode 100644 cwd/shaders/sky.fs delete mode 100644 cwd/shaders/sky.vs (limited to 'cwd/shaders') diff --git a/cwd/shaders/entity.fs b/cwd/shaders/entity.fs deleted file mode 100644 index f0bb42f..0000000 --- a/cwd/shaders/entity.fs +++ /dev/null @@ -1,9 +0,0 @@ -#version 330 core - -uniform vec3 color; -in vec2 uvPos; - -void main(){ - //if (uvPos.x < 0.9 && uvPos.x > 0.1 && uvPos.y < 0.9 && uvPos.y > 0.1) discard; - gl_FragColor = vec4(color,1); -} \ No newline at end of file diff --git a/cwd/shaders/entity.vs b/cwd/shaders/entity.vs deleted file mode 100644 index baa25e5..0000000 --- a/cwd/shaders/entity.vs +++ /dev/null @@ -1,13 +0,0 @@ -#version 330 core - -uniform mat4 view; -uniform mat4 projection; -uniform mat4 model; -layout (location = 0) in vec3 position; -layout (location = 1) in vec2 uvPosition; -out vec2 uvPos; - -void main(){ - uvPos = uvPosition; - gl_Position = projection*view*model*vec4(position,1); -} \ No newline at end of file diff --git a/cwd/shaders/face.fs b/cwd/shaders/face.fs deleted file mode 100644 index 4872f06..0000000 --- a/cwd/shaders/face.fs +++ /dev/null @@ -1,49 +0,0 @@ -#version 330 core - -in VS_OUT { - vec2 UvPosition; - vec3 Texture; - vec3 Color; - vec2 Light; -} fs_in; - -uniform sampler2DArray textureAtlas; -uniform vec2 windowSize; -uniform float DayTime; -uniform float MinLightLevel; - -vec3 rgb2hsv(vec3 c) -{ - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 1.0e-10; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); -} - -vec3 hsv2rgb(vec3 c) -{ - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} - -void main() { - vec4 color = texture(textureAtlas,fs_in.Texture); - if (color.a < 0.3) - discard; - - vec3 hsvColor = rgb2hsv(color.xyz); - hsvColor+=fs_in.Color; - color = vec4(hsv2rgb(hsvColor),1); - - float light = fs_in.Light.x / 15.0; - float skyLight = (fs_in.Light.y / 15.0) * DayTime; - - float faceLight = clamp(light + skyLight,MinLightLevel,1.0); - - color = vec4(color.rgb * faceLight, color.a); - gl_FragColor = color; -} \ No newline at end of file diff --git a/cwd/shaders/face.vs b/cwd/shaders/face.vs deleted file mode 100644 index 9c40846..0000000 --- a/cwd/shaders/face.vs +++ /dev/null @@ -1,41 +0,0 @@ -#version 330 core -layout (location = 0) in vec3 position; -layout (location = 2) in vec2 UvCoordinates; -layout (location = 7) in vec4 Texture; -layout (location = 8) in mat4 model; -layout (location = 12) in vec3 color; -layout (location = 13) in vec2 light; -layout (location = 14) in float TextureLayer; - -out VS_OUT { - vec2 UvPosition; - vec3 Texture; - vec3 Color; - vec2 Light; -} vs_out; - -//uniform mat4 view; -//uniform mat4 projection; -uniform mat4 projView; - -vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer) { - float x = TextureAtlasCoords.x; - float y = TextureAtlasCoords.y; - float w = TextureAtlasCoords.z; - float h = TextureAtlasCoords.w; - vec2 A = vec2(x, 1 - y - h); - vec2 B = vec2(x + w, 1 - y); - vec2 transformed = A + UvCoords * (B - A); - return vec3(transformed.x, transformed.y, Layer); -} - -void main() -{ - vec4 sourcePosition = vec4(position,1.0f); - gl_Position = projView * model * sourcePosition; - - vs_out.UvPosition = vec2(UvCoordinates.x,UvCoordinates.y); - vs_out.Texture = TransformTextureCoord(Texture,UvCoordinates,TextureLayer); - vs_out.Color = color; - vs_out.Light = light; -} diff --git a/cwd/shaders/fbo.fs b/cwd/shaders/fbo.fs deleted file mode 100644 index df624b3..0000000 --- a/cwd/shaders/fbo.fs +++ /dev/null @@ -1,11 +0,0 @@ -#version 330 core - -out vec4 FragColor; -in vec2 TexCoords; - -uniform sampler2D inputTexture; - -void main() -{ - FragColor = texture(inputTexture, TexCoords); -} \ No newline at end of file diff --git a/cwd/shaders/fbo.vs b/cwd/shaders/fbo.vs deleted file mode 100644 index e1e8966..0000000 --- a/cwd/shaders/fbo.vs +++ /dev/null @@ -1,11 +0,0 @@ -#version 330 core -layout (location = 0) in vec2 Pos; -layout (location = 1) in vec2 TextureCoords; - -out vec2 TexCoords; - -void main() -{ - gl_Position = vec4(Pos.x, Pos.y, 0.0, 1.0); - TexCoords = TextureCoords; -} \ No newline at end of file diff --git a/cwd/shaders/sky.fs b/cwd/shaders/sky.fs deleted file mode 100644 index 36d65a5..0000000 --- a/cwd/shaders/sky.fs +++ /dev/null @@ -1,51 +0,0 @@ -#version 330 core - -in vec2 uvPos; -in vec3 pos; - -uniform sampler2DArray textureAtlas; -uniform float DayTime; -uniform vec4 sunTexture; -uniform float sunTextureLayer; -uniform vec4 moonTexture; -uniform float moonTextureLayer; - -const vec4 DaySkyColor = vec4(0.49,0.66,1, 1); - -const vec3 SunPos = vec3(0,0.1,0.5); - -const vec3 MoonPos = vec3(0,0.1,-0.5); - -vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer) { - float x = TextureAtlasCoords.x; - float y = TextureAtlasCoords.y; - float w = TextureAtlasCoords.z; - float h = TextureAtlasCoords.w; - vec2 A = vec2(x, 1 - y - h); - vec2 B = vec2(x + w, 1 - y); - vec2 transformed = A + UvCoords * (B - A); - return vec3(transformed.x, transformed.y, Layer); -} - -vec4 Sun() { - vec3 sunDelta = (pos - SunPos)*3.0f; - float distanceToSun = length(sunDelta); - vec4 sunColor = texture(textureAtlas,TransformTextureCoord(sunTexture,(vec2(sunDelta.xy)+0.5f),sunTextureLayer)); - vec4 sun = mix(vec4(0,0,0,1),sunColor,clamp(1-distanceToSun*2.0f,0,1)); - return sun; -} - -vec4 Moon() { - vec3 moonDelta = (pos - MoonPos)*4.5f; - float distanceToMoon = length(moonDelta); - vec4 moonColor = texture(textureAtlas,TransformTextureCoord(moonTexture,(vec2(moonDelta.xy)+0.5f),moonTextureLayer)); - vec4 moon = mix(vec4(0,0,0,1),moonColor,clamp(1-distanceToMoon*2.0f,0,1)); - return moon; -} - -void main() { - vec4 starColor = vec4(0.0f, 0.04f, 0.06f, 1.0f); - gl_FragColor = mix(starColor, DaySkyColor, DayTime); - gl_FragColor += Sun(); - gl_FragColor += Moon(); -} \ No newline at end of file diff --git a/cwd/shaders/sky.vs b/cwd/shaders/sky.vs deleted file mode 100644 index 983e1f3..0000000 --- a/cwd/shaders/sky.vs +++ /dev/null @@ -1,17 +0,0 @@ -#version 330 core - -uniform mat4 view; -uniform mat4 projection; -uniform mat4 model; - -layout (location = 0) in vec3 position; -layout (location = 1) in vec2 uvPosition; - -out vec2 uvPos; -out vec3 pos; - -void main(){ - uvPos = uvPosition; - pos = position; - gl_Position = projection*view*model*vec4(position,1); -} \ No newline at end of file -- cgit v1.2.3