From a7dec8fb75fa417400e3594b6e689bc05a6f4f9b Mon Sep 17 00:00:00 2001 From: SamGondelman <samuel_gondelman@alumni.brown.edu> Date: Mon, 6 Aug 2018 15:49:52 -0700 Subject: [PATCH] parabola and particle shader fixes --- .../src/textured_particle.slv | 2 +- .../src/procedural/proceduralSkybox.slf | 3 --- libraries/render-utils/src/parabola.slv | 22 +++++++++++-------- .../render/src/render/DrawSceneOctree.cpp | 19 ---------------- libraries/render/src/render/DrawStatus.cpp | 7 ------ 5 files changed, 14 insertions(+), 39 deletions(-) diff --git a/libraries/entities-renderer/src/textured_particle.slv b/libraries/entities-renderer/src/textured_particle.slv index 60bca6e9bd..3eacaec3b5 100644 --- a/libraries/entities-renderer/src/textured_particle.slv +++ b/libraries/entities-renderer/src/textured_particle.slv @@ -149,7 +149,7 @@ void main(void) { vec3 UP = vec3(0, 1, 0); vec3 modelUpWorld; <$transformModelToWorldDir(cam, obj, UP, modelUpWorld)$> - vec3 upWorld = mix(UP, normalize(modelUpWorld), particle.rotateWithEntity); + vec3 upWorld = mix(UP, normalize(modelUpWorld), float(particle.rotateWithEntity)); vec3 upEye = normalize(view3 * upWorld); vec3 FORWARD = vec3(0, 0, -1); vec3 particleRight = normalize(cross(FORWARD, upEye)); diff --git a/libraries/procedural/src/procedural/proceduralSkybox.slf b/libraries/procedural/src/procedural/proceduralSkybox.slf index 9960698ff0..e18b7abef6 100644 --- a/libraries/procedural/src/procedural/proceduralSkybox.slf +++ b/libraries/procedural/src/procedural/proceduralSkybox.slf @@ -39,7 +39,4 @@ void main(void) { // Procedural Shaders are expected to be Gamma corrected so let's bring back the RGB in linear space for the rest of the pipeline color = pow(color, vec3(2.2)); _fragColor = vec4(color, 0.0); - - // FIXME: scribe does not yet scrub out else statements - return; } diff --git a/libraries/render-utils/src/parabola.slv b/libraries/render-utils/src/parabola.slv index 50b5999450..0948b2ab47 100644 --- a/libraries/render-utils/src/parabola.slv +++ b/libraries/render-utils/src/parabola.slv @@ -12,7 +12,7 @@ <@include gpu/Transform.slh@> <$declareStandardTransform()$> -layout(std140, binding=0) uniform parabolaData { +struct ParabolaData { vec3 velocity; float parabolicDistance; vec3 acceleration; @@ -20,34 +20,38 @@ layout(std140, binding=0) uniform parabolaData { vec4 color; int numSections; ivec3 spare; +} + +layout(std140, binding=0) uniform parabolaData { + ParabolaData _parabolaData; }; layout(location=0) out vec4 _color; void main(void) { - _color = color; + _color = _parabolaData.color; - float t = parabolicDistance * (float(gl_VertexID / 2) / float(numSections)); + float t = _parabolaData.parabolicDistance * (float(gl_VertexID / 2) / float(_parabolaData.numSections)); - vec4 pos = vec4(velocity * t + 0.5 * acceleration * t * t, 1); + vec4 pos = vec4(_parabolaData.velocity * t + 0.5 * _parabolaData.acceleration * t * t, 1); const float EPSILON = 0.00001; vec4 normal; TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); - if (dot(acceleration, acceleration) < EPSILON) { + if (dot(_parabolaData.acceleration, _parabolaData.acceleration) < EPSILON) { // Handle case where acceleration == (0, 0, 0) vec3 eyeUp = vec3(0, 1, 0); vec3 worldUp; <$transformEyeToWorldDir(cam, eyeUp, worldUp)$> - normal = vec4(normalize(cross(velocity, worldUp)), 0); + normal = vec4(normalize(cross(_parabolaData.velocity, worldUp)), 0); } else { - normal = vec4(normalize(cross(velocity, acceleration)), 0); + normal = vec4(normalize(cross(_parabolaData.velocity, _parabolaData.acceleration)), 0); } if (gl_VertexID % 2 == 0) { - pos += 0.5 * width * normal; + pos += 0.5 * _parabolaData.width * normal; } else { - pos -= 0.5 * width * normal; + pos -= 0.5 * _parabolaData.width * normal; } <$transformModelToClipPos(cam, obj, pos, gl_Position)$> diff --git a/libraries/render/src/render/DrawSceneOctree.cpp b/libraries/render/src/render/DrawSceneOctree.cpp index b8014b4e4f..f733fa5eb1 100644 --- a/libraries/render/src/render/DrawSceneOctree.cpp +++ b/libraries/render/src/render/DrawSceneOctree.cpp @@ -142,10 +142,6 @@ const gpu::PipelinePointer DrawItemSelection::getDrawItemBoundPipeline() { if (!_drawItemBoundPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawItemBounds); - //_drawItemBoundPosLoc = program->getUniforms().findLocation("inBoundPos"); - //_drawItemBoundDimLoc = program->getUniforms().findLocation("inBoundDim"); - //_drawCellLocationLoc = program->getUniforms().findLocation("inCellLocation"); - auto state = std::make_shared<gpu::State>(); state->setDepthTest(true, false, gpu::LESS_EQUAL); @@ -194,10 +190,6 @@ void DrawItemSelection::run(const RenderContextPointer& renderContext, const Ite auto itemCell = scene->getSpatialTree().getCellLocation(item.getCell()); glm::ivec4 cellLocation(0, 0, 0, itemCell.depth); - //batch._glUniform4iv(_drawCellLocationLoc, 1, ((const int*)(&cellLocation))); - //batch._glUniform3fv(_drawItemBoundPosLoc, 1, (const float*)(&itemBound.getCorner())); - //batch._glUniform3fv(_drawItemBoundDimLoc, 1, (const float*)(&itemBound.getScale())); - batch.draw(gpu::LINES, 24, 0); } } @@ -209,10 +201,6 @@ void DrawItemSelection::run(const RenderContextPointer& renderContext, const Ite auto itemCell = scene->getSpatialTree().getCellLocation(item.getCell()); glm::ivec4 cellLocation(0, 0, 1, itemCell.depth); - //batch._glUniform4iv(_drawCellLocationLoc, 1, ((const int*)(&cellLocation))); - //batch._glUniform3fv(_drawItemBoundPosLoc, 1, (const float*)(&itemBound.getCorner())); - //batch._glUniform3fv(_drawItemBoundDimLoc, 1, (const float*)(&itemBound.getScale())); - batch.draw(gpu::LINES, 24, 0); } } @@ -224,10 +212,6 @@ void DrawItemSelection::run(const RenderContextPointer& renderContext, const Ite auto itemCell = scene->getSpatialTree().getCellLocation(item.getCell()); glm::ivec4 cellLocation(0, 0, 0, itemCell.depth); - //batch._glUniform4iv(_drawCellLocationLoc, 1, ((const int*)(&cellLocation))); - //batch._glUniform3fv(_drawItemBoundPosLoc, 1, (const float*)(&itemBound.getCorner())); - //batch._glUniform3fv(_drawItemBoundDimLoc, 1, (const float*)(&itemBound.getScale())); - batch.draw(gpu::LINES, 24, 0); } } @@ -238,9 +222,6 @@ void DrawItemSelection::run(const RenderContextPointer& renderContext, const Ite auto itemBound = item.getBound(); auto itemCell = scene->getSpatialTree().getCellLocation(item.getCell()); glm::ivec4 cellLocation(0, 0, 1, itemCell.depth); - //batch._glUniform4iv(_drawCellLocationLoc, 1, ((const int*)(&cellLocation))); - //batch._glUniform3fv(_drawItemBoundPosLoc, 1, (const float*)(&itemBound.getCorner())); - //batch._glUniform3fv(_drawItemBoundDimLoc, 1, (const float*)(&itemBound.getScale())); batch.draw(gpu::LINES, 24, 0); } diff --git a/libraries/render/src/render/DrawStatus.cpp b/libraries/render/src/render/DrawStatus.cpp index 2894a85a30..1c5ab27507 100644 --- a/libraries/render/src/render/DrawStatus.cpp +++ b/libraries/render/src/render/DrawStatus.cpp @@ -33,9 +33,6 @@ void DrawStatusConfig::dirtyHelper() { const gpu::PipelinePointer DrawStatus::getDrawItemBoundsPipeline() { if (!_drawItemBoundsPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawItemBounds); - //_drawItemBoundPosLoc = program->getUniforms().findLocation("inBoundPos"); - //_drawItemBoundDimLoc = program->getUniforms().findLocation("inBoundDim"); - //_drawItemCellLocLoc = program->getUniforms().findLocation("inCellLocation"); auto state = std::make_shared<gpu::State>(); @@ -55,10 +52,6 @@ const gpu::PipelinePointer DrawStatus::getDrawItemBoundsPipeline() { const gpu::PipelinePointer DrawStatus::getDrawItemStatusPipeline() { if (!_drawItemStatusPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::blurGaussianDepthAwareV); - //_drawItemStatusPosLoc = program->getUniforms().findLocation(""); - //_drawItemStatusDimLoc = program->getUniforms().findLocation(""); - //_drawItemStatusValue0Loc = program->getUniforms().findLocation(""); - //_drawItemStatusValue1Loc = program->getUniforms().findLocation(""); auto state = std::make_shared<gpu::State>();