diff options
Diffstat (limited to 'gfx/gl/shaders')
| -rw-r--r-- | gfx/gl/shaders/billboard.frag | 2 | ||||
| -rw-r--r-- | gfx/gl/shaders/billboard.vert | 6 | ||||
| -rw-r--r-- | gfx/gl/shaders/commonPoint.glsl | 4 | ||||
| -rw-r--r-- | gfx/gl/shaders/directionalLight.frag | 5 | ||||
| -rw-r--r-- | gfx/gl/shaders/landmass.frag | 2 | ||||
| -rw-r--r-- | gfx/gl/shaders/materialOut.glsl | 2 | ||||
| -rw-r--r-- | gfx/gl/shaders/network.frag | 3 | ||||
| -rw-r--r-- | gfx/gl/shaders/pointLight.frag | 2 | ||||
| -rw-r--r-- | gfx/gl/shaders/pointLight.vert | 4 | ||||
| -rw-r--r-- | gfx/gl/shaders/spotLight.frag | 2 | ||||
| -rw-r--r-- | gfx/gl/shaders/spotLight.vert | 4 | ||||
| -rw-r--r-- | gfx/gl/shaders/water.frag | 6 | ||||
| -rw-r--r-- | gfx/gl/shaders/water.vert | 6 |
13 files changed, 23 insertions, 25 deletions
diff --git a/gfx/gl/shaders/billboard.frag b/gfx/gl/shaders/billboard.frag index 1e2c4ae..7864c79 100644 --- a/gfx/gl/shaders/billboard.frag +++ b/gfx/gl/shaders/billboard.frag @@ -10,7 +10,7 @@ uniform float size; include(`materialOut.glsl') -flat in ivec3 ModelPos; +flat in vec3 ModelPos; flat in float Yaw; flat in float Depth; diff --git a/gfx/gl/shaders/billboard.vert b/gfx/gl/shaders/billboard.vert index 2d73084..faf8b19 100644 --- a/gfx/gl/shaders/billboard.vert +++ b/gfx/gl/shaders/billboard.vert @@ -8,16 +8,16 @@ uniform float size; layout(location = 0) in ivec3 modelPos; layout(location = 1) in float yaw; -flat out ivec3 ModelPos; +flat out vec3 ModelPos; flat out float Yaw; flat out float Depth; void main() { - ModelPos = modelPos; + ModelPos = modelPos - viewPoint; Yaw = yaw; - gl_Position = viewProjection * vec4(modelPos - viewPoint + centre, 1); + gl_Position = viewProjection * vec4(ModelPos + centre, 1); Depth = gl_Position.w; gl_PointSize = (viewPort.w * size * 2) / gl_Position.w; } diff --git a/gfx/gl/shaders/commonPoint.glsl b/gfx/gl/shaders/commonPoint.glsl index dc534d5..9a08321 100644 --- a/gfx/gl/shaders/commonPoint.glsl +++ b/gfx/gl/shaders/commonPoint.glsl @@ -3,11 +3,11 @@ include(`getMaterialDetail.glsl') void main() { - FragPos = (model * position) + modelPos; + FragPos = (model * position) + modelPos - viewPoint; TexCoords = texCoord; Normal = (model * normal); Colour = colour; Material = getMaterialDetail(material); - gl_Position = viewProjection * vec4(FragPos - viewPoint, 1); + gl_Position = viewProjection * vec4(FragPos, 1); } diff --git a/gfx/gl/shaders/directionalLight.frag b/gfx/gl/shaders/directionalLight.frag index e5ebfb0..5da1acd 100644 --- a/gfx/gl/shaders/directionalLight.frag +++ b/gfx/gl/shaders/directionalLight.frag @@ -6,13 +6,12 @@ out vec3 FragColor; in vec2 TexCoords; -layout(binding = 0) uniform isampler2D gPosition; +layout(binding = 0) uniform sampler2D gPosition; layout(binding = 1) uniform sampler2D gNormal; layout(binding = 2) uniform sampler2DArray shadowMap; uniform vec3 lightDirection; uniform vec3 lightColour; -uniform ivec3 lightPoint; uniform mat4 lightViewProjection[MAX_MAPS]; uniform uint lightViewProjectionCount; @@ -53,7 +52,7 @@ isShaded(vec4 Position) void main() { - const vec4 Position = vec4(texture(gPosition, TexCoords).xyz - lightPoint, 1); + const vec4 Position = vec4(texture(gPosition, TexCoords).xyz, 1); const vec3 Normal = texture(gNormal, TexCoords).rgb; const float shaded = isShaded(Position); FragColor = shaded * max(dot(-lightDirection, Normal) * lightColour, 0); diff --git a/gfx/gl/shaders/landmass.frag b/gfx/gl/shaders/landmass.frag index b5c7fa1..d641ecd 100644 --- a/gfx/gl/shaders/landmass.frag +++ b/gfx/gl/shaders/landmass.frag @@ -67,7 +67,7 @@ main() } } - gPosition = ivec4(position, 1); + gPosition = vec4(FragPos, 1); gNormal = vec4(Normal, 1); gAlbedoSpec = vec4(color, 1); } diff --git a/gfx/gl/shaders/materialOut.glsl b/gfx/gl/shaders/materialOut.glsl index 846825e..dc5f8e8 100644 --- a/gfx/gl/shaders/materialOut.glsl +++ b/gfx/gl/shaders/materialOut.glsl @@ -1,3 +1,3 @@ -layout(location = 0) out ivec4 gPosition; +layout(location = 0) out vec4 gPosition; layout(location = 1) out vec4 gNormal; layout(location = 2) out vec4 gAlbedoSpec; diff --git a/gfx/gl/shaders/network.frag b/gfx/gl/shaders/network.frag index 2f291ea..8c62e34 100644 --- a/gfx/gl/shaders/network.frag +++ b/gfx/gl/shaders/network.frag @@ -5,12 +5,11 @@ in vec3 rposition; in vec2 texCoord; layout(binding = 0) uniform sampler2D texture0; -uniform ivec3 viewPoint; void main() { - gPosition = ivec4(viewPoint + rposition, 1); + gPosition = vec4(rposition, 1); gNormal = vec4(0, 0, 1, 1); gAlbedoSpec = texture(texture0, texCoord); } diff --git a/gfx/gl/shaders/pointLight.frag b/gfx/gl/shaders/pointLight.frag index bb2c453..a141592 100644 --- a/gfx/gl/shaders/pointLight.frag +++ b/gfx/gl/shaders/pointLight.frag @@ -2,7 +2,7 @@ out vec3 FragColor; -layout(binding = 0) uniform isampler2D gPosition; +layout(binding = 0) uniform sampler2D gPosition; layout(binding = 1) uniform sampler2D gNormal; uniform ivec4 viewPort; flat in vec4 geo_centre; diff --git a/gfx/gl/shaders/pointLight.vert b/gfx/gl/shaders/pointLight.vert index 2fd5418..b8ddecb 100644 --- a/gfx/gl/shaders/pointLight.vert +++ b/gfx/gl/shaders/pointLight.vert @@ -16,9 +16,9 @@ flat out float kq; void main() { - position = modelPos + ivec3(mat3(model) * v_position); + position = (modelPos - viewPoint) + ivec3(mat3(model) * v_position); kq = v_kq; size = (8000 * sqrt(max(max(v_colour.r, v_colour.g), v_colour.b))) / sqrt(v_kq); colour = v_colour; - gl_Position = vec4(position - viewPoint, 0); + gl_Position = vec4(position, 0); } diff --git a/gfx/gl/shaders/spotLight.frag b/gfx/gl/shaders/spotLight.frag index 1305dbd..0241e88 100644 --- a/gfx/gl/shaders/spotLight.frag +++ b/gfx/gl/shaders/spotLight.frag @@ -2,7 +2,7 @@ out vec3 FragColor; -layout(binding = 0) uniform isampler2D gPosition; +layout(binding = 0) uniform sampler2D gPosition; layout(binding = 1) uniform sampler2D gNormal; uniform ivec4 viewPort; flat in vec4 geo_centre; diff --git a/gfx/gl/shaders/spotLight.vert b/gfx/gl/shaders/spotLight.vert index 36d2ee5..83f3859 100644 --- a/gfx/gl/shaders/spotLight.vert +++ b/gfx/gl/shaders/spotLight.vert @@ -20,11 +20,11 @@ flat out float kq; void main() { - position = modelPos + ivec3(mat3(model) * v_position); + position = (modelPos - viewPoint) + ivec3(mat3(model) * v_position); direction = normalize(mat3(model) * v_direction); colour = v_colour; kq = v_kq; size = (8000 * sqrt(max(max(colour.r, colour.g), colour.b))) / sqrt(kq); arc = vec2(cos(v_arc / 2), tan(v_arc / 2)); - gl_Position = vec4(position - viewPoint, 0); + gl_Position = vec4(position, 0); } diff --git a/gfx/gl/shaders/water.frag b/gfx/gl/shaders/water.frag index a09e754..86a8a87 100644 --- a/gfx/gl/shaders/water.frag +++ b/gfx/gl/shaders/water.frag @@ -1,6 +1,6 @@ #version 460 core -in vec3 FragPos; +in vec4 FragPos; in vec2 TexCoords; include(`materialOut.glsl') @@ -9,8 +9,8 @@ uniform sampler2D texture0; void main() { - gPosition = ivec4(FragPos, 1); + gPosition = vec4(FragPos.xyz, 1); gNormal = vec4(0, 0, 1, 1); gAlbedoSpec = texture(texture0, TexCoords); - gAlbedoSpec.a *= clamp(-FragPos.z * .0007, .1, 1.0); + gAlbedoSpec.a *= clamp(-FragPos.w * .0007, .1, 1.0); } diff --git a/gfx/gl/shaders/water.vert b/gfx/gl/shaders/water.vert index 60e4fb8..bb056b8 100644 --- a/gfx/gl/shaders/water.vert +++ b/gfx/gl/shaders/water.vert @@ -1,7 +1,7 @@ #version 460 core layout(location = 0) in ivec3 position; -out vec3 FragPos; +out vec4 FragPos; out vec2 TexCoords; uniform mat4 viewProjection; @@ -14,8 +14,8 @@ main() vec3 wpos = vec3(position.x + (cos(waves) * 1000.0), position.y + (cos(waves * 1.4) * 1000.0), cos(waves + (position.x / 1000000) + (position.y / 8000)) * 300.0); - FragPos = vec3(wpos.xy, position.z); + FragPos = vec4(wpos - viewPoint, position.z); TexCoords = (position.xy / 8192) - (viewPoint.xy / 8192); - gl_Position = viewProjection * vec4(wpos - viewPoint, 1.0); + gl_Position = viewProjection * vec4(FragPos.xyz, 1.0); } |
