|
@@ -1,36 +1,27 @@
|
|
|
-<!--
|
|
|
|
|
-Copyright (C) 2009-2018, Panagiotis Christopoulos Charitos and contributors.
|
|
|
|
|
-All rights reserved.
|
|
|
|
|
-Code licensed under the BSD License.
|
|
|
|
|
-http://www.anki3d.org/LICENSE
|
|
|
|
|
--->
|
|
|
|
|
-<shaderProgram>
|
|
|
|
|
- <mutators>
|
|
|
|
|
- <mutator name="VARIANT" values="0 1"/>
|
|
|
|
|
- </mutators>
|
|
|
|
|
-
|
|
|
|
|
- <shaders>
|
|
|
|
|
- <shader type="comp">
|
|
|
|
|
- <inputs>
|
|
|
|
|
- <input name="FB_SIZE" type="UVec2" const="1"/>
|
|
|
|
|
- <input name="WORKGROUP_SIZE" type="UVec2" const="1"/>
|
|
|
|
|
- <input name="MAX_STEPS" type="U32" const="1"/>
|
|
|
|
|
- <input name="LIGHT_BUFFER_MIP_COUNT" type="U32" const="1"/>
|
|
|
|
|
- <input name="HIZ_MIP_COUNT" type="U32" const="1"/>
|
|
|
|
|
- <input name="CLUSTER_COUNT_X" type="U32" const="1"/>
|
|
|
|
|
- <input name="CLUSTER_COUNT_Y" type="U32" const="1"/>
|
|
|
|
|
- <input name="CLUSTER_COUNT_Z" type="U32" const="1"/>
|
|
|
|
|
- <input name="IR_MIPMAP_COUNT" type="U32" const="1"/>
|
|
|
|
|
- </inputs>
|
|
|
|
|
-
|
|
|
|
|
- <source><![CDATA[
|
|
|
|
|
|
|
+// Copyright (C) 2009-2018, Panagiotis Christopoulos Charitos and contributors.
|
|
|
|
|
+// All rights reserved.
|
|
|
|
|
+// Code licensed under the BSD License.
|
|
|
|
|
+// http://www.anki3d.org/LICENSE
|
|
|
|
|
+
|
|
|
// if VARIANT==0 then the checkerboard pattern is (render on 'v'):
|
|
// if VARIANT==0 then the checkerboard pattern is (render on 'v'):
|
|
|
// -----
|
|
// -----
|
|
|
// |v| |
|
|
// |v| |
|
|
|
// | |v|
|
|
// | |v|
|
|
|
// -----
|
|
// -----
|
|
|
|
|
|
|
|
|
|
+#pragma anki mutator VARIANT 0 1
|
|
|
|
|
+
|
|
|
|
|
+#pragma anki input const UVec2 FB_SIZE
|
|
|
|
|
+#pragma anki input const UVec2 WORKGROUP_SIZE
|
|
|
|
|
+#pragma anki input const U32 MAX_STEPS
|
|
|
|
|
+#pragma anki input const U32 LIGHT_BUFFER_MIP_COUNT
|
|
|
|
|
+#pragma anki input const U32 HIZ_MIP_COUNT
|
|
|
|
|
+#pragma anki input const U32 CLUSTER_COUNT_X
|
|
|
|
|
+#pragma anki input const U32 CLUSTER_COUNT_Y
|
|
|
|
|
+#pragma anki input const U32 CLUSTER_COUNT_Z
|
|
|
|
|
+#pragma anki input const U32 IR_MIPMAP_COUNT
|
|
|
|
|
|
|
|
|
|
+#pragma anki start comp
|
|
|
#include <shaders/Functions.glsl>
|
|
#include <shaders/Functions.glsl>
|
|
|
#include <shaders/Pack.glsl>
|
|
#include <shaders/Pack.glsl>
|
|
|
#include <shaders/glsl_cpp_common/Clusterer.h>
|
|
#include <shaders/glsl_cpp_common/Clusterer.h>
|
|
@@ -117,7 +108,7 @@ Vec4 doSslr(Vec3 r, Vec3 n, Vec3 viewPos, Vec2 uv, F32 depth, F32 roughness)
|
|
|
U32 j = gl_GlobalInvocationID.y & 1u;
|
|
U32 j = gl_GlobalInvocationID.y & 1u;
|
|
|
const U32 STEPS_ARR[4] = U32[](6u, 25u, 13u, 18u);
|
|
const U32 STEPS_ARR[4] = U32[](6u, 25u, 13u, 18u);
|
|
|
U32 step = STEPS_ARR[l * 2u + j];
|
|
U32 step = STEPS_ARR[l * 2u + j];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Iterate
|
|
// Iterate
|
|
|
Bool found = false;
|
|
Bool found = false;
|
|
|
Vec3 raySample;
|
|
Vec3 raySample;
|
|
@@ -150,7 +141,7 @@ Vec4 doSslr(Vec3 r, Vec3 n, Vec3 viewPos, Vec2 uv, F32 depth, F32 roughness)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //return Vec4(heatmap(F32(iterations) / F32(MAX_STEPS)), 1.0);
|
|
|
|
|
|
|
+ // return Vec4(heatmap(F32(iterations) / F32(MAX_STEPS)), 1.0);
|
|
|
|
|
|
|
|
if(found)
|
|
if(found)
|
|
|
{
|
|
{
|
|
@@ -189,12 +180,12 @@ void readReflectionsAndIrradianceFromProbes(
|
|
|
// Compute blend weight
|
|
// Compute blend weight
|
|
|
F32 blendWeight = computeProbeBlendWeight(worldPos, aabbMin, aabbMax, 0.2);
|
|
F32 blendWeight = computeProbeBlendWeight(worldPos, aabbMin, aabbMax, 0.2);
|
|
|
totalBlendWeight += blendWeight;
|
|
totalBlendWeight += blendWeight;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Sample reflections
|
|
// Sample reflections
|
|
|
Vec3 cubeUv = intersectProbe(worldPos, reflDir, aabbMin, aabbMax, probeOrigin);
|
|
Vec3 cubeUv = intersectProbe(worldPos, reflDir, aabbMin, aabbMax, probeOrigin);
|
|
|
Vec3 c = textureLod(u_reflectionsTex, Vec4(cubeUv, cubemapIndex), reflLod).rgb;
|
|
Vec3 c = textureLod(u_reflectionsTex, Vec4(cubeUv, cubemapIndex), reflLod).rgb;
|
|
|
specIndirect += c * blendWeight;
|
|
specIndirect += c * blendWeight;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Sample irradiance
|
|
// Sample irradiance
|
|
|
cubeUv = intersectProbe(worldPos, normal, aabbMin, aabbMax, probeOrigin);
|
|
cubeUv = intersectProbe(worldPos, normal, aabbMin, aabbMax, probeOrigin);
|
|
|
c = textureLod(u_irradianceTex, Vec4(cubeUv, cubemapIndex), 0.0).rgb;
|
|
c = textureLod(u_irradianceTex, Vec4(cubeUv, cubemapIndex), 0.0).rgb;
|
|
@@ -276,7 +267,7 @@ void main()
|
|
|
// Skip decals
|
|
// Skip decals
|
|
|
U32 count = u_lightIndices[idxOffset++];
|
|
U32 count = u_lightIndices[idxOffset++];
|
|
|
idxOffset += count;
|
|
idxOffset += count;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Skip point lights
|
|
// Skip point lights
|
|
|
count = u_lightIndices[idxOffset++];
|
|
count = u_lightIndices[idxOffset++];
|
|
|
idxOffset += count;
|
|
idxOffset += count;
|
|
@@ -314,7 +305,7 @@ void main()
|
|
|
Bool pickRightNeighbour = (fixedInvocationId.y & 1) == 0;
|
|
Bool pickRightNeighbour = (fixedInvocationId.y & 1) == 0;
|
|
|
#endif
|
|
#endif
|
|
|
I32 xOffset = (pickRightNeighbour) ? 1 : -1;
|
|
I32 xOffset = (pickRightNeighbour) ? 1 : -1;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
readPixel.x = I32(gl_LocalInvocationID.x) + xOffset;
|
|
readPixel.x = I32(gl_LocalInvocationID.x) + xOffset;
|
|
|
readPixel.x = clamp(readPixel.x, 0, I32(WORKGROUP_SIZE.x - 1));
|
|
readPixel.x = clamp(readPixel.x, 0, I32(WORKGROUP_SIZE.x - 1));
|
|
|
|
|
|
|
@@ -326,7 +317,4 @@ void main()
|
|
|
imageStore(out_reflAndIndirect, fixedInvocationId, Vec4(outColor, 0.0));
|
|
imageStore(out_reflAndIndirect, fixedInvocationId, Vec4(outColor, 0.0));
|
|
|
imageStore(out_reflAndIndirect, storePixel, Vec4(missingColor, 0.0));
|
|
imageStore(out_reflAndIndirect, storePixel, Vec4(missingColor, 0.0));
|
|
|
}
|
|
}
|
|
|
- ]]></source>
|
|
|
|
|
- </shader>
|
|
|
|
|
- </shaders>
|
|
|
|
|
-</shaderProgram>
|
|
|
|
|
|
|
+#pragma anki end
|