diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-17 17:04:32 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-17 17:04:32 +0100 |
commit | e4414150da485a8aacdd221e23cad801f8d532c6 (patch) | |
tree | d93c48015e50501477bb97d067eca16c746a36f5 /gfx/gl/sceneShader.cpp | |
parent | Assets moved to global game state (diff) | |
download | ilt-e4414150da485a8aacdd221e23cad801f8d532c6.tar.bz2 ilt-e4414150da485a8aacdd221e23cad801f8d532c6.tar.xz ilt-e4414150da485a8aacdd221e23cad801f8d532c6.zip |
Fix up the way spotlight shader works
Was mostly through lack of understanding and coincidences. Position is now the only vertex data,
direction is moved to a uniform. Instancing will address this by making everything instance data.
Diffstat (limited to 'gfx/gl/sceneShader.cpp')
-rw-r--r-- | gfx/gl/sceneShader.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gfx/gl/sceneShader.cpp b/gfx/gl/sceneShader.cpp index 54f5737..37eacbd 100644 --- a/gfx/gl/sceneShader.cpp +++ b/gfx/gl/sceneShader.cpp @@ -20,8 +20,8 @@ #include <maths.h> SceneShader::SceneShader() : - basicInst {dynamicPointInst_vs, material_fs}, landmass {fixedPoint_vs, landmass_fs}, absolute {fixedPoint_vs, - material_fs} + basicInst {dynamicPointInst_vs, material_fs}, landmass {fixedPoint_vs, landmass_fs}, + absolute {fixedPoint_vs, material_fs} { } @@ -104,8 +104,8 @@ SceneShader::PointLightShader::add(const glm::vec3 & position, const glm::vec3 & } SceneShader::SpotLightShader::SpotLightShader() : - SceneProgram {spotLight_vs, spotLight_gs, spotLight_fs}, colourLoc {*this, "colour"}, kqLoc {*this, "kq"}, - arcLoc {*this, "arc"} + SceneProgram {spotLight_vs, spotLight_gs, spotLight_fs}, directionLoc {*this, "v_direction"}, + colourLoc {*this, "colour"}, kqLoc {*this, "kq"}, arcLoc {*this, "arc"} { using v3pair = std::pair<glm::vec3, glm::vec3>; VertexArrayObject<v3pair>::configure<&v3pair::first, &v3pair::second>(va, b); @@ -119,9 +119,9 @@ SceneShader::SpotLightShader::add(const glm::vec3 & position, const glm::vec3 & glBindVertexArray(va); glBindBuffer(GL_ARRAY_BUFFER, b); glUniform3fv(colourLoc, 1, glm::value_ptr(colour)); + glUniform3fv(directionLoc, 1, glm::value_ptr(direction)); glUniform1f(kqLoc, kq); glUniform1f(arcLoc, arc); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(glm::vec3), glm::value_ptr(position)); - glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3), sizeof(glm::vec3), glm::value_ptr(direction)); glDrawArrays(GL_POINTS, 0, 1); } |