From 4202e60ac397e295ffef3a3284181a20b2f8c1e2 Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 26 Apr 2016 18:20:15 -0700 Subject: [PATCH] trying to add the skymap on translucents --- libraries/render-utils/src/DeferredGlobalLight.slh | 12 ++++++++++++ libraries/render-utils/src/RenderPipelines.cpp | 2 +- libraries/render-utils/src/model_translucent.slf | 5 +++-- libraries/render/src/render/ShapePipeline.cpp | 2 ++ libraries/render/src/render/ShapePipeline.h | 2 ++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/DeferredGlobalLight.slh b/libraries/render-utils/src/DeferredGlobalLight.slh index c87aa1cee2..5a429ff7c4 100755 --- a/libraries/render-utils/src/DeferredGlobalLight.slh +++ b/libraries/render-utils/src/DeferredGlobalLight.slh @@ -125,4 +125,16 @@ vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscur } <@endfunc@> + + +<@func declareEvalGlobalLightColor()@> + +<$declareEvalSkyboxGlobalColor()$> + +vec3 evalGlobalLightColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 emissive, float roughness) { + return evalSkyboxGlobalColor(invViewMat, shadowAttenuation, obscurance, position, normal, albedo, metallic, emissive, roughness); +} +<@endfunc@> + + <@endif@> diff --git a/libraries/render-utils/src/RenderPipelines.cpp b/libraries/render-utils/src/RenderPipelines.cpp index aa0f9dc7d9..4452872108 100644 --- a/libraries/render-utils/src/RenderPipelines.cpp +++ b/libraries/render-utils/src/RenderPipelines.cpp @@ -98,7 +98,7 @@ void lightBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) { if (pipeline.locations->lightBufferUnit >= 0) { DependencyManager::get()->setupKeyLightBatch(batch, pipeline.locations->lightBufferUnit, - -1); + pipeline.locations->lightAmbientMapUnit); } } diff --git a/libraries/render-utils/src/model_translucent.slf b/libraries/render-utils/src/model_translucent.slf index 12a7b9299f..f70d922a67 100755 --- a/libraries/render-utils/src/model_translucent.slf +++ b/libraries/render-utils/src/model_translucent.slf @@ -15,7 +15,8 @@ <@include model/Material.slh@> <@include DeferredGlobalLight.slh@> -<$declareEvalAmbientSphereGlobalColor()$> + +<$declareEvalGlobalLightColor()$> <@include gpu/Transform.slh@> <$declareStandardCameraTransform()$> @@ -58,7 +59,7 @@ void main(void) { TransformCamera cam = getTransformCamera(); - _fragColor = vec4(evalAmbientSphereGlobalColor( + _fragColor = vec4(evalSkyboxGlobalColor( cam._viewInverse, 1.0, 1.0, diff --git a/libraries/render/src/render/ShapePipeline.cpp b/libraries/render/src/render/ShapePipeline.cpp index 6974a7e385..766d899465 100644 --- a/libraries/render/src/render/ShapePipeline.cpp +++ b/libraries/render/src/render/ShapePipeline.cpp @@ -60,6 +60,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p slotBindings.insert(gpu::Shader::Binding(std::string("emissiveMap"), Slot::EMISSIVE_LIGHTMAP_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("occlusionMap"), Slot::OCCLUSION_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), Slot::LIGHT_BUFFER)); + slotBindings.insert(gpu::Shader::Binding(std::string("skyboxMap"), Slot::LIGHT_AMBIENT_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), Slot::NORMAL_FITTING_MAP)); gpu::Shader::makeProgram(*program, slotBindings); @@ -77,6 +78,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p locations->skinClusterBufferUnit = program->getBuffers().findLocation("skinClusterBuffer"); locations->materialBufferUnit = program->getBuffers().findLocation("materialBuffer"); locations->lightBufferUnit = program->getBuffers().findLocation("lightBuffer"); + locations->lightAmbientMapUnit = program->getBuffers().findLocation("skyboxMap"); ShapeKey key{filter._flags}; auto gpuPipeline = gpu::Pipeline::create(program, state); diff --git a/libraries/render/src/render/ShapePipeline.h b/libraries/render/src/render/ShapePipeline.h index 0f795aadde..876e056a9a 100644 --- a/libraries/render/src/render/ShapePipeline.h +++ b/libraries/render/src/render/ShapePipeline.h @@ -203,6 +203,7 @@ public: static const int OCCLUSION_MAP = 5; static const int LIGHT_BUFFER = 4; + static const int LIGHT_AMBIENT_MAP = 6; static const int NORMAL_FITTING_MAP = 10; }; @@ -220,6 +221,7 @@ public: int skinClusterBufferUnit; int materialBufferUnit; int lightBufferUnit; + int lightAmbientMapUnit; }; using LocationsPointer = std::shared_ptr;