diff options
-rw-r--r-- | game/scenary/foliage.h | 2 | ||||
-rw-r--r-- | game/scenary/illuminator.h | 2 | ||||
-rw-r--r-- | game/vehicles/railVehicleClass.cpp | 2 | ||||
-rw-r--r-- | game/vehicles/railVehicleClass.h | 2 | ||||
-rw-r--r-- | gfx/gl/sceneShader.cpp | 2 | ||||
-rw-r--r-- | gfx/gl/shaders/commonPoint.glsl | 4 | ||||
-rw-r--r-- | gfx/gl/shaders/commonShadowPoint.glsl | 4 | ||||
-rw-r--r-- | gfx/gl/shaders/dynamicPoint.vs | 2 | ||||
-rw-r--r-- | gfx/gl/shaders/dynamicPointInst.vs | 4 | ||||
-rw-r--r-- | gfx/gl/shaders/fixedPoint.vs | 2 | ||||
-rw-r--r-- | gfx/gl/shaders/pointLight.vs | 4 | ||||
-rw-r--r-- | gfx/gl/shaders/shadowDynamicPoint.vs | 2 | ||||
-rw-r--r-- | gfx/gl/shaders/shadowDynamicPointInst.vs | 4 | ||||
-rw-r--r-- | gfx/gl/shaders/shadowFixedPoint.vs | 2 | ||||
-rw-r--r-- | gfx/gl/shaders/spotLight.vs | 4 | ||||
-rw-r--r-- | gfx/gl/shadowMapper.cpp | 2 | ||||
-rw-r--r-- | lib/location.cpp | 2 | ||||
-rw-r--r-- | lib/location.h | 2 |
18 files changed, 24 insertions, 24 deletions
diff --git a/game/scenary/foliage.h b/game/scenary/foliage.h index bbb6200..3beda89 100644 --- a/game/scenary/foliage.h +++ b/game/scenary/foliage.h @@ -15,7 +15,7 @@ class Foliage : public Asset, public Renderable, public StdTypeDefs<Foliage> { glVertexArray instanceVAO; public: - using LocationVertex = std::pair<glm::mat4, GlobalPosition3D>; + using LocationVertex = std::pair<glm::mat3, GlobalPosition3D>; mutable InstanceVertices<LocationVertex> instances; void render(const SceneShader &) const override; void shadows(const ShadowMapper &) const override; diff --git a/game/scenary/illuminator.h b/game/scenary/illuminator.h index 893e5c7..cd6073c 100644 --- a/game/scenary/illuminator.h +++ b/game/scenary/illuminator.h @@ -41,7 +41,7 @@ public: }; public: - using LocationVertex = std::pair<glm::mat4, GlobalPosition3D>; + using LocationVertex = std::pair<glm::mat3, GlobalPosition3D>; mutable InstanceVertices<LocationVertex> instances; mutable InstanceVertices<SpotLightVertex> instancesSpotLight; mutable InstanceVertices<PointLightVertex> instancesPointLight; diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp index 3ca42db..5fd7580 100644 --- a/game/vehicles/railVehicleClass.cpp +++ b/game/vehicles/railVehicleClass.cpp @@ -43,7 +43,7 @@ RailVehicleClass::postLoad() bogies.back() ->configureVAO(instancesBogiesVAO.back()) .addAttribs<LocationVertex, &LocationVertex::back, &LocationVertex::backPos>(instances.bufferName(), 1); - static_assert(sizeof(LocationVertex) == 228UL); + static_assert(sizeof(LocationVertex) == 144UL); } void diff --git a/game/vehicles/railVehicleClass.h b/game/vehicles/railVehicleClass.h index 913feea..9d9d4c2 100644 --- a/game/vehicles/railVehicleClass.h +++ b/game/vehicles/railVehicleClass.h @@ -19,7 +19,7 @@ public: void shadows(const ShadowMapper & shadowMapper) const override; struct LocationVertex { - glm::mat4 body, front, back; + glm::mat3 body, front, back; GlobalPosition3D bodyPos, frontPos, backPos; }; 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)); } diff --git a/lib/location.cpp b/lib/location.cpp index ff7cfa6..13acfde 100644 --- a/lib/location.cpp +++ b/lib/location.cpp @@ -2,7 +2,7 @@ #include "maths.h" #include <glm/gtx/transform.hpp> -glm::mat4 +glm::mat3 Location::getRotationTransform() const { return rotate_ypr(rot); diff --git a/lib/location.h b/lib/location.h index 8570fc2..016aee7 100644 --- a/lib/location.h +++ b/lib/location.h @@ -9,7 +9,7 @@ public: explicit Location(GlobalPosition3D pos = {}, Rotation3D rot = {}) : pos {pos}, rot {rot} { } #endif - [[nodiscard]] glm::mat4 getRotationTransform() const; + [[nodiscard]] glm::mat3 getRotationTransform() const; GlobalPosition3D pos; Rotation3D rot; |