mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-24 01:39:47 +02:00
Expose Hlaton 16 sequence
This commit is contained in:
parent
af09ae0686
commit
37f440031f
4 changed files with 41 additions and 10 deletions
|
@ -409,8 +409,32 @@ int JitterSampleConfig::play() {
|
||||||
return _index;
|
return _index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <int B> class Halton {
|
||||||
|
public:
|
||||||
|
|
||||||
|
float eval(int index) {
|
||||||
|
float f = 1.0f;
|
||||||
|
float r = 0.0f;
|
||||||
|
float invB = 1.0f / (float)B;
|
||||||
|
index++;
|
||||||
|
|
||||||
|
while (index > 0) {
|
||||||
|
f = f * invB;
|
||||||
|
r = r + f * (float) (index % B);
|
||||||
|
index = index / B;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
JitterSample::SampleSequence::SampleSequence(){
|
JitterSample::SampleSequence::SampleSequence(){
|
||||||
// Halton sequence (2,3)
|
// Halton sequence (2,3)
|
||||||
|
|
||||||
|
Halton<2> genX;
|
||||||
|
Halton<3> genY;
|
||||||
|
|
||||||
offsets[0] = { 1.0f / 2.0f, 1.0f / 3.0f };
|
offsets[0] = { 1.0f / 2.0f, 1.0f / 3.0f };
|
||||||
offsets[1] = { 1.0f / 4.0f, 2.0f / 3.0f };
|
offsets[1] = { 1.0f / 4.0f, 2.0f / 3.0f };
|
||||||
offsets[2] = { 3.0f / 4.0f, 1.0f / 9.0f };
|
offsets[2] = { 3.0f / 4.0f, 1.0f / 9.0f };
|
||||||
|
@ -421,7 +445,11 @@ JitterSample::SampleSequence::SampleSequence(){
|
||||||
offsets[7] = { 1.0f / 16.0f, 8.0f / 9.0f };
|
offsets[7] = { 1.0f / 16.0f, 8.0f / 9.0f };
|
||||||
|
|
||||||
for (int i = 0; i < SEQUENCE_LENGTH; i++) {
|
for (int i = 0; i < SEQUENCE_LENGTH; i++) {
|
||||||
offsets[i] = offsets[i] - vec2(0.5f);
|
offsets[i] = glm::vec2(genX.eval(i), genY.eval(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < SEQUENCE_LENGTH; i++) {
|
||||||
|
offsets[i] -= vec2(0.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,11 +476,13 @@ void JitterSample::run(const render::RenderContextPointer& renderContext, Jitter
|
||||||
auto width = (float) renderContext->args->_viewport.z;
|
auto width = (float) renderContext->args->_viewport.z;
|
||||||
auto height = (float) renderContext->args->_viewport.w;
|
auto height = (float) renderContext->args->_viewport.w;
|
||||||
|
|
||||||
auto jx = -4.0 * jit.x / width;
|
// auto jx = -4.0 * jit.x / width;
|
||||||
auto jy = -4.0 * jit.y / height;
|
// auto jy = -4.0 * jit.y / height;
|
||||||
|
auto jx = -2.0 * jit.x / width;
|
||||||
|
auto jy = -2.0 * jit.y / height;
|
||||||
|
|
||||||
projMat[2][0] += jx;
|
projMat[2][0] += jx * projMat[0][0];
|
||||||
projMat[2][1] += jy;
|
projMat[2][1] += jy * projMat[1][1];
|
||||||
|
|
||||||
viewFrustum.setProjection(projMat);
|
viewFrustum.setProjection(projMat);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
|
|
||||||
struct SampleSequence {
|
struct SampleSequence {
|
||||||
SampleSequence();
|
SampleSequence();
|
||||||
static const int SEQUENCE_LENGTH{ 8 };
|
static const int SEQUENCE_LENGTH{ 16 };
|
||||||
glm::vec2 offsets[SEQUENCE_LENGTH];
|
glm::vec2 offsets[SEQUENCE_LENGTH];
|
||||||
int sequenceLength{ SEQUENCE_LENGTH };
|
int sequenceLength{ SEQUENCE_LENGTH };
|
||||||
int currentIndex{ 0 };
|
int currentIndex{ 0 };
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<@include DeferredTransform.slh@>
|
<@include DeferredTransform.slh@>
|
||||||
<$declareDeferredFrameTransform()$>
|
<$declareDeferredFrameTransform()$>
|
||||||
|
|
||||||
const int SEQUENCE_LENGTH = 8;
|
const int SEQUENCE_LENGTH = 16;
|
||||||
struct JitterSequence {
|
struct JitterSequence {
|
||||||
vec4 offsets[SEQUENCE_LENGTH / 2];
|
vec4 offsets[SEQUENCE_LENGTH / 2];
|
||||||
int sequenceLength;
|
int sequenceLength;
|
||||||
|
|
|
@ -125,12 +125,13 @@ void main(void) {
|
||||||
|
|
||||||
float niceDotR2 = 4.0;
|
float niceDotR2 = 4.0;
|
||||||
|
|
||||||
for (int s = 0; s < SEQUENCE_LENGTH; s++) {
|
int sequenceLength = sequence.sequenceLength;
|
||||||
|
for (int s = 0; s < sequenceLength; s++) {
|
||||||
vec2 pixToSampleVec = jitterRegionPos - (vec2(0.5) + taa_getJitterSample(s)) * jitterRegionSize;
|
vec2 pixToSampleVec = jitterRegionPos - (vec2(0.5) + taa_getJitterSample(s)) * jitterRegionSize;
|
||||||
float radius2 = (s == sequence.currentIndex ? 4.0 * niceDotR2 : niceDotR2);
|
float radius2 = (s == sequence.currentIndex ? 4.0 * niceDotR2 : niceDotR2);
|
||||||
float distToSample2 = dot(pixToSampleVec, pixToSampleVec);
|
float distToSample2 = dot(pixToSampleVec, pixToSampleVec);
|
||||||
if (distToSample2 < radius2) {
|
if (distToSample2 < radius2) {
|
||||||
outFragColor = vec4(mix( outFragColor.rgb, colorRamp(float(s) / float(SEQUENCE_LENGTH)), 1.0 - distToSample2 / radius2), 1.0);
|
outFragColor = vec4(mix( outFragColor.rgb, colorRamp(float(s) / float(sequenceLength)), 1.0 - distToSample2 / radius2), 1.0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue