mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:36:57 +02:00
Adding the support for the subregion in the blur passes to apply it correctly to mini mirror
This commit is contained in:
parent
f6671b34fa
commit
b9a2b2778e
6 changed files with 26 additions and 5 deletions
|
@ -28,8 +28,8 @@ void main(void) {
|
||||||
|
|
||||||
_texCoord0 = (pos.xy + 1) * 0.5;
|
_texCoord0 = (pos.xy + 1) * 0.5;
|
||||||
|
|
||||||
_texCoord0 += texcoordFrameTransform.xy;
|
|
||||||
_texCoord0 *= texcoordFrameTransform.zw;
|
_texCoord0 *= texcoordFrameTransform.zw;
|
||||||
|
_texCoord0 += texcoordFrameTransform.xy;
|
||||||
|
|
||||||
gl_Position = pos;
|
gl_Position = pos;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ void main(void) {
|
||||||
|
|
||||||
// Grab the fragment data from the uv
|
// Grab the fragment data from the uv
|
||||||
vec2 texCoord = _texCoord0.st / _texCoord0.q;
|
vec2 texCoord = _texCoord0.st / _texCoord0.q;
|
||||||
texCoord += texcoordFrameTransform.xy;
|
|
||||||
texCoord *= texcoordFrameTransform.zw;
|
texCoord *= texcoordFrameTransform.zw;
|
||||||
|
texCoord += texcoordFrameTransform.xy;
|
||||||
|
|
||||||
DeferredFragment frag = unpackDeferredFragment(deferredTransform, texCoord);
|
DeferredFragment frag = unpackDeferredFragment(deferredTransform, texCoord);
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ void main(void) {
|
||||||
|
|
||||||
// Grab the fragment data from the uv
|
// Grab the fragment data from the uv
|
||||||
vec2 texCoord = _texCoord0.st / _texCoord0.q;
|
vec2 texCoord = _texCoord0.st / _texCoord0.q;
|
||||||
texCoord += texcoordFrameTransform.xy;
|
|
||||||
texCoord *= texcoordFrameTransform.zw;
|
texCoord *= texcoordFrameTransform.zw;
|
||||||
|
texCoord += texcoordFrameTransform.xy;
|
||||||
|
|
||||||
DeferredFragment frag = unpackDeferredFragment(deferredTransform, texCoord);
|
DeferredFragment frag = unpackDeferredFragment(deferredTransform, texCoord);
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,13 @@ void BlurParams::setWidthHeight(int width, int height, bool isStereo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BlurParams::setTexcoordTransform(const glm::vec4 texcoordTransformViewport) {
|
||||||
|
auto texcoordTransform = _parametersBuffer.get<Params>().texcoordTransform;
|
||||||
|
if (texcoordTransformViewport != texcoordTransform) {
|
||||||
|
_parametersBuffer.edit<Params>().texcoordTransform = texcoordTransform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BlurParams::setFilterRadiusScale(float scale) {
|
void BlurParams::setFilterRadiusScale(float scale) {
|
||||||
auto filterInfo = _parametersBuffer.get<Params>().filterInfo;
|
auto filterInfo = _parametersBuffer.get<Params>().filterInfo;
|
||||||
if (scale != filterInfo.x) {
|
if (scale != filterInfo.x) {
|
||||||
|
@ -211,6 +218,8 @@ void BlurGaussian::run(const SceneContextPointer& sceneContext, const RenderCont
|
||||||
auto blurHPipeline = getBlurHPipeline();
|
auto blurHPipeline = getBlurHPipeline();
|
||||||
|
|
||||||
_parameters->setWidthHeight(args->_viewport.z, args->_viewport.w, args->_context->isStereo());
|
_parameters->setWidthHeight(args->_viewport.z, args->_viewport.w, args->_context->isStereo());
|
||||||
|
glm::ivec2 textureSize(blurringResources.sourceTexture->getDimensions());
|
||||||
|
_parameters->setTexcoordTransform(gpu::Framebuffer::evalSubregionTexcoordTransformCoefficients(textureSize, args->_viewport));
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
|
@ -320,6 +329,8 @@ void BlurGaussianDepthAware::run(const SceneContextPointer& sceneContext, const
|
||||||
auto blurHPipeline = getBlurHPipeline();
|
auto blurHPipeline = getBlurHPipeline();
|
||||||
|
|
||||||
_parameters->setWidthHeight(args->_viewport.z, args->_viewport.w, args->_context->isStereo());
|
_parameters->setWidthHeight(args->_viewport.z, args->_viewport.w, args->_context->isStereo());
|
||||||
|
glm::ivec2 textureSize(blurringResources.sourceTexture->getDimensions());
|
||||||
|
_parameters->setTexcoordTransform(gpu::Framebuffer::evalSubregionTexcoordTransformCoefficients(textureSize, args->_viewport));
|
||||||
_parameters->setDepthPerspective(args->getViewFrustum().getProjection()[1][1]);
|
_parameters->setDepthPerspective(args->getViewFrustum().getProjection()[1][1]);
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
|
|
|
@ -22,6 +22,8 @@ public:
|
||||||
|
|
||||||
void setWidthHeight(int width, int height, bool isStereo);
|
void setWidthHeight(int width, int height, bool isStereo);
|
||||||
|
|
||||||
|
void setTexcoordTransform(const glm::vec4 texcoordTransformViewport);
|
||||||
|
|
||||||
void setFilterRadiusScale(float scale);
|
void setFilterRadiusScale(float scale);
|
||||||
|
|
||||||
void setDepthPerspective(float oneOverTan2FOV);
|
void setDepthPerspective(float oneOverTan2FOV);
|
||||||
|
@ -33,6 +35,9 @@ public:
|
||||||
// Resolution info (width, height, inverse of width, inverse of height)
|
// Resolution info (width, height, inverse of width, inverse of height)
|
||||||
glm::vec4 resolutionInfo{ 0.0f, 0.0f, 0.0f, 0.0f };
|
glm::vec4 resolutionInfo{ 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
|
// Viewport to Texcoord info, if the region of the blur (viewport) is smaller than the full frame
|
||||||
|
glm::vec4 texcoordTransform{ 0.0f, 0.0f, 1.0f, 1.0f };
|
||||||
|
|
||||||
// Filter info (radius scale
|
// Filter info (radius scale
|
||||||
glm::vec4 filterInfo{ 1.0f, 0.0f, 0.0f, 0.0f };
|
glm::vec4 filterInfo{ 1.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ const float gaussianDistributionOffset[NUM_TAPS] = float[](
|
||||||
|
|
||||||
struct BlurParameters {
|
struct BlurParameters {
|
||||||
vec4 resolutionInfo;
|
vec4 resolutionInfo;
|
||||||
|
vec4 texcoordTransform;
|
||||||
vec4 filterInfo;
|
vec4 filterInfo;
|
||||||
vec4 depthInfo;
|
vec4 depthInfo;
|
||||||
vec4 stereoInfo;
|
vec4 stereoInfo;
|
||||||
|
@ -36,6 +37,10 @@ vec2 getViewportInvWidthHeight() {
|
||||||
return parameters.resolutionInfo.zw;
|
return parameters.resolutionInfo.zw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec2 evalTexcoordTransformed(vec2 texcoord) {
|
||||||
|
return (texcoord * parameters.texcoordTransform.zw + parameters.texcoordTransform.xy);
|
||||||
|
}
|
||||||
|
|
||||||
float getFilterScale() {
|
float getFilterScale() {
|
||||||
return parameters.filterInfo.x;
|
return parameters.filterInfo.x;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +64,7 @@ float getDepthPerspective() {
|
||||||
uniform sampler2D sourceMap;
|
uniform sampler2D sourceMap;
|
||||||
|
|
||||||
vec4 pixelShaderGaussian(vec2 texcoord, vec2 direction, vec2 pixelStep) {
|
vec4 pixelShaderGaussian(vec2 texcoord, vec2 direction, vec2 pixelStep) {
|
||||||
|
texcoord = evalTexcoordTransformed(texcoord);
|
||||||
vec4 sampleCenter = texture(sourceMap, texcoord);
|
vec4 sampleCenter = texture(sourceMap, texcoord);
|
||||||
|
|
||||||
vec2 finalStep = getFilterScale() * direction * pixelStep;
|
vec2 finalStep = getFilterScale() * direction * pixelStep;
|
||||||
|
@ -86,7 +91,7 @@ uniform sampler2D sourceMap;
|
||||||
uniform sampler2D depthMap;
|
uniform sampler2D depthMap;
|
||||||
|
|
||||||
vec4 pixelShaderGaussianDepthAware(vec2 texcoord, vec2 direction, vec2 pixelStep) {
|
vec4 pixelShaderGaussianDepthAware(vec2 texcoord, vec2 direction, vec2 pixelStep) {
|
||||||
|
texcoord = evalTexcoordTransformed(texcoord);
|
||||||
float sampleDepth = texture(depthMap, texcoord).x;
|
float sampleDepth = texture(depthMap, texcoord).x;
|
||||||
vec4 sampleCenter = texture(sourceMap, texcoord);
|
vec4 sampleCenter = texture(sourceMap, texcoord);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue