summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-13 19:45:54 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-13 19:45:54 +0000
commit8566e63b26f9e7ee809c03394743a0576c499378 (patch)
treecdcef5b698a224003ba54507dc24cbb27a57cbbe /gfx
parentAdd glContainer::at override to update a single item (diff)
downloadilt-8566e63b26f9e7ee809c03394743a0576c499378.tar.bz2
ilt-8566e63b26f9e7ee809c03394743a0576c499378.tar.xz
ilt-8566e63b26f9e7ee809c03394743a0576c499378.zip
We only need 3x3 matrix for model rotation spec
Diffstat (limited to 'gfx')
-rw-r--r--gfx/gl/sceneShader.cpp2
-rw-r--r--gfx/gl/shaders/commonPoint.glsl4
-rw-r--r--gfx/gl/shaders/commonShadowPoint.glsl4
-rw-r--r--gfx/gl/shaders/dynamicPoint.vs2
-rw-r--r--gfx/gl/shaders/dynamicPointInst.vs4
-rw-r--r--gfx/gl/shaders/fixedPoint.vs2
-rw-r--r--gfx/gl/shaders/pointLight.vs4
-rw-r--r--gfx/gl/shaders/shadowDynamicPoint.vs2
-rw-r--r--gfx/gl/shaders/shadowDynamicPointInst.vs4
-rw-r--r--gfx/gl/shaders/shadowFixedPoint.vs2
-rw-r--r--gfx/gl/shaders/spotLight.vs4
-rw-r--r--gfx/gl/shadowMapper.cpp2
12 files changed, 18 insertions, 18 deletions
diff --git a/gfx/gl/sceneShader.cpp b/gfx/gl/sceneShader.cpp
index 64bf171..dc77793 100644
--- a/gfx/gl/sceneShader.cpp
+++ b/gfx/gl/sceneShader.cpp
@@ -68,7 +68,7 @@ SceneShader::BasicProgram::BasicProgram() :
void
SceneShader::BasicProgram::setModel(Location const & location) const
{
- glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(rotate_ypr(location.rot)));
+ glUniformMatrix3fv(modelLoc, 1, GL_FALSE, glm::value_ptr(location.getRotationTransform()));
glUniform3iv(modelPosLoc, 1, glm::value_ptr(location.pos));
}
diff --git a/gfx/gl/shaders/commonPoint.glsl b/gfx/gl/shaders/commonPoint.glsl
index a9817fb..2d9e388 100644
--- a/gfx/gl/shaders/commonPoint.glsl
+++ b/gfx/gl/shaders/commonPoint.glsl
@@ -16,9 +16,9 @@ getMaterialDetail(uint midx)
void
main()
{
- FragPos = (model * vec4(position, 1.0)).xyz + modelPos;
+ FragPos = (model * position) + modelPos;
TexCoords = texCoord;
- Normal = (model * vec4(normal, 0.0)).xyz;
+ Normal = (model * normal);
Colour = colour;
Material = getMaterialDetail(material);
diff --git a/gfx/gl/shaders/commonShadowPoint.glsl b/gfx/gl/shaders/commonShadowPoint.glsl
index 216642e..47722d6 100644
--- a/gfx/gl/shaders/commonShadowPoint.glsl
+++ b/gfx/gl/shaders/commonShadowPoint.glsl
@@ -1,7 +1,7 @@
void
main()
{
- vec4 worldPos = model * vec4(position, 1.0);
- gl_Position = viewProjection * vec4(worldPos.xyz - viewPoint + modelPos, 1);
+ vec3 worldPos = model * position;
+ gl_Position = viewProjection * vec4(worldPos - viewPoint + modelPos, 1);
gl_Position.z = max(gl_Position.z, -1);
}
diff --git a/gfx/gl/shaders/dynamicPoint.vs b/gfx/gl/shaders/dynamicPoint.vs
index 097cd11..7551688 100644
--- a/gfx/gl/shaders/dynamicPoint.vs
+++ b/gfx/gl/shaders/dynamicPoint.vs
@@ -6,7 +6,7 @@ include(`materialInterface.glsl')
uniform mat4 viewProjection;
uniform ivec3 viewPoint;
-uniform mat4 model;
+uniform mat3 model;
uniform ivec3 modelPos;
include(`commonPoint.glsl')
diff --git a/gfx/gl/shaders/dynamicPointInst.vs b/gfx/gl/shaders/dynamicPointInst.vs
index 529fe1d..69eab0c 100644
--- a/gfx/gl/shaders/dynamicPointInst.vs
+++ b/gfx/gl/shaders/dynamicPointInst.vs
@@ -6,7 +6,7 @@ include(`materialInterface.glsl')
uniform mat4 viewProjection;
uniform ivec3 viewPoint;
-layout(location = 5) in mat4 model;
-layout(location = 9) in ivec3 modelPos;
+layout(location = 5) in mat3 model;
+layout(location = 8) in ivec3 modelPos;
include(`commonPoint.glsl')
diff --git a/gfx/gl/shaders/fixedPoint.vs b/gfx/gl/shaders/fixedPoint.vs
index 3cea737..5cfe9b3 100644
--- a/gfx/gl/shaders/fixedPoint.vs
+++ b/gfx/gl/shaders/fixedPoint.vs
@@ -6,7 +6,7 @@ include(`materialInterface.glsl')
uniform mat4 viewProjection;
uniform ivec3 viewPoint;
-const mat4 model = mat4(1);
+const mat3 model = mat3(1);
const vec3 modelPos = ivec3(0);
include(`commonPoint.glsl')
diff --git a/gfx/gl/shaders/pointLight.vs b/gfx/gl/shaders/pointLight.vs
index c538207..fbd031c 100644
--- a/gfx/gl/shaders/pointLight.vs
+++ b/gfx/gl/shaders/pointLight.vs
@@ -3,8 +3,8 @@
layout(location = 0) in vec3 v_position;
layout(location = 1) in vec3 v_colour;
layout(location = 2) in float v_kq;
-layout(location = 3) in mat4 model;
-layout(location = 7) in ivec3 modelPos;
+layout(location = 3) in mat3 model;
+layout(location = 6) in ivec3 modelPos;
uniform ivec3 viewPoint;
diff --git a/gfx/gl/shaders/shadowDynamicPoint.vs b/gfx/gl/shaders/shadowDynamicPoint.vs
index f21b3b6..bf0f0a1 100644
--- a/gfx/gl/shaders/shadowDynamicPoint.vs
+++ b/gfx/gl/shaders/shadowDynamicPoint.vs
@@ -4,7 +4,7 @@ include(`meshIn.glsl')
uniform mat4 viewProjection;
uniform ivec3 viewPoint;
-uniform mat4 model;
+uniform mat3 model;
uniform ivec3 modelPos;
include(`commonShadowPoint.glsl')
diff --git a/gfx/gl/shaders/shadowDynamicPointInst.vs b/gfx/gl/shaders/shadowDynamicPointInst.vs
index 28a62d9..b0b80da 100644
--- a/gfx/gl/shaders/shadowDynamicPointInst.vs
+++ b/gfx/gl/shaders/shadowDynamicPointInst.vs
@@ -4,7 +4,7 @@ include(`meshIn.glsl')
uniform mat4 viewProjection;
uniform ivec3 viewPoint;
-layout(location = 5) in mat4 model;
-layout(location = 9) in ivec3 modelPos;
+layout(location = 5) in mat3 model;
+layout(location = 8) in ivec3 modelPos;
include(`commonShadowPoint.glsl')
diff --git a/gfx/gl/shaders/shadowFixedPoint.vs b/gfx/gl/shaders/shadowFixedPoint.vs
index 168d5f1..307aac2 100644
--- a/gfx/gl/shaders/shadowFixedPoint.vs
+++ b/gfx/gl/shaders/shadowFixedPoint.vs
@@ -4,7 +4,7 @@ include(`meshIn.glsl')
uniform mat4 viewProjection;
uniform ivec3 viewPoint;
-const mat4 model = mat4(1);
+const mat3 model = mat3(1);
const ivec3 modelPos = ivec3(0);
include(`commonShadowPoint.glsl')
diff --git a/gfx/gl/shaders/spotLight.vs b/gfx/gl/shaders/spotLight.vs
index eed8778..e0196c3 100644
--- a/gfx/gl/shaders/spotLight.vs
+++ b/gfx/gl/shaders/spotLight.vs
@@ -5,8 +5,8 @@ layout(location = 1) in vec3 v_direction;
layout(location = 2) in vec3 v_colour;
layout(location = 3) in float v_kq;
layout(location = 4) in float v_arc;
-layout(location = 5) in mat4 model;
-layout(location = 9) in ivec3 modelPos;
+layout(location = 5) in mat3 model;
+layout(location = 8) in ivec3 modelPos;
uniform ivec3 viewPoint;
diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp
index 1498bb0..5dc555a 100644
--- a/gfx/gl/shadowMapper.cpp
+++ b/gfx/gl/shadowMapper.cpp
@@ -208,6 +208,6 @@ ShadowMapper::DynamicPoint::use(const Location & location) const
void
ShadowMapper::DynamicPoint::setModel(const Location & location) const
{
- glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(rotate_ypr(location.rot)));
+ glUniformMatrix3fv(modelLoc, 1, GL_FALSE, glm::value_ptr(location.getRotationTransform()));
glUniform3iv(modelPosLoc, 1, glm::value_ptr(location.pos));
}