@@ -247,6 +247,7 @@ layout(push_constant) uniform constants {
247247 int aoSamples;
248248 float aoRadius;
249249 float aoPower;
250+ uint frameId;
250251} pc;
251252
252253layout (location=0) in PerVertex vtx;
@@ -322,7 +323,7 @@ void main() {
322323 vec3 tangent, bitangent;
323324 computeTBN(n, tangent, bitangent);
324325
325- uint seed = tea(uint(gl_FragCoord.y * 4003.0 + gl_FragCoord.x), 0 ); // prime
326+ uint seed = tea(uint(gl_FragCoord.y * 4003.0 + gl_FragCoord.x), pc.frameId ); // prime
326327
327328 float occl = 0.0;
328329
@@ -400,6 +401,9 @@ int aoSamples_ = 8;
400401bool aoDistanceBased_ = false ;
401402float aoRadius_ = 8 .0f ;
402403float aoPower_ = 1 .0f ;
404+ bool timeVaryingNoise = false ;
405+
406+ uint32_t frameId = 0 ;
403407
404408vec3 lightDir_ = normalize(vec3(0 .032f , 0 .835f , 0 .549f ));
405409
@@ -953,6 +957,7 @@ void render(double delta, uint32_t frameIndex) {
953957 ImGui::Text (" 1/2 - camera up/down" );
954958 ImGui::Text (" Shift - fast movement" );
955959 ImGui::Separator ();
960+ ImGui::Checkbox (" Time-varying noise" , &timeVaryingNoise);
956961 ImGui::Checkbox (" Ray traced shadows" , &enableShadows_);
957962 ImGui::Indent (indentSize);
958963 imGuiPushFlagsAndStyles (enableShadows_);
@@ -1054,6 +1059,7 @@ void render(double delta, uint32_t frameIndex) {
10541059 int aoSamples;
10551060 float aoRadius;
10561061 float aoPower;
1062+ uint32_t frameId;
10571063 } pc = {
10581064 .lightDir = vec4 (lightDir_, 1.0 ),
10591065 .perFrame = ctx_->gpuAddress (ubPerFrame_[frameIndex]),
@@ -1066,6 +1072,7 @@ void render(double delta, uint32_t frameIndex) {
10661072 .aoSamples = aoSamples_,
10671073 .aoRadius = aoRadius_,
10681074 .aoPower = aoPower_,
1075+ .frameId = timeVaryingNoise ? frameId++ : 0 ,
10691076 };
10701077 buffer.cmdPushConstants (pc);
10711078 buffer.cmdBindDepthState ({.compareOp = lvk::CompareOp_Equal, .isDepthWriteEnabled = false });
0 commit comments