diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-10 00:59:41 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-10 00:59:41 +0100 |
commit | 439630ae86b01b714574335d4dd2e583f724dba3 (patch) | |
tree | 719374873dad863c4a71c741ed74f143bc52b089 | |
parent | Fix stencil shadow depth offset (diff) | |
download | ilt-439630ae86b01b714574335d4dd2e583f724dba3.tar.bz2 ilt-439630ae86b01b714574335d4dd2e583f724dba3.tar.xz ilt-439630ae86b01b714574335d4dd2e583f724dba3.zip |
Include foliage yaw rotation in vertex, pass through instead of whole model rotation matrix
-rw-r--r-- | game/scenary/foliage.cpp | 5 | ||||
-rw-r--r-- | game/scenary/foliage.h | 7 | ||||
-rw-r--r-- | game/scenary/plant.cpp | 3 | ||||
-rw-r--r-- | gfx/gl/shaders/shadowDynamicPointStencil.vs | 8 |
4 files changed, 15 insertions, 8 deletions
diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp index 1e7424e..c90d5be 100644 --- a/game/scenary/foliage.cpp +++ b/game/scenary/foliage.cpp @@ -15,8 +15,9 @@ Foliage::postLoad() { texture = getTexture(); bodyMesh->configureVAO(instanceVAO) - .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(instances.bufferName(), 1); - VertexArrayObject {instancePointVAO}.addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>( + .addAttribs<LocationVertex, &LocationVertex::rotation, &LocationVertex::position>( + instances.bufferName(), 1); + VertexArrayObject {instancePointVAO}.addAttribs<LocationVertex, &LocationVertex::position, &LocationVertex::yaw>( instances.bufferName()); } diff --git a/game/scenary/foliage.h b/game/scenary/foliage.h index 824a644..5da63f0 100644 --- a/game/scenary/foliage.h +++ b/game/scenary/foliage.h @@ -17,7 +17,12 @@ class Foliage : public Asset, public Renderable, public StdTypeDefs<Foliage> { glVertexArray instancePointVAO; public: - using LocationVertex = std::pair<glm::mat3, GlobalPosition3D>; + struct LocationVertex { + glm::mat3 rotation; + float yaw; + GlobalPosition3D position; + }; + mutable InstanceVertices<LocationVertex> instances; void render(const SceneShader &) const override; void shadows(const ShadowMapper &) const override; diff --git a/game/scenary/plant.cpp b/game/scenary/plant.cpp index b39c28b..2006225 100644 --- a/game/scenary/plant.cpp +++ b/game/scenary/plant.cpp @@ -2,6 +2,7 @@ #include "location.h" Plant::Plant(std::shared_ptr<const Foliage> type, const Location & position) : - type {std::move(type)}, location {this->type->instances.acquire(position.getRotationTransform(), position.pos)} + type {std::move(type)}, + location {this->type->instances.acquire(position.getRotationTransform(), position.rot.y, position.pos)} { } diff --git a/gfx/gl/shaders/shadowDynamicPointStencil.vs b/gfx/gl/shaders/shadowDynamicPointStencil.vs index dadf9c2..0dd2d79 100644 --- a/gfx/gl/shaders/shadowDynamicPointStencil.vs +++ b/gfx/gl/shaders/shadowDynamicPointStencil.vs @@ -1,17 +1,17 @@ #version 330 core #extension GL_ARB_shading_language_420pack : enable -layout(location = 0) in mat3 model; -layout(location = 3) in ivec3 worldPos; +layout(location = 0) in ivec3 worldPos; +layout(location = 1) in float modelYaw; uniform ivec3 viewPoint; uniform vec3 centre; -out mat3 vmodel; +out float vmodelYaw; out ivec3 vworldPos; void main() { - vmodel = model; + vmodelYaw = modelYaw; vworldPos = worldPos - viewPoint + ivec3(centre); } |