History

Merge branch 'master' of github.com:highfidelity/hifi into flag/shadows

Zach Pomerantz committed 10 years ago

Commit dee8e0b2 parents 0c798c0 c9d9bbe298 files · +9586 −6878Browse files

Showing the changes to libraries/render-utils/src/DebugDeferredBuffer.cpp (1 of 298 files). Show all

Unified · Split

libraries/render-utils/src/DebugDeferredBuffer.cpp+40−10
@@ -33,7 +33,10 @@ enum Slots { · 32 unmodified lines
3333 Specular,
3434 Depth,
3535 Lighting,
36− Shadow
36+ Shadow,
37+ Pyramid,
38+ AmbientOcclusion,
39+ AmbientOcclusionBlurred
3740 };
3841
3942 static const std::string DEFAULT_DIFFUSE_SHADER {
@@ -41,11 +44,7 @@ static const std::string DEFAULT_DIFFUSE_SHADER { · 1 unmodified line
4144 " return vec4(pow(texture(diffuseMap, uv).xyz, vec3(1.0 / 2.2)), 1.0);"
4245 " }"
4346 };
44−static const std::string DEFAULT_ALPHA_SHADER {
45− "vec4 getFragmentColor() {"
46− " return vec4(vec3(texture(diffuseMap, uv).a), 1.0);"
47− " }"
48−};
47+
4948 static const std::string DEFAULT_SPECULAR_SHADER {
5049 "vec4 getFragmentColor() {"
5150 " return vec4(texture(specularMap, uv).xyz, 1.0);"
@@ -58,7 +57,7 @@ static const std::string DEFAULT_ROUGHNESS_SHADER { · 6 unmodified lines
5857 };
5958 static const std::string DEFAULT_NORMAL_SHADER {
6059 "vec4 getFragmentColor() {"
61− " return vec4(normalize(texture(normalMap, uv).xyz), 1.0);"
60+ " return vec4(normalize(texture(normalMap, uv).xyz * 2.0 - vec3(1.0)), 1.0);"
6261 " }"
6362 };
6463 static const std::string DEFAULT_DEPTH_SHADER {
@@ -83,6 +82,27 @@ static const std::string DEFAULT_SHADOW_SHADER { · 18 unmodified lines
8382 " return vec4(vec3(0.0), 1.0);"
8483 " }"
8584 };
85+
86+static const std::string DEFAULT_PYRAMID_DEPTH_SHADER {
87+ "vec4 getFragmentColor() {"
88+ " return vec4(vec3(1.0 - texture(pyramidMap, uv).x * 0.01), 1.0);"
89+ //" return vec4(vec3(1.0 - textureLod(pyramidMap, uv, 3).x * 0.01), 1.0);"
90+ " }"
91+};
92+
93+static const std::string DEFAULT_AMBIENT_OCCLUSION_SHADER{
94+ "vec4 getFragmentColor() {"
95+ " return vec4(vec3(texture(occlusionMap, uv).x), 1.0);"
96+ // When drawing color " return vec4(vec3(texture(occlusionMap, uv).xyz), 1.0);"
97+ // when drawing normal " return vec4(normalize(texture(occlusionMap, uv).xyz * 2.0 - vec3(1.0)), 1.0);"
98+ " }"
99+};
100+static const std::string DEFAULT_AMBIENT_OCCLUSION_BLURRED_SHADER{
101+ "vec4 getFragmentColor() {"
102+ " return vec4(vec3(texture(occlusionBlurredMap, uv).x), 1.0);"
103+ " }"
104+};
105+
86106 static const std::string DEFAULT_CUSTOM_SHADER {
87107 "vec4 getFragmentColor() {"
88108 " return vec4(1.0, 0.0, 0.0, 1.0);"
@@ -113,8 +133,6 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Modes mode, std::string cus · 24 unmodified lines
113133 switch (mode) {
114134 case DiffuseMode:
115135 return DEFAULT_DIFFUSE_SHADER;
116− case AlphaMode:
117− return DEFAULT_ALPHA_SHADER;
118136 case SpecularMode:
119137 return DEFAULT_SPECULAR_SHADER;
120138 case RoughnessMode:
@@ -127,6 +145,12 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Modes mode, std::string cus · 6 unmodified lines
127145 return DEFAULT_LIGHTING_SHADER;
128146 case ShadowMode:
129147 return DEFAULT_SHADOW_SHADER;
148+ case PyramidDepthMode:
149+ return DEFAULT_PYRAMID_DEPTH_SHADER;
150+ case AmbientOcclusionMode:
151+ return DEFAULT_AMBIENT_OCCLUSION_SHADER;
152+ case AmbientOcclusionBlurredMode:
153+ return DEFAULT_AMBIENT_OCCLUSION_BLURRED_SHADER;
130154 case CustomMode:
131155 return getFileContent(customFile, DEFAULT_CUSTOM_SHADER);
132156 }
@@ -175,6 +199,9 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Modes mode, std::st · 42 unmodified lines
175199 slotBindings.insert(gpu::Shader::Binding("depthMap", Depth));
176200 slotBindings.insert(gpu::Shader::Binding("lightingMap", Lighting));
177201 slotBindings.insert(gpu::Shader::Binding("shadowMap", Shadow));
202+ slotBindings.insert(gpu::Shader::Binding("pyramidMap", Pyramid));
203+ slotBindings.insert(gpu::Shader::Binding("occlusionMap", AmbientOcclusion));
204+ slotBindings.insert(gpu::Shader::Binding("occlusionBlurredMap", AmbientOcclusionBlurred));
178205 gpu::Shader::makeProgram(*program, slotBindings);
179206
180207 auto pipeline = gpu::Pipeline::create(program, std::make_shared<gpu::State>());
@@ -231,7 +258,10 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren · 50 unmodified lines
231258 batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture());
232259 batch.setResourceTexture(Lighting, framebufferCache->getLightingTexture());
233260 batch.setResourceTexture(Shadow, lightStage.lights[0]->shadow.framebuffer->getDepthStencilBuffer());
234−
261+ batch.setResourceTexture(Pyramid, framebufferCache->getDepthPyramidTexture());
262+ batch.setResourceTexture(AmbientOcclusion, framebufferCache->getOcclusionTexture());
263+ batch.setResourceTexture(AmbientOcclusionBlurred, framebufferCache->getOcclusionBlurredTexture());
264+
235265 const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f);
236266 const glm::vec2 bottomLeft(renderContext->_deferredDebugSize.x, renderContext->_deferredDebugSize.y);
237267 const glm::vec2 topRight(renderContext->_deferredDebugSize.z, renderContext->_deferredDebugSize.w);