mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-06 18:23:29 +02:00
Fixed android compilation error and removed _glUniformi call
This commit is contained in:
parent
1a5c382d88
commit
51fe60ec45
5 changed files with 57 additions and 21 deletions
|
@ -268,6 +268,7 @@ GLsizei getCompressedImageSize(int width, int height, GLenum internalFormat) {
|
|||
void GLESFixedAllocationTexture::allocateStorage() const {
|
||||
const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat());
|
||||
const auto numMips = _gpuObject.getNumMips();
|
||||
const auto numSlices = _gpuObject.getNumSlices();
|
||||
|
||||
// glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
||||
for (GLint level = 0; level < numMips; level++) {
|
||||
|
|
|
@ -60,7 +60,8 @@ enum TextureSlot {
|
|||
enum ParamSlot {
|
||||
CameraCorrection = 0,
|
||||
DeferredFrameTransform,
|
||||
ShadowTransform
|
||||
ShadowTransform,
|
||||
DebugParametersBuffer
|
||||
};
|
||||
|
||||
static const std::string DEFAULT_ALBEDO_SHADER {
|
||||
|
@ -139,13 +140,11 @@ static const std::string DEFAULT_LIGHTING_SHADER {
|
|||
" }"
|
||||
};
|
||||
|
||||
static const std::string DEFAULT_SHADOW_SHADER{
|
||||
"uniform sampler2DArrayShadow shadowMaps;"
|
||||
"uniform int shadowCascadeIndex;"
|
||||
static const std::string DEFAULT_SHADOW_DEPTH_SHADER{
|
||||
"vec4 getFragmentColor() {"
|
||||
" for (int i = 255; i >= 0; --i) {"
|
||||
" float depth = i / 255.0;"
|
||||
" if (texture(shadowMaps, vec4(uv, shadowCascadeIndex, depth)) > 0.5) {"
|
||||
" if (texture(shadowMaps, vec4(uv, parameters._shadowCascadeIndex, depth)) > 0.5) {"
|
||||
" return vec4(vec3(depth), 1.0);"
|
||||
" }"
|
||||
" }"
|
||||
|
@ -324,7 +323,7 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, std::string cust
|
|||
case ShadowCascade1Mode:
|
||||
case ShadowCascade2Mode:
|
||||
case ShadowCascade3Mode:
|
||||
return DEFAULT_SHADOW_SHADER;
|
||||
return DEFAULT_SHADOW_DEPTH_SHADER;
|
||||
case ShadowCascadeIndicesMode:
|
||||
return DEFAULT_SHADOW_CASCADE_SHADER;
|
||||
case LinearDepthMode:
|
||||
|
@ -397,6 +396,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str
|
|||
slotBindings.insert(gpu::Shader::Binding("cameraCorrectionBuffer", CameraCorrection));
|
||||
slotBindings.insert(gpu::Shader::Binding("deferredFrameTransformBuffer", DeferredFrameTransform));
|
||||
slotBindings.insert(gpu::Shader::Binding("shadowTransformBuffer", ShadowTransform));
|
||||
slotBindings.insert(gpu::Shader::Binding("parametersBuffer", DebugParametersBuffer));
|
||||
|
||||
slotBindings.insert(gpu::Shader::Binding("albedoMap", Albedo));
|
||||
slotBindings.insert(gpu::Shader::Binding("normalMap", Normal));
|
||||
|
@ -433,8 +433,11 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str
|
|||
}
|
||||
|
||||
void DebugDeferredBuffer::configure(const Config& config) {
|
||||
auto& parameters = _parameters.edit();
|
||||
|
||||
_mode = (Mode)config.mode;
|
||||
_size = config.size;
|
||||
parameters._shadowCascadeIndex = glm::clamp(_mode - Mode::ShadowCascade0Mode, 0, (int)SHADOW_CASCADE_MAX_COUNT - 1);
|
||||
}
|
||||
|
||||
void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const Inputs& inputs) {
|
||||
|
@ -484,18 +487,15 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I
|
|||
batch.setResourceTexture(Velocity, velocityFramebuffer->getVelocityTexture());
|
||||
}
|
||||
|
||||
batch.setUniformBuffer(DebugParametersBuffer, _parameters);
|
||||
|
||||
auto lightStage = renderContext->_scene->getStage<LightStage>();
|
||||
assert(lightStage);
|
||||
assert(lightStage->getNumLights() > 0);
|
||||
auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow();
|
||||
const auto& globalShadow = lightAndShadow.second;
|
||||
if (globalShadow) {
|
||||
const auto cascadeIndex = glm::clamp(_mode - Mode::ShadowCascade0Mode, 0, (int)globalShadow->getCascadeCount() - 1);
|
||||
const auto cascadeIndexLocation = pipeline->getProgram()->getUniforms().findLocation("shadowCascadeIndex");
|
||||
batch.setResourceTexture(Shadow, globalShadow->map);
|
||||
if (cascadeIndexLocation >= 0) {
|
||||
batch._glUniform1i(cascadeIndexLocation, cascadeIndex);
|
||||
}
|
||||
batch.setUniformBuffer(ShadowTransform, globalShadow->getBuffer());
|
||||
batch.setUniformBuffer(DeferredFrameTransform, frameTransform->getFrameTransformBuffer());
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
DebugDeferredBufferConfig() : render::Job::Config(false) {}
|
||||
|
||||
void setMode(int newMode);
|
||||
|
||||
|
||||
int mode{ 0 };
|
||||
glm::vec4 size{ 0.0f, -1.0f, 1.0f, 1.0f };
|
||||
signals:
|
||||
|
@ -39,20 +39,26 @@ signals:
|
|||
|
||||
class DebugDeferredBuffer {
|
||||
public:
|
||||
using Inputs = render::VaryingSet6<DeferredFramebufferPointer, LinearDepthFramebufferPointer, SurfaceGeometryFramebufferPointer, AmbientOcclusionFramebufferPointer, VelocityFramebufferPointer, DeferredFrameTransformPointer>;
|
||||
using Inputs = render::VaryingSet6<DeferredFramebufferPointer,
|
||||
LinearDepthFramebufferPointer,
|
||||
SurfaceGeometryFramebufferPointer,
|
||||
AmbientOcclusionFramebufferPointer,
|
||||
VelocityFramebufferPointer,
|
||||
DeferredFrameTransformPointer>;
|
||||
using Config = DebugDeferredBufferConfig;
|
||||
using JobModel = render::Job::ModelI<DebugDeferredBuffer, Inputs, Config>;
|
||||
|
||||
|
||||
DebugDeferredBuffer();
|
||||
~DebugDeferredBuffer();
|
||||
|
||||
void configure(const Config& config);
|
||||
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
|
||||
|
||||
|
||||
protected:
|
||||
friend class DebugDeferredBufferConfig;
|
||||
|
||||
enum Mode : uint8_t {
|
||||
enum Mode : uint8_t
|
||||
{
|
||||
// Use Mode suffix to avoid collisions
|
||||
Off = 0,
|
||||
DepthMode,
|
||||
|
@ -83,7 +89,7 @@ protected:
|
|||
AmbientOcclusionMode,
|
||||
AmbientOcclusionBlurredMode,
|
||||
VelocityMode,
|
||||
CustomMode, // Needs to stay last
|
||||
CustomMode, // Needs to stay last
|
||||
|
||||
NumModes,
|
||||
};
|
||||
|
@ -92,20 +98,25 @@ private:
|
|||
Mode _mode{ Off };
|
||||
glm::vec4 _size;
|
||||
|
||||
#include "debug_deferred_buffer_shared.slh"
|
||||
|
||||
using ParametersBuffer = gpu::StructBuffer<DebugParameters>;
|
||||
|
||||
struct CustomPipeline {
|
||||
gpu::PipelinePointer pipeline;
|
||||
mutable QFileInfo info;
|
||||
};
|
||||
using StandardPipelines = std::array<gpu::PipelinePointer, NumModes>;
|
||||
using CustomPipelines = std::unordered_map<std::string, CustomPipeline>;
|
||||
|
||||
|
||||
bool pipelineNeedsUpdate(Mode mode, std::string customFile = std::string()) const;
|
||||
const gpu::PipelinePointer& getPipeline(Mode mode, std::string customFile = std::string());
|
||||
std::string getShaderSourceCode(Mode mode, std::string customFile = std::string());
|
||||
|
||||
|
||||
ParametersBuffer _parameters;
|
||||
StandardPipelines _pipelines;
|
||||
CustomPipelines _customPipelines;
|
||||
int _geometryId { 0 };
|
||||
int _geometryId{ 0 };
|
||||
};
|
||||
|
||||
#endif // hifi_DebugDeferredBuffer_h
|
||||
#endif // hifi_DebugDeferredBuffer_h
|
|
@ -23,11 +23,18 @@ uniform sampler2D occlusionMap;
|
|||
uniform sampler2D occlusionBlurredMap;
|
||||
uniform sampler2D scatteringMap;
|
||||
uniform sampler2D velocityMap;
|
||||
uniform sampler2DArrayShadow shadowMaps;
|
||||
|
||||
<@include ShadowCore.slh@>
|
||||
|
||||
<$declareDeferredCurvature()$>
|
||||
|
||||
<@include debug_deferred_buffer_shared.slh@>
|
||||
|
||||
layout(std140) uniform parametersBuffer {
|
||||
DebugParameters parameters;
|
||||
};
|
||||
|
||||
float curvatureAO(float k) {
|
||||
return 1.0f - (0.0022f * k * k) + (0.0776f * k) + 0.7369f;
|
||||
}
|
||||
|
|
17
libraries/render-utils/src/debug_deferred_buffer_shared.slh
Normal file
17
libraries/render-utils/src/debug_deferred_buffer_shared.slh
Normal file
|
@ -0,0 +1,17 @@
|
|||
// glsl / C++ compatible source as interface for FadeEffect
|
||||
#ifdef __cplusplus
|
||||
# define INT32 glm::int32
|
||||
#else
|
||||
# define INT32 int
|
||||
#endif
|
||||
|
||||
struct DebugParameters
|
||||
{
|
||||
INT32 _shadowCascadeIndex;
|
||||
};
|
||||
|
||||
// <@if 1@>
|
||||
// Trigger Scribe include
|
||||
// <@endif@> <!def that !>
|
||||
//
|
||||
|
Loading…
Reference in a new issue