diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-27 18:36:45 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-27 18:36:45 +0100 |
commit | 6ed208747005774f3fbc90256b9da0c6890a0814 (patch) | |
tree | b10a7a2a23bdfad799fb108687108798561ed866 /gfx/gl/shaders/commonPoint.glsl | |
parent | Merge branch 'instancing-pt2' (diff) | |
download | ilt-6ed208747005774f3fbc90256b9da0c6890a0814.tar.bz2 ilt-6ed208747005774f3fbc90256b9da0c6890a0814.tar.xz ilt-6ed208747005774f3fbc90256b9da0c6890a0814.zip |
Lookup material details once in the vertex shader
... instead of per texel in the fragment shader
Diffstat (limited to 'gfx/gl/shaders/commonPoint.glsl')
-rw-r--r-- | gfx/gl/shaders/commonPoint.glsl | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gfx/gl/shaders/commonPoint.glsl b/gfx/gl/shaders/commonPoint.glsl index ecf5fc9..35510e1 100644 --- a/gfx/gl/shaders/commonPoint.glsl +++ b/gfx/gl/shaders/commonPoint.glsl @@ -1,3 +1,18 @@ +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)); +} + void main() { @@ -7,7 +22,7 @@ main() TexCoords = texCoord; Normal = (model * vec4(normal, 0.0)).xyz; Colour = colour; - Material = material; + Material = getMaterialDetail(material); gl_Position = viewProjection * worldPos; } |