Showing the changes to libraries/render-utils/src/DebugDeferredBuffer.cpp (1 of 298 files). Show all
Unified · Split
| @@ -33,7 +33,10 @@ enum Slots { · 32 unmodified lines | |||
| 33 | Specular, | 33 | Specular, |
| 34 | Depth, | 34 | Depth, |
| 35 | Lighting, | 35 | Lighting, |
| 36 | Shadow | 36 | Shadow, |
| 37 | Pyramid, | ||
| 38 | AmbientOcclusion, | ||
| 39 | AmbientOcclusionBlurred | ||
| 37 | }; | 40 | }; |
| 38 | 41 | ||
| 39 | static const std::string DEFAULT_DIFFUSE_SHADER { | 42 | static const std::string DEFAULT_DIFFUSE_SHADER { |
| @@ -41,11 +44,7 @@ static const std::string DEFAULT_DIFFUSE_SHADER { · 1 unmodified line | |||
| 41 | " return vec4(pow(texture(diffuseMap, uv).xyz, vec3(1.0 / 2.2)), 1.0);" | 44 | " return vec4(pow(texture(diffuseMap, uv).xyz, vec3(1.0 / 2.2)), 1.0);" |
| 42 | " }" | 45 | " }" |
| 43 | }; | 46 | }; |
| 44 | static const std::string DEFAULT_ALPHA_SHADER { | 47 | |
| 45 | "vec4 getFragmentColor() {" | ||
| 46 | " return vec4(vec3(texture(diffuseMap, uv).a), 1.0);" | ||
| 47 | " }" | ||
| 48 | }; | ||
| 49 | static const std::string DEFAULT_SPECULAR_SHADER { | 48 | static const std::string DEFAULT_SPECULAR_SHADER { |
| 50 | "vec4 getFragmentColor() {" | 49 | "vec4 getFragmentColor() {" |
| 51 | " return vec4(texture(specularMap, uv).xyz, 1.0);" | 50 | " return vec4(texture(specularMap, uv).xyz, 1.0);" |
| @@ -58,7 +57,7 @@ static const std::string DEFAULT_ROUGHNESS_SHADER { · 6 unmodified lines | |||
| 58 | }; | 57 | }; |
| 59 | static const std::string DEFAULT_NORMAL_SHADER { | 58 | static const std::string DEFAULT_NORMAL_SHADER { |
| 60 | "vec4 getFragmentColor() {" | 59 | "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);" |
| 62 | " }" | 61 | " }" |
| 63 | }; | 62 | }; |
| 64 | static const std::string DEFAULT_DEPTH_SHADER { | 63 | static const std::string DEFAULT_DEPTH_SHADER { |
| @@ -83,6 +82,27 @@ static const std::string DEFAULT_SHADOW_SHADER { · 18 unmodified lines | |||
| 83 | " return vec4(vec3(0.0), 1.0);" | 82 | " return vec4(vec3(0.0), 1.0);" |
| 84 | " }" | 83 | " }" |
| 85 | }; | 84 | }; |
| 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 | |||
| 86 | static const std::string DEFAULT_CUSTOM_SHADER { | 106 | static const std::string DEFAULT_CUSTOM_SHADER { |
| 87 | "vec4 getFragmentColor() {" | 107 | "vec4 getFragmentColor() {" |
| 88 | " return vec4(1.0, 0.0, 0.0, 1.0);" | 108 | " 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 | |||
| 113 | switch (mode) { | 133 | switch (mode) { |
| 114 | case DiffuseMode: | 134 | case DiffuseMode: |
| 115 | return DEFAULT_DIFFUSE_SHADER; | 135 | return DEFAULT_DIFFUSE_SHADER; |
| 116 | case AlphaMode: | ||
| 117 | return DEFAULT_ALPHA_SHADER; | ||
| 118 | case SpecularMode: | 136 | case SpecularMode: |
| 119 | return DEFAULT_SPECULAR_SHADER; | 137 | return DEFAULT_SPECULAR_SHADER; |
| 120 | case RoughnessMode: | 138 | case RoughnessMode: |
| @@ -127,6 +145,12 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Modes mode, std::string cus · 6 unmodified lines | |||
| 127 | return DEFAULT_LIGHTING_SHADER; | 145 | return DEFAULT_LIGHTING_SHADER; |
| 128 | case ShadowMode: | 146 | case ShadowMode: |
| 129 | return DEFAULT_SHADOW_SHADER; | 147 | 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; | ||
| 130 | case CustomMode: | 154 | case CustomMode: |
| 131 | return getFileContent(customFile, DEFAULT_CUSTOM_SHADER); | 155 | return getFileContent(customFile, DEFAULT_CUSTOM_SHADER); |
| 132 | } | 156 | } |
| @@ -175,6 +199,9 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Modes mode, std::st · 42 unmodified lines | |||
| 175 | slotBindings.insert(gpu::Shader::Binding("depthMap", Depth)); | 199 | slotBindings.insert(gpu::Shader::Binding("depthMap", Depth)); |
| 176 | slotBindings.insert(gpu::Shader::Binding("lightingMap", Lighting)); | 200 | slotBindings.insert(gpu::Shader::Binding("lightingMap", Lighting)); |
| 177 | slotBindings.insert(gpu::Shader::Binding("shadowMap", Shadow)); | 201 | 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)); | ||
| 178 | gpu::Shader::makeProgram(*program, slotBindings); | 205 | gpu::Shader::makeProgram(*program, slotBindings); |
| 179 | 206 | ||
| 180 | auto pipeline = gpu::Pipeline::create(program, std::make_shared<gpu::State>()); | 207 | 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 | |||
| 231 | batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture()); | 258 | batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture()); |
| 232 | batch.setResourceTexture(Lighting, framebufferCache->getLightingTexture()); | 259 | batch.setResourceTexture(Lighting, framebufferCache->getLightingTexture()); |
| 233 | batch.setResourceTexture(Shadow, lightStage.lights[0]->shadow.framebuffer->getDepthStencilBuffer()); | 260 | 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 | |||
| 235 | const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f); | 265 | const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f); |
| 236 | const glm::vec2 bottomLeft(renderContext->_deferredDebugSize.x, renderContext->_deferredDebugSize.y); | 266 | const glm::vec2 bottomLeft(renderContext->_deferredDebugSize.x, renderContext->_deferredDebugSize.y); |
| 237 | const glm::vec2 topRight(renderContext->_deferredDebugSize.z, renderContext->_deferredDebugSize.w); | 267 | const glm::vec2 topRight(renderContext->_deferredDebugSize.z, renderContext->_deferredDebugSize.w); |