mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 11:33:44 +02:00
exposing the ditheringEnable field
This commit is contained in:
parent
0d8e247626
commit
89d2d102f6
7 changed files with 26 additions and 4 deletions
|
@ -177,6 +177,14 @@ void AmbientOcclusionEffect::setLevel(float level) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void AmbientOcclusionEffect::setDithering(bool enabled) {
|
||||
if (enabled != isDitheringEnabled()) {
|
||||
auto& current = _parametersBuffer.edit<Parameters>()._performanceCaps;
|
||||
current.x = (float)enabled;
|
||||
}
|
||||
}
|
||||
|
||||
void AmbientOcclusionEffect::updateDeferredTransformBuffer(const render::RenderContextPointer& renderContext) {
|
||||
// Allocate the parameters buffer used by all the deferred shaders
|
||||
if (!_deferredTransformBuffer[0]._buffer) {
|
||||
|
|
|
@ -30,6 +30,10 @@ public:
|
|||
void setLevel(float level);
|
||||
float getLevel() const { return _parametersBuffer.get<Parameters>()._radiusInfo.w; }
|
||||
|
||||
void setDithering(bool enabled);
|
||||
bool isDitheringEnabled() const { return _parametersBuffer.get<Parameters>()._performanceCaps.x; }
|
||||
|
||||
|
||||
using JobModel = render::Task::Job::Model<AmbientOcclusionEffect>;
|
||||
|
||||
private:
|
||||
|
@ -41,6 +45,8 @@ private:
|
|||
public:
|
||||
// radius info is { R, R^2, 1 / R^6, ObscuranceScale}
|
||||
glm::vec4 _radiusInfo{ 0.5, 0.5 * 0.5, 1.0 / (0.25 * 0.25 * 0.25), 1.0 };
|
||||
// Performance parameters to adjust the effect
|
||||
glm::vec4 _performanceCaps{ 1.0, 1.0, 1.0, 1.0 };
|
||||
// Pixel info is { viemport width height and stereo on off}
|
||||
glm::vec4 _pixelInfo;
|
||||
// Depth info is { n.f, f - n, -f}
|
||||
|
|
|
@ -183,6 +183,7 @@ void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const Rend
|
|||
if (_occlusionJobIndex >= 0) {
|
||||
_jobs[_occlusionJobIndex].edit<AmbientOcclusionEffect>().setRadius(renderContext->getAmbientOcclusion().radius);
|
||||
_jobs[_occlusionJobIndex].edit<AmbientOcclusionEffect>().setLevel(renderContext->getAmbientOcclusion().level);
|
||||
_jobs[_occlusionJobIndex].edit<AmbientOcclusionEffect>().setDithering(renderContext->getAmbientOcclusion().ditheringEnabled);
|
||||
}
|
||||
|
||||
setAntialiasingStatus(renderContext->getFxaaStatus());
|
||||
|
|
|
@ -72,6 +72,7 @@ namespace RenderScripting {
|
|||
public:
|
||||
Q_PROPERTY(float radius MEMBER radius)
|
||||
Q_PROPERTY(float level MEMBER level)
|
||||
Q_PROPERTY(bool ditheringEnabled MEMBER ditheringEnabled)
|
||||
};
|
||||
using AmbientOcclusionPointer = std::unique_ptr<AmbientOcclusion>;
|
||||
};
|
||||
|
|
|
@ -33,6 +33,7 @@ vec2 unpackOcclusionDepth(vec3 raw) {
|
|||
|
||||
struct AmbientOcclusionParams {
|
||||
vec4 _radiusInfo;
|
||||
vec4 _performanceCaps;
|
||||
vec4 _pixelInfo;
|
||||
vec4 _depthInfo;
|
||||
mat4 _projection[2];
|
||||
|
@ -65,6 +66,10 @@ float getObscuranceScaling() {
|
|||
return params._radiusInfo.z * params._radiusInfo.w;
|
||||
}
|
||||
|
||||
float isDitheringEnabled() {
|
||||
return params._performanceCaps.x;
|
||||
}
|
||||
|
||||
float evalZeyeFromZdb(float depth) {
|
||||
return params._depthInfo.x / (depth * params._depthInfo.y + params._depthInfo.z);
|
||||
}
|
||||
|
@ -102,7 +107,7 @@ vec2 fetchOcclusionDepth(ivec2 coords) {
|
|||
|
||||
|
||||
const int BLUR_RADIUS = 4;
|
||||
const int RADIUS_SCALE = 3;
|
||||
const int RADIUS_SCALE = 2;
|
||||
const float EDGE_SHARPNESS = 1.0;
|
||||
|
||||
const float gaussian[BLUR_RADIUS + 1] =
|
||||
|
|
|
@ -53,7 +53,8 @@ vec3 getOffsetPosition(ivec2 ssC, vec2 unitOffset, float ssR) {
|
|||
// We need to divide by 2^mipLevel to read the appropriately scaled coordinate from a MIP-map.
|
||||
// Manually clamp to the texture size because texelFetch bypasses the texture unit
|
||||
ivec2 mipP = clamp(ssP >> mipLevel, ivec2(0), textureSize(pyramidMap, mipLevel) - ivec2(1));
|
||||
P.z = -texelFetch(pyramidMap, mipP, mipLevel).r;
|
||||
// P.z = -texelFetch(pyramidMap, mipP, mipLevel).r;
|
||||
P.z = -texelFetch(pyramidMap, ssP, 0).r;
|
||||
|
||||
// Offset to pixel center
|
||||
//P = reconstructCSPosition(vec2(ssP) + vec2(0.5), P.z);
|
||||
|
@ -104,10 +105,9 @@ void main(void) {
|
|||
vec3 Cp = evalEyePosition(varTexCoord0);
|
||||
|
||||
// Hash function used in the HPG12 AlchemyAO paper
|
||||
float randomPatternRotationAngle = (3 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 10;
|
||||
float randomPatternRotationAngle = isDitheringEnabled() * (3 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 10;
|
||||
|
||||
vec3 Cn = evalEyeNormal(Cp);
|
||||
// vec3 Cn = normalize((texelFetch(normalMap, ssC, 0).xyz * 2.0) - vec3(1.0));
|
||||
|
||||
// Choose the screen-space sample radius
|
||||
// proportional to the projected area of the sphere
|
||||
|
|
|
@ -76,6 +76,7 @@ public:
|
|||
public:
|
||||
float radius = 0.5f; // radius in meters of the AO effect
|
||||
float level = 0.5f; // Level of the obscrance value
|
||||
bool ditheringEnabled = true;
|
||||
};
|
||||
|
||||
RenderContext(ItemsConfig items, Tone tone, AmbientOcclusion ao, int drawStatus, bool drawHitEffect, glm::vec4 deferredDebugSize, int deferredDebugMode);
|
||||
|
|
Loading…
Reference in a new issue