Skip to content

Commit 449be6d

Browse files
committed
remap internal vars to _ for screenspace
1 parent f897f4c commit 449be6d

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

src/main/resources/assets/voxy/shaders/lod/hierarchical/screenspace.glsl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ bool checkPointInView(vec4 point) {
3737
return within(vec3(-point.w,-point.w,0.0f), point.xyz, vec3(point.w));
3838
}
3939

40-
vec3 minBB = vec3(0.0f);
41-
vec3 maxBB = vec3(0.0f);
42-
bool frustumCulled = false;
40+
vec3 _minBB = vec3(0.0f);
41+
vec3 _maxBB = vec3(0.0f);
42+
bool _frustumCulled = false;
4343

44-
float screenSize = 0.0f;
44+
float _screenSize = 0.0f;
4545

4646
#ifdef TAA
4747
vec2 getTAA();
@@ -64,10 +64,10 @@ void setupScreenspace(in UnpackedNode node) {
6464

6565
vec3 basePos = vec3(((node.pos<<node.lodLevel)-camSecPos)<<5)-camSubSecPos;
6666

67-
frustumCulled = outsideFrustum(frustum, basePos, float(32<<node.lodLevel));
67+
_frustumCulled = outsideFrustum(frustum, basePos, float(32<<node.lodLevel));
6868

6969
//Fast exit
70-
if (frustumCulled) {
70+
if (_frustumCulled) {
7171
return;
7272
}
7373

@@ -123,26 +123,26 @@ void setupScreenspace(in UnpackedNode node) {
123123
ssize += crossMag(C,B);
124124
}
125125
ssize *= 0.5f;//Half the size since we did both back and front area
126-
screenSize = ssize;
126+
_screenSize = ssize;
127127
}
128128

129-
minBB = min(min(min(p000, p100), min(p001, p101)), min(min(p010, p110), min(p011, p111)));
130-
maxBB = max(max(max(p000, p100), max(p001, p101)), max(max(p010, p110), max(p011, p111)));
129+
_minBB = min(min(min(p000, p100), min(p001, p101)), min(min(p010, p110), min(p011, p111)));
130+
_maxBB = max(max(max(p000, p100), max(p001, p101)), max(max(p010, p110), max(p011, p111)));
131131

132132

133133
#ifdef TAA
134134
vec2 taaValue = getTAA()*0.5f;//Note! this might be need tobe *0.5f
135-
minBB.xy += taaValue;
136-
maxBB.xy += taaValue;
135+
_minBB.xy += taaValue;
136+
_maxBB.xy += taaValue;
137137
#endif
138138

139-
minBB = clamp(minBB, vec3(0), vec3(1));
140-
maxBB = clamp(maxBB, vec3(0), vec3(1));
139+
_minBB = clamp(_minBB, vec3(0), vec3(1));
140+
_maxBB = clamp(_maxBB, vec3(0), vec3(1));
141141
}
142142

143143
//Checks if the node is implicitly culled (outside frustum)
144144
bool outsideFrustum() {
145-
return frustumCulled;// maxW < 16 is a trick where 16 is the near plane
145+
return _frustumCulled;// maxW < 16 is a trick where 16 is the near plane
146146

147147
//|| any(lessThanEqual(minBB, vec3(0.0f, 0.0f, 0.0f))) || any(lessThanEqual(vec3(1.0f, 1.0f, 1.0f), maxBB));
148148
}
@@ -152,10 +152,10 @@ bool isCulledByHiz() {
152152

153153
//Things start breaking down if the area is the entire scree, no idea why, just abort if we hit this case
154154
//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;
155+
if (any(lessThan(abs(_maxBB.xy-_minBB.xy-vec2(1.0f)), vec2(0.000001f)))) return false;
156156

157157
ivec2 ssize = ivec2(packedHizSize>>16,packedHizSize&0xFFFF);
158-
vec2 size = (maxBB.xy-minBB.xy)*ssize;
158+
vec2 size = (_maxBB.xy-_minBB.xy)*ssize;
159159
float miplevel = log2(max(max(size.x, size.y),1));
160160

161161
miplevel = floor(miplevel)-1;
@@ -164,8 +164,8 @@ bool isCulledByHiz() {
164164

165165
int ml = int(miplevel);
166166
ssize = max(ivec2(1), ssize>>ml);
167-
ivec2 mxbb = min(ivec2(ceil(maxBB.xy*ssize)),ssize-1);
168-
ivec2 mnbb = ivec2(floor(minBB.xy*ssize));
167+
ivec2 mxbb = min(ivec2(ceil(_maxBB.xy*ssize)),ssize-1);
168+
ivec2 mnbb = ivec2(floor(_minBB.xy*ssize));
169169

170170
float pointSample = -1.0f;
171171
//float pointSample2 = 0.0f;
@@ -178,13 +178,13 @@ bool isCulledByHiz() {
178178
}
179179
}
180180
//pointSample = mix(pointSample, pointSample2, pointSample<=0.000001f);
181-
return pointSample<minBB.z-0.000001f;;////(minBB.z*2-1);
181+
return pointSample<_minBB.z-0.000001f;;////(minBB.z*2-1);
182182
}
183183

184184

185185

186186
//Returns if we should decend into its children or not
187187
bool shouldDecend() {
188-
return screenSize > minSSS;
188+
return _screenSize > minSSS;
189189
}
190190

0 commit comments

Comments
 (0)