summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'gfx')
-rw-r--r--gfx/gl/shaders/commonPoint.glsl2
-rw-r--r--gfx/gl/shaders/commonShadowPoint.glsl5
-rw-r--r--gfx/gl/shaders/commonShadowPoint.gs8
-rw-r--r--gfx/gl/shaders/dynamicPoint.vs2
-rw-r--r--gfx/gl/shaders/dynamicPointInst.vs2
-rw-r--r--gfx/gl/shaders/fixedPoint.vs2
-rw-r--r--gfx/gl/shaders/getMaterialDetail.glsl12
-rw-r--r--gfx/gl/shaders/material.fs2
-rw-r--r--gfx/gl/shaders/materialCommon.glsl6
-rw-r--r--gfx/gl/shaders/materialDetail.glsl19
-rw-r--r--gfx/gl/shaders/materialInterface.glsl6
-rw-r--r--gfx/gl/shaders/shadowDynamicPointInstWithTextures.fs8
-rw-r--r--gfx/gl/shaders/shadowDynamicPointInstWithTextures.vs14
13 files changed, 56 insertions, 32 deletions
diff --git a/gfx/gl/shaders/commonPoint.glsl b/gfx/gl/shaders/commonPoint.glsl
index 6272d0b..dc534d5 100644
--- a/gfx/gl/shaders/commonPoint.glsl
+++ b/gfx/gl/shaders/commonPoint.glsl
@@ -1,4 +1,4 @@
-include(`materialDetail.glsl')
+include(`getMaterialDetail.glsl')
void
main()
diff --git a/gfx/gl/shaders/commonShadowPoint.glsl b/gfx/gl/shaders/commonShadowPoint.glsl
index c4ea827..9910d46 100644
--- a/gfx/gl/shaders/commonShadowPoint.glsl
+++ b/gfx/gl/shaders/commonShadowPoint.glsl
@@ -1,11 +1,10 @@
out vec4 vworldPos;
-ifdef(`TEXTURES', out vec2 vtexCoord;);
-
void
main()
{
vec3 worldPos = model * position;
vworldPos = vec4(worldPos - viewPoint + modelPos, 1);
- ifdef(`TEXTURES', vtexCoord = texCoord;);
+ ifdef(`TEXTURES', TexCoords = texCoord;);
+ ifdef(`TEXTURES', Material = getMaterialDetail(material););
}
diff --git a/gfx/gl/shaders/commonShadowPoint.gs b/gfx/gl/shaders/commonShadowPoint.gs
index b99bd20..2413cc0 100644
--- a/gfx/gl/shaders/commonShadowPoint.gs
+++ b/gfx/gl/shaders/commonShadowPoint.gs
@@ -1,13 +1,16 @@
#version 330 core
#extension GL_ARB_viewport_array : enable
+ifdef(`TEXTURES', include(`materialDetail.glsl'))
+
uniform mat4 viewProjection[4];
uniform int viewProjections;
in vec4 vworldPos[];
layout(triangles) in;
layout(triangle_strip, max_vertices = 12) out;
-ifdef(`TEXTURES', in vec2 vtexCoord[]; out vec2 texCoord;);
+ifdef(`TEXTURES', in vec2 TexCoords[]; out vec2 texCoord;)
+ifdef(`TEXTURES', flat in MaterialDetail Material[]; flat out MaterialDetail material;)
void
main()
@@ -17,7 +20,8 @@ main()
gl_Position = viewProjection[vp] * vworldPos[v];
gl_Position.z = max(gl_Position.z, -1);
gl_Layer = vp;
- ifdef(`TEXTURES', texCoord = vtexCoord[v];);
+ ifdef(`TEXTURES', texCoord = TexCoords[v];)
+ ifdef(`TEXTURES', material = Material[v];)
EmitVertex();
}
EndPrimitive();
diff --git a/gfx/gl/shaders/dynamicPoint.vs b/gfx/gl/shaders/dynamicPoint.vs
index 7551688..97d2983 100644
--- a/gfx/gl/shaders/dynamicPoint.vs
+++ b/gfx/gl/shaders/dynamicPoint.vs
@@ -1,6 +1,8 @@
#version 330 core
#extension GL_ARB_shading_language_420pack : enable
+layout(binding = 1) uniform usampler2DRect materialData;
+
include(`meshIn.glsl')
include(`materialInterface.glsl')
diff --git a/gfx/gl/shaders/dynamicPointInst.vs b/gfx/gl/shaders/dynamicPointInst.vs
index 69eab0c..a85f9c9 100644
--- a/gfx/gl/shaders/dynamicPointInst.vs
+++ b/gfx/gl/shaders/dynamicPointInst.vs
@@ -1,6 +1,8 @@
#version 330 core
#extension GL_ARB_shading_language_420pack : enable
+layout(binding = 1) uniform usampler2DRect materialData;
+
include(`meshIn.glsl')
include(`materialInterface.glsl')
diff --git a/gfx/gl/shaders/fixedPoint.vs b/gfx/gl/shaders/fixedPoint.vs
index 5cfe9b3..435b3d1 100644
--- a/gfx/gl/shaders/fixedPoint.vs
+++ b/gfx/gl/shaders/fixedPoint.vs
@@ -1,6 +1,8 @@
#version 330 core
#extension GL_ARB_shading_language_420pack : enable
+layout(binding = 1) uniform usampler2DRect materialData;
+
include(`meshIn.glsl')
include(`materialInterface.glsl')
diff --git a/gfx/gl/shaders/getMaterialDetail.glsl b/gfx/gl/shaders/getMaterialDetail.glsl
new file mode 100644
index 0000000..f819fb2
--- /dev/null
+++ b/gfx/gl/shaders/getMaterialDetail.glsl
@@ -0,0 +1,12 @@
+MaterialDetail
+getMaterialDetail(uint midx)
+{
+ if (midx > 0u) {
+ const vec4 sPosSize = texture(materialData, uvec2(0, midx - 1u));
+ const uvec4 sMode = texture(materialData, uvec2(1, midx - 1u));
+ const uint mapmodeU = sMode.x & 0xFu;
+ const uint mapmodeV = (sMode.x & 0xF0u) >> 1;
+ return MaterialDetail(sPosSize.xy, sPosSize.zw, uvec2(mapmodeU, mapmodeV));
+ }
+ return MaterialDetail(vec2(0, 0), vec2(0, 0), uvec2(0, 0));
+}
diff --git a/gfx/gl/shaders/material.fs b/gfx/gl/shaders/material.fs
index 94ed024..37f2e27 100644
--- a/gfx/gl/shaders/material.fs
+++ b/gfx/gl/shaders/material.fs
@@ -1,6 +1,8 @@
#version 330 core
#extension GL_ARB_shading_language_420pack : enable
+layout(binding = 0) uniform sampler2D textureAlbedo;
+
include(`materialInterface.glsl')
include(`materialOut.glsl')
include(`materialCommon.glsl')
diff --git a/gfx/gl/shaders/materialCommon.glsl b/gfx/gl/shaders/materialCommon.glsl
index a915ce3..3fe2237 100644
--- a/gfx/gl/shaders/materialCommon.glsl
+++ b/gfx/gl/shaders/materialCommon.glsl
@@ -1,5 +1,3 @@
-layout(binding = 0) uniform sampler2D texture0;
-
float
map(uint mapmode, float value)
{
@@ -28,8 +26,8 @@ vec4
getTextureColour(MaterialDetail mat, vec2 uv)
{
if (mat.textureSize.x > 0) {
- const vec2 tSize = textureSize(texture0, 0);
+ const vec2 tSize = textureSize(textureAlbedo, 0);
uv = (mat.textureOrigin + mat.textureSize * map(mat.mapmode, uv)) / tSize;
}
- return texture(texture0, uv);
+ return texture(textureAlbedo, uv);
}
diff --git a/gfx/gl/shaders/materialDetail.glsl b/gfx/gl/shaders/materialDetail.glsl
index 05cf2c7..a208d50 100644
--- a/gfx/gl/shaders/materialDetail.glsl
+++ b/gfx/gl/shaders/materialDetail.glsl
@@ -1,14 +1,5 @@
-layout(binding = 1) uniform usampler2DRect materialData;
-
-MaterialDetail
-getMaterialDetail(uint midx)
-{
- if (midx > 0u) {
- const vec4 sPosSize = texture(materialData, uvec2(0, midx - 1u));
- const uvec4 sMode = texture(materialData, uvec2(1, midx - 1u));
- const uint mapmodeU = sMode.x & 0xFu;
- const uint mapmodeV = (sMode.x & 0xF0u) >> 1;
- return MaterialDetail(sPosSize.xy, sPosSize.zw, uvec2(mapmodeU, mapmodeV));
- }
- return MaterialDetail(vec2(0, 0), vec2(0, 0), uvec2(0, 0));
-}
+struct MaterialDetail {
+ vec2 textureOrigin;
+ vec2 textureSize;
+ uvec2 mapmode;
+};
diff --git a/gfx/gl/shaders/materialInterface.glsl b/gfx/gl/shaders/materialInterface.glsl
index 5ec5066..f2ca297 100644
--- a/gfx/gl/shaders/materialInterface.glsl
+++ b/gfx/gl/shaders/materialInterface.glsl
@@ -1,8 +1,4 @@
-struct MaterialDetail {
- vec2 textureOrigin;
- vec2 textureSize;
- uvec2 mapmode;
-};
+include(`materialDetail.glsl')
define(INOUT, ifelse(TYPE, .fs, in, out));
diff --git a/gfx/gl/shaders/shadowDynamicPointInstWithTextures.fs b/gfx/gl/shaders/shadowDynamicPointInstWithTextures.fs
index 90519e3..47ce9c0 100644
--- a/gfx/gl/shaders/shadowDynamicPointInstWithTextures.fs
+++ b/gfx/gl/shaders/shadowDynamicPointInstWithTextures.fs
@@ -1,14 +1,18 @@
#version 330 core
#extension GL_ARB_shading_language_420pack : enable
-layout(binding = 3) uniform sampler2D texture0;
+layout(binding = 3) uniform sampler2D textureAlbedo;
+
+include(`materialInterface.glsl')
+include(`materialCommon.glsl')
in vec2 texCoord;
+flat in MaterialDetail material;
void
main()
{
- if (texture(texture0, texCoord).a < 0.5) {
+ if (getTextureColour(material, texCoord).a < 0.5) {
discard;
}
gl_FragDepth = gl_FragCoord.z;
diff --git a/gfx/gl/shaders/shadowDynamicPointInstWithTextures.vs b/gfx/gl/shaders/shadowDynamicPointInstWithTextures.vs
index 27ad9d7..a76c87f 100644
--- a/gfx/gl/shaders/shadowDynamicPointInstWithTextures.vs
+++ b/gfx/gl/shaders/shadowDynamicPointInstWithTextures.vs
@@ -1,3 +1,15 @@
+#version 330 core
+#extension GL_ARB_shading_language_420pack : enable
+
+layout(binding = 4) uniform usampler2DRect materialData;
+
define(`TEXTURES', 1)
+include(`materialInterface.glsl')
+include(`getMaterialDetail.glsl')
+include(`meshIn.glsl')
+
+uniform ivec3 viewPoint;
+layout(location = 5) in mat3 model;
+layout(location = 8) in ivec3 modelPos;
-include(`shadowDynamicPointInst.vs')
+include(`commonShadowPoint.glsl')