@@ -43,6 +43,10 @@ bool frustumCulled = false;
4343
4444float screenSize = 0 .0f;
4545
46+ #ifdef TAA
47+ vec2 getTAA();
48+ #endif
49+
4650UnpackedNode node22;
4751// Sets up screenspace with the given node id, returns true on success false on failure/should not continue
4852// Accesses data that is setup in the main traversal and is just shared to here
@@ -125,6 +129,13 @@ void setupScreenspace(in UnpackedNode node) {
125129 minBB = min (min (min (p000, p100), min (p001, p101)), min (min (p010, p110), min (p011, p111)));
126130 maxBB = max (max (max (p000, p100), max (p001, p101)), max (max (p010, p110), max (p011, p111)));
127131
132+
133+ #ifdef TAA
134+ vec2 taaValue = getTAA()* 0 .5f;// Note! this might be need tobe *0.5f
135+ minBB.xy += taaValue;
136+ maxBB.xy += taaValue;
137+ #endif
138+
128139 minBB = clamp (minBB, vec3 (0 ), vec3 (1 ));
129140 maxBB = clamp (maxBB, vec3 (0 ), vec3 (1 ));
130141}
@@ -137,21 +148,24 @@ bool outsideFrustum() {
137148}
138149
139150bool isCulledByHiz() {
151+ // if (node22.lodLevel!=0) return false;
152+
140153 // Things start breaking down if the area is the entire scree, no idea why, just abort if we hit this case
141- if ((maxBB.xy- minBB.xy)== vec2 (1 .0f)) return false;
154+ // if ((maxBB.xy-minBB.xy)==vec2(1.0f)) return false;
155+ if (any (lessThan (abs (maxBB.xy- minBB.xy- vec2 (1 .0f)), vec2 (0 .000001f)))) return false;
142156
143157 ivec2 ssize = ivec2 (packedHizSize>> 16 ,packedHizSize& 0xFFFF);
144158 vec2 size = (maxBB.xy- minBB.xy)* ssize;
145159 float miplevel = log2 (max (max (size.x, size.y),1 ));
146160
147161 miplevel = floor (miplevel)- 1 ;
148- // miplevel = clamp(miplevel, 0, 6 );
162+ // miplevel = clamp(miplevel, 0, 0 );
149163 miplevel = clamp (miplevel, 0 , textureQueryLevels(hizDepthSampler)- 1 );
150164
151165 int ml = int (miplevel);
152166 ssize = max (ivec2 (1 ), ssize>> ml);
153- ivec2 mxbb = min (ivec2 (maxBB.xy* ssize),ssize- 1 );
154- ivec2 mnbb = ivec2 (minBB.xy* ssize);
167+ ivec2 mxbb = min (ivec2 (ceil ( maxBB.xy* ssize) ),ssize- 1 );
168+ ivec2 mnbb = ivec2 (floor ( minBB.xy* ssize) );
155169
156170 float pointSample = - 1 .0f;
157171 // float pointSample2 = 0.0f;
@@ -164,13 +178,13 @@ bool isCulledByHiz() {
164178 }
165179 }
166180 // pointSample = mix(pointSample, pointSample2, pointSample<=0.000001f);
167-
168- return pointSample<= minBB.z;
181+ return pointSample< minBB.z- 0 .000001f;;// //(minBB.z*2-1);
169182}
170183
171184
172185
173186// Returns if we should decend into its children or not
174187bool shouldDecend() {
175188 return screenSize > minSSS;
176- }
189+ }
190+
0 commit comments