فهرست منبع

Remove unused GLSL code

Panagiotis Christopoulos Charitos 2 سال پیش
والد
کامیت
050ea02c6a

+ 0 - 124
AnKi/Shaders/BilateralFilter.glsl

@@ -1,124 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-// Contains a bounch of edge stopping functions plus some other things
-
-#pragma once
-
-#include <AnKi/Shaders/Common.glsl>
-
-// https://cs.dartmouth.edu/~wjarosz/publications/mara17towards.html
-F32 calculateBilateralWeightDepth(F32 depthCenter, F32 depthTap, F32 phi)
-{
-	const F32 diff = abs(depthTap - depthCenter);
-#if 0
-	return max(0.0, 1.0 - diff * phi);
-#else
-	return sqrt(1.0 / (kEpsilonf + diff)) * phi;
-#endif
-}
-
-// From the SVGF sample code. Depth is linear
-F32 calculateBilateralWeightDepth2(F32 depthCenter, F32 depthTap, F32 phi)
-{
-	return (phi == 0.0) ? 0.0 : abs(depthCenter - depthTap) / phi;
-}
-
-// https://cs.dartmouth.edu/~wjarosz/publications/mara17towards.html
-F32 calculateBilateralWeightNormal(Vec3 center, Vec3 tap, F32 phi)
-{
-	F32 normalCloseness = dot(tap, center);
-	normalCloseness = normalCloseness * normalCloseness;
-	normalCloseness = normalCloseness * normalCloseness;
-
-	const F32 normalError = (1.0 - normalCloseness);
-	return max((1.0 - normalError * phi), 0.0);
-}
-
-F32 calculateBilateralWeightNormalCos(Vec3 ref, Vec3 tap, F32 phi)
-{
-	return pow(saturate(dot(ref, tap)), phi);
-}
-
-// https://cs.dartmouth.edu/~wjarosz/publications/mara17towards.html
-F32 calculateBilateralWeightPlane(Vec3 positionCenter, Vec3 centerNormal, Vec3 positionTap, Vec3 normalTap, F32 phi)
-{
-	const F32 lowDistanceThreshold2 = 0.001;
-
-	// Change in position in camera space
-	const Vec3 dq = positionCenter - positionTap;
-
-	// How far away is this point from the original sample in camera space? (Max value is unbounded)
-	const F32 distance2 = dot(dq, dq);
-
-	// How far off the expected plane (on the perpendicular) is this point? Max value is unbounded.
-	const F32 planeError = max(abs(dot(dq, normalTap)), abs(dot(dq, centerNormal)));
-
-	return (distance2 < lowDistanceThreshold2) ? 1.0
-											   : pow(max(0.0, 1.0 - 2.0 * phi * planeError / sqrt(distance2)), 2.0);
-}
-
-// https://cs.dartmouth.edu/~wjarosz/publications/mara17towards.html
-F32 calculateBilateralWeightRoughness(F32 roughnessCenter, F32 roughnessTap, F32 phi)
-{
-	const F32 gDiff = abs(roughnessCenter - roughnessTap) * 10.0;
-	return max(0.0, 1.0 - (gDiff * phi));
-}
-
-// From SVGF sample code.
-F32 calculateBilateralWeightLinearDepthAndLuminance(F32 depthCenter, F32 luminanceCenter, F32 depthTap,
-													F32 luminanceTap, F32 phiDepth, F32 phiLuminance)
-{
-	const F32 wZ = calculateBilateralWeightDepth2(depthCenter, depthTap, phiDepth);
-	const F32 wL = abs(luminanceCenter - luminanceTap) / phiLuminance;
-	return exp(0.0 - max(wL, 0.0) - max(wZ, 0.0));
-}
-
-// Compute a weight given 2 viewspace positions.
-F32 calculateBilateralWeightViewspacePosition(Vec3 posCenter, Vec3 posTap, F32 sigma)
-{
-	const Vec3 t = posCenter - posTap;
-	const F32 dist2 = dot(t, t) + t.z * t.z;
-	return min(exp(-(dist2) / sigma), 1.0);
-}
-
-struct SpatialBilateralContext
-{
-	U32 sampleCount;
-	UVec2 referencePointUnormalizedTextureUv;
-	U32 maxRadiusPixels;
-	U32 spiralTurnCount;
-	F32 randomRotationAngle;
-};
-
-// Initialize the spatial bilateral context. Its purpose it to create samples that form a spiral around the reference
-// point. To experiment and play with the values use this: https://www.shadertoy.com/view/3s3BRs
-SpatialBilateralContext spatialBilateralInit(U32 sampleCount, UVec2 referencePointUnormalizedTextureUv,
-											 U32 maxRadiusPixels, U32 spiralTurnCount, F32 time)
-{
-	SpatialBilateralContext ctx;
-
-	ctx.sampleCount = sampleCount;
-	ctx.referencePointUnormalizedTextureUv = referencePointUnormalizedTextureUv;
-	ctx.maxRadiusPixels = maxRadiusPixels;
-	ctx.spiralTurnCount = spiralTurnCount;
-
-	const UVec2 ref = referencePointUnormalizedTextureUv;
-	ctx.randomRotationAngle = F32((3u * ref.x) ^ (ref.y + ref.x * ref.y)) + time;
-
-	return ctx;
-}
-
-// Iterate to get a new sample. See spatialBilateralInit()
-UVec2 spatialBilateralIterate(SpatialBilateralContext ctx, U32 iteration)
-{
-	const F32 alpha = F32(F32(iteration) + 0.5) * (1.0 / F32(ctx.sampleCount));
-	const F32 angle = alpha * F32(ctx.spiralTurnCount) * 6.28 + ctx.randomRotationAngle;
-
-	const Vec2 unitOffset = Vec2(cos(angle), sin(angle));
-
-	const IVec2 tapOffset = IVec2(alpha * F32(ctx.maxRadiusPixels) * unitOffset);
-	return UVec2(IVec2(ctx.referencePointUnormalizedTextureUv) + tapOffset);
-}

+ 0 - 196
AnKi/Shaders/ClusteredShadingCommon.glsl

@@ -1,196 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/LightFunctions.glsl>
-
-//
-// Common uniforms
-//
-#if defined(CLUSTERED_SHADING_UNIFORMS_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_UNIFORMS_BINDING) uniform b_clusteredShading
-{
-	ClusteredShadingUniforms u_clusteredShading;
-};
-#endif
-
-//
-// Light uniforms (3)
-//
-#if defined(CLUSTERED_SHADING_LIGHTS_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_LIGHTS_BINDING) uniform b_pointLights
-{
-	PointLight u_pointLights2[kMaxVisiblePointLights];
-};
-
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_LIGHTS_BINDING + 1u) uniform b_spotLights
-{
-	SpotLight u_spotLights[kMaxVisibleSpotLights];
-};
-
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_LIGHTS_BINDING + 2u) uniform texture2D u_shadowAtlasTex;
-#endif
-
-//
-// Reflection probes (3)
-//
-#if defined(CLUSTERED_SHADING_REFLECTIONS_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_REFLECTIONS_BINDING) uniform b_reflectionProbes
-{
-	ReflectionProbe u_reflectionProbes[kMaxVisibleReflectionProbes];
-};
-
-layout(set = CLUSTERED_SHADING_SET,
-	   binding = CLUSTERED_SHADING_REFLECTIONS_BINDING + 1u) uniform ANKI_RP textureCubeArray u_reflectionsTex;
-#endif
-
-//
-// Decal uniforms (3)
-//
-#if defined(CLUSTERED_SHADING_DECALS_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_DECALS_BINDING) uniform b_decals
-{
-	Decal u_decals2[kMaxVisibleDecals];
-};
-
-layout(set = CLUSTERED_SHADING_SET,
-	   binding = CLUSTERED_SHADING_DECALS_BINDING + 1u) uniform ANKI_RP texture2D u_diffuseDecalTex;
-layout(set = CLUSTERED_SHADING_SET,
-	   binding = CLUSTERED_SHADING_DECALS_BINDING + 2u) uniform ANKI_RP texture2D u_specularRoughnessDecalTex;
-#endif
-
-//
-// Fog density uniforms (1)
-//
-#if defined(CLUSTERED_SHADING_FOG_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_FOG_BINDING) uniform b_fogDensityVolumes
-{
-	FogDensityVolume u_fogDensityVolumes[kMaxVisibleFogDensityVolumes];
-};
-#endif
-
-//
-// GI (2)
-//
-#if defined(CLUSTERED_SHADING_GI_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_GI_BINDING) uniform ANKI_RP texture3D
-	u_globalIlluminationTextures[kMaxVisibleGlobalIlluminationProbes];
-
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_GI_BINDING + 1u) uniform b_giProbes
-{
-	GlobalIlluminationProbe u_giProbes[kMaxVisibleGlobalIlluminationProbes];
-};
-#endif
-
-//
-// Cluster uniforms
-//
-#if defined(CLUSTERED_SHADING_CLUSTERS_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_CLUSTERS_BINDING) readonly buffer b_clusters
-{
-	Cluster u_clusters[];
-};
-#endif
-
-// Debugging function
-Vec3 clusterHeatmap(Cluster cluster, U32 objectTypeMask)
-{
-	U32 maxObjects = 0u;
-	I32 count = 0;
-
-	if((objectTypeMask & (1u << kClusterObjectTypePointLight)) != 0u)
-	{
-		maxObjects += kMaxVisiblePointLights;
-		count += I32(bitCount(cluster.m_pointLightsMask));
-	}
-
-	if((objectTypeMask & (1u << kClusterObjectTypeSpotLight)) != 0u)
-	{
-		maxObjects += kMaxVisibleSpotLights;
-		count += I32(bitCount(cluster.m_spotLightsMask));
-	}
-
-	if((objectTypeMask & (1u << kClusterObjectTypeDecal)) != 0u)
-	{
-		maxObjects += kMaxVisibleDecals;
-		count += I32(bitCount(cluster.m_decalsMask));
-	}
-
-	if((objectTypeMask & (1u << kClusterObjectTypeFogDensityVolume)) != 0u)
-	{
-		maxObjects += kMaxVisibleFogDensityVolumes;
-		count += bitCount(cluster.m_fogDensityVolumesMask);
-	}
-
-	if((objectTypeMask & (1u << kClusterObjectTypeReflectionProbe)) != 0u)
-	{
-		maxObjects += kMaxVisibleReflectionProbes;
-		count += bitCount(cluster.m_reflectionProbesMask);
-	}
-
-	if((objectTypeMask & (1u << kClusterObjectTypeGlobalIlluminationProbe)) != 0u)
-	{
-		maxObjects += kMaxVisibleGlobalIlluminationProbes;
-		count += bitCount(cluster.m_giProbesMask);
-	}
-
-	const F32 factor = min(1.0, F32(count) / F32(maxObjects));
-	return heatmap(factor);
-}
-
-/// Returns the index of the zSplit or linearizeDepth(n, f, depth)*zSplitCount
-/// Simplifying this equation is 1/(a+b/depth) where a=(n-f)/(n*zSplitCount) and b=f/(n*zSplitCount)
-U32 computeZSplitClusterIndex(F32 depth, U32 zSplitCount, F32 a, F32 b)
-{
-	const F32 fSplitIdx = 1.0 / (a + b / depth);
-	return min(zSplitCount - 1u, U32(fSplitIdx));
-}
-
-/// Return the tile index.
-U32 computeTileClusterIndexFragCoord(Vec2 fragCoord, U32 tileSize, U32 tileCountX)
-{
-	const UVec2 tileXY = UVec2(fragCoord / F32(tileSize));
-	return tileXY.y * tileCountX + tileXY.x;
-}
-
-/// Merge the tiles with z splits into a single cluster.
-Cluster mergeClusters(Cluster tileCluster, Cluster zCluster)
-{
-//#define ANKI_OR_MASKS(x) subgroupOr(x)
-#define ANKI_OR_MASKS(x) (x)
-
-	Cluster outCluster;
-	outCluster.m_pointLightsMask = ANKI_OR_MASKS(tileCluster.m_pointLightsMask & zCluster.m_pointLightsMask);
-	outCluster.m_spotLightsMask = ANKI_OR_MASKS(tileCluster.m_spotLightsMask & zCluster.m_spotLightsMask);
-	outCluster.m_decalsMask = ANKI_OR_MASKS(tileCluster.m_decalsMask & zCluster.m_decalsMask);
-	outCluster.m_fogDensityVolumesMask =
-		ANKI_OR_MASKS(tileCluster.m_fogDensityVolumesMask & zCluster.m_fogDensityVolumesMask);
-	outCluster.m_reflectionProbesMask =
-		ANKI_OR_MASKS(tileCluster.m_reflectionProbesMask & zCluster.m_reflectionProbesMask);
-	outCluster.m_giProbesMask = ANKI_OR_MASKS(tileCluster.m_giProbesMask & zCluster.m_giProbesMask);
-
-#undef ANKI_OR_MASKS
-
-	return outCluster;
-}
-
-#if defined(CLUSTERED_SHADING_CLUSTERS_BINDING)
-/// Get the final cluster after ORing and ANDing the masks.
-Cluster getClusterFragCoord(Vec3 fragCoord, U32 tileSize, UVec2 tileCounts, U32 zSplitCount, F32 a, F32 b)
-{
-	const Cluster tileCluster = u_clusters[computeTileClusterIndexFragCoord(fragCoord.xy, tileSize, tileCounts.x)];
-	const Cluster zCluster =
-		u_clusters[computeZSplitClusterIndex(fragCoord.z, zSplitCount, a, b) + tileCounts.x * tileCounts.y];
-	return mergeClusters(tileCluster, zCluster);
-}
-
-Cluster getClusterFragCoord(Vec3 fragCoord)
-{
-	return getClusterFragCoord(fragCoord, u_clusteredShading.m_tileSize, u_clusteredShading.m_tileCounts,
-							   u_clusteredShading.m_zSplitCount, u_clusteredShading.m_zSplitMagic.x,
-							   u_clusteredShading.m_zSplitMagic.y);
-}
-#endif

+ 0 - 130
AnKi/Shaders/CollisionFunctions.glsl

@@ -1,130 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-/// https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-rendering-a-triangle/moller-trumbore-ray-triangle-intersection
-Bool testRayTriangle(Vec3 rayOrigin, Vec3 rayDir, Vec3 v0, Vec3 v1, Vec3 v2, Bool backfaceCulling, out F32 t, out F32 u,
-					 out F32 v)
-{
-	const Vec3 v0v1 = v1 - v0;
-	const Vec3 v0v2 = v2 - v0;
-	const Vec3 pvec = cross(rayDir, v0v2);
-	const F32 det = dot(v0v1, pvec);
-
-	if((backfaceCulling && det < kEpsilonf) || abs(det) < kEpsilonf)
-	{
-		return false;
-	}
-
-	const F32 invDet = 1.0 / det;
-
-	const Vec3 tvec = rayOrigin - v0;
-	u = dot(tvec, pvec) * invDet;
-	if(u < 0.0 || u > 1.0)
-	{
-		return false;
-	}
-
-	const Vec3 qvec = cross(tvec, v0v1);
-	v = dot(rayDir, qvec) * invDet;
-	if(v < 0.0 || u + v > 1.0)
-	{
-		return false;
-	}
-
-	t = dot(v0v2, qvec) * invDet;
-
-	if(t <= kEpsilonf)
-	{
-		// This is an addition to the original code. Can't have rays that don't touch the triangle
-		return false;
-	}
-
-	return true;
-}
-
-/// Return true if to AABBs overlap.
-Bool testAabbAabb(Vec3 aMin, Vec3 aMax, Vec3 bMin, Vec3 bMax)
-{
-	return all(lessThan(aMin, bMax)) && all(lessThan(bMin, aMax));
-}
-
-/// Intersect a ray against an AABB. The ray is inside the AABB. The function returns the distance 'a' where the
-/// intersection point is rayOrigin + rayDir * a
-/// https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
-F32 testRayAabbInside(Vec3 rayOrigin, Vec3 rayDir, Vec3 aabbMin, Vec3 aabbMax)
-{
-	const Vec3 intersectMaxPointPlanes = (aabbMax - rayOrigin) / rayDir;
-	const Vec3 intersectMinPointPlanes = (aabbMin - rayOrigin) / rayDir;
-	const Vec3 largestParams = max(intersectMaxPointPlanes, intersectMinPointPlanes);
-	const F32 distToIntersect = min(min(largestParams.x, largestParams.y), largestParams.z);
-	return distToIntersect;
-}
-
-/// Ray box intersection by Simon Green
-Bool testRayAabb(Vec3 rayOrigin, Vec3 rayDir, Vec3 aabbMin, Vec3 aabbMax, out F32 t0, out F32 t1)
-{
-	const Vec3 invR = 1.0 / rayDir;
-	const Vec3 tbot = invR * (aabbMin - rayOrigin);
-	const Vec3 ttop = invR * (aabbMax - rayOrigin);
-
-	const Vec3 tmin = min(ttop, tbot);
-	const Vec3 tmax = max(ttop, tbot);
-
-	t0 = max(tmin.x, max(tmin.y, tmin.z));
-	t1 = min(tmax.x, min(tmax.y, tmax.z));
-
-	return t0 < t1 && t1 > kEpsilonf;
-}
-
-Bool testRayObb(Vec3 rayOrigin, Vec3 rayDir, Vec3 obbExtend, Mat4 obbTransformInv, out F32 t0, out F32 t1)
-{
-	// Transform ray to OBB space
-	const Vec3 rayOriginS = (obbTransformInv * Vec4(rayOrigin, 1.0)).xyz;
-	const Vec3 rayDirS = (obbTransformInv * Vec4(rayDir, 0.0)).xyz;
-
-	// Test as AABB
-	return testRayAabb(rayOriginS, rayDirS, -obbExtend, obbExtend, t0, t1);
-}
-
-/// https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection
-Bool testRaySphere(Vec3 rayOrigin, Vec3 rayDir, Vec3 sphereCenter, F32 sphereRadius, out F32 t0, out F32 t1)
-{
-	const Vec3 L = sphereCenter - rayOrigin;
-	const F32 tca = dot(L, rayDir);
-	const F32 d2 = dot(L, L) - tca * tca;
-	const F32 radius2 = sphereRadius * sphereRadius;
-	const F32 diff = radius2 - d2;
-	if(diff < 0.0)
-	{
-		return false;
-	}
-
-	const F32 thc = sqrt(diff);
-	t0 = tca - thc;
-	t1 = tca + thc;
-
-	if(t0 < 0.0 && t1 < 0.0)
-	{
-		return false;
-	}
-
-	// Swap
-	if(t0 > t1)
-	{
-		const F32 tmp = t0;
-		t0 = t1;
-		t1 = tmp;
-	}
-
-	t0 = max(0.0, t0);
-	return true;
-}
-
-F32 testPlanePoint(Vec3 planeNormal, F32 planeOffset, Vec3 point)
-{
-	return dot(planeNormal, point) - planeOffset;
-}

+ 0 - 23
AnKi/Shaders/Common.glsl

@@ -1,23 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-// This file contains common code for all shaders. It's optional but it's recomended to include it
-
-#pragma once
-
-#include <AnKi/Shaders/Include/Common.h>
-#if ANKI_GLSL
-#	include <AnKi/Shaders/TextureFunctions.glsl>
-#endif
-
-// Macros
-#define UV_TO_NDC(x_) ((x_)*2.0 - 1.0)
-#define NDC_TO_UV(x_) ((x_)*0.5 + 0.5)
-
-// Techniques
-#define RENDERING_TECHNIQUE_GBUFFER 0
-#define RENDERING_TECHNIQUE_GBUFFER_EZ 1
-#define RENDERING_TECHNIQUE_SHADOWS 2
-#define RENDERING_TECHNIQUE_FORWARD 3

+ 0 - 763
AnKi/Shaders/Functions.glsl

@@ -1,763 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Common.glsl>
-
-#if defined(ANKI_FRAGMENT_SHADER)
-Vec3 dither(Vec3 col, F32 C)
-{
-	Vec3 vDither = Vec3(dot(Vec2(171.0, 231.0), gl_FragCoord.xy));
-	vDither.rgb = frac(vDither.rgb / Vec3(103.0, 71.0, 97.0));
-
-	col = col * (255.0 / C) + vDither.rgb;
-	col = floor(col) / 255.0;
-	col *= C;
-
-	return col;
-}
-
-F32 dither(F32 col, F32 C)
-{
-	F32 vDither = dot(Vec2(171.0, 231.0), gl_FragCoord.xy);
-	vDither = frac(vDither / 103.0);
-
-	col = col * (255.0 / C) + vDither;
-	col = floor(col) / 255.0;
-	col *= C;
-
-	return col;
-}
-#endif
-
-// Convert to linear depth
-F32 linearizeDepth(F32 depth, F32 zNear, F32 zFar)
-{
-	return zNear / ((zNear - zFar) + zFar / depth);
-}
-
-// Convert to linear depth
-Vec4 linearizeDepth(Vec4 depth, F32 zNear, F32 zFar)
-{
-	return zNear / ((zNear - zFar) + zFar / depth);
-}
-
-// This is the optimal linearizeDepth where a=(n-f)/n and b=f/n
-F32 linearizeDepthOptimal(F32 depth, F32 a, F32 b)
-{
-	return 1.0 / (a + b / depth);
-}
-
-// This is the optimal linearizeDepth where a=(n-f)/n and b=f/n
-Vec4 linearizeDepthOptimal(Vec4 depths, F32 a, F32 b)
-{
-	return 1.0 / (a + b / depths);
-}
-
-// Project a vector by knowing only the non zero values of a perspective matrix
-Vec4 projectPerspective(Vec4 vec, F32 m00, F32 m11, F32 m22, F32 m23)
-{
-	Vec4 o;
-	o.x = vec.x * m00;
-	o.y = vec.y * m11;
-	o.z = vec.z * m22 + vec.w * m23;
-	o.w = -vec.z;
-	return o;
-}
-
-#if defined(ANKI_FRAGMENT_SHADER)
-// Stolen from shadertoy.com/view/4tyGDD
-Vec4 textureCatmullRom4Samples(texture2D tex, sampler sampl, Vec2 uv, Vec2 texSize)
-{
-	const Vec2 halff = 2.0 * frac(0.5 * uv * texSize - 0.25) - 1.0;
-	const Vec2 f = frac(halff);
-	const Vec2 sum0 = (2.0 * f - 3.5) * f + 0.5;
-	const Vec2 sum1 = (2.0 * f - 2.5) * f - 0.5;
-	Vec4 w = Vec4(f * sum0 + 1.0, f * sum1);
-	const Vec4 pos = Vec4((((-2.0 * f + 3.0) * f + 0.5) * f - 1.5) * f / (w.xy * texSize) + uv,
-						  (((-2.0 * f + 5.0) * f - 2.5) * f - 0.5) / (sum1 * texSize) + uv);
-	w.xz *= halff.x * halff.y > 0.0 ? 1.0 : -1.0;
-
-	return (texture(tex, sampl, pos.xy) * w.x + texture(tex, sampl, pos.zy) * w.z) * w.y
-		   + (texture(tex, sampl, pos.xw) * w.x + texture(tex, sampl, pos.zw) * w.z) * w.w;
-}
-#endif
-
-// Stolen from shadertoy.com/view/4df3Dn
-#if ANKI_GLSL
-Vec4 textureBicubic(texture2D tex, sampler sampl, Vec2 uv, F32 lod, Vec2 texSize)
-#else
-Vec4 textureBicubic(Texture2D tex, SamplerState sampl, Vec2 uv, F32 lod, Vec2 texSize)
-#endif
-{
-#define w0(a) ((1.0 / 6.0) * ((a) * ((a) * (-(a) + 3.0) - 3.0) + 1.0))
-#define w1(a) ((1.0 / 6.0) * ((a) * (a) * (3.0 * (a)-6.0) + 4.0))
-#define w2(a) ((1.0 / 6.0) * ((a) * ((a) * (-3.0 * (a) + 3.0) + 3.0) + 1.0))
-#define w3(a) ((1.0 / 6.0) * ((a) * (a) * (a)))
-#define g0(a) (w0(a) + w1(a))
-#define g1(a) (w2(a) + w3(a))
-#define h0(a) (-1.0 + w1(a) / (w0(a) + w1(a)))
-#define h1(a) (1.0 + w3(a) / (w2(a) + w3(a)))
-#if ANKI_GLSL
-#	define texSample(uv) textureLod(tex, sampl, uv, lod)
-#else
-#	define texSample(uv) tex.SampleLevel(sampl, uv, lod)
-#endif
-
-	uv = uv * texSize + 0.5;
-	const Vec2 iuv = floor(uv);
-	const Vec2 fuv = frac(uv);
-
-	const F32 g0x = g0(fuv.x);
-	const F32 g1x = g1(fuv.x);
-	const F32 h0x = h0(fuv.x);
-	const F32 h1x = h1(fuv.x);
-	const F32 h0y = h0(fuv.y);
-	const F32 h1y = h1(fuv.y);
-
-	const Vec2 p0 = (Vec2(iuv.x + h0x, iuv.y + h0y) - 0.5) / texSize;
-	const Vec2 p1 = (Vec2(iuv.x + h1x, iuv.y + h0y) - 0.5) / texSize;
-	const Vec2 p2 = (Vec2(iuv.x + h0x, iuv.y + h1y) - 0.5) / texSize;
-	const Vec2 p3 = (Vec2(iuv.x + h1x, iuv.y + h1y) - 0.5) / texSize;
-
-	return g0(fuv.y) * (g0x * texSample(p0) + g1x * texSample(p1))
-		   + g1(fuv.y) * (g0x * texSample(p2) + g1x * texSample(p3));
-
-#undef w0
-#undef w1
-#undef w2
-#undef g0
-#undef g1
-#undef h0
-#undef h1
-#undef texSample
-}
-
-F32 rand(Vec2 n)
-{
-	return 0.5 + 0.5 * frac(sin(dot(n, Vec2(12.9898, 78.233))) * 43758.5453);
-}
-
-#if ANKI_GLSL
-Vec4 nearestDepthUpscale(Vec2 uv, texture2D depthFull, texture2D depthHalf, texture2D colorTex,
-						 sampler linearAnyClampSampler, Vec2 linearDepthCf, F32 depthThreshold)
-{
-	F32 fullDepth = textureLod(depthFull, linearAnyClampSampler, uv, 0.0).r; // Sampler not important.
-	fullDepth = linearizeDepthOptimal(fullDepth, linearDepthCf.x, linearDepthCf.y);
-
-	Vec4 halfDepths = textureGather(sampler2D(depthHalf, linearAnyClampSampler), uv, 0); // Sampler not important.
-	halfDepths = linearizeDepthOptimal(halfDepths, linearDepthCf.x, linearDepthCf.y);
-
-	const Vec4 diffs = abs(Vec4(fullDepth) - halfDepths);
-	Vec4 color;
-
-	if(all(lessThan(diffs, Vec4(depthThreshold))))
-	{
-		// No major discontinuites, sample with bilinear
-		color = textureLod(colorTex, linearAnyClampSampler, uv, 0.0);
-	}
-	else
-	{
-		// Some discontinuites, need to use the newUv
-		const Vec4 r = textureGather(sampler2D(colorTex, linearAnyClampSampler), uv, 0);
-		const Vec4 g = textureGather(sampler2D(colorTex, linearAnyClampSampler), uv, 1);
-		const Vec4 b = textureGather(sampler2D(colorTex, linearAnyClampSampler), uv, 2);
-		const Vec4 a = textureGather(sampler2D(colorTex, linearAnyClampSampler), uv, 3);
-
-		F32 minDiff = diffs.x;
-		U32 comp = 0u;
-
-		if(diffs.y < minDiff)
-		{
-			comp = 1u;
-			minDiff = diffs.y;
-		}
-
-		if(diffs.z < minDiff)
-		{
-			comp = 2u;
-			minDiff = diffs.z;
-		}
-
-		if(diffs.w < minDiff)
-		{
-			comp = 3u;
-		}
-
-		color = Vec4(r[comp], g[comp], b[comp], a[comp]);
-	}
-
-	return color;
-}
-
-F32 _calcDepthWeight(texture2D depthLow, sampler nearestAnyClamp, Vec2 uv, F32 ref, Vec2 linearDepthCf)
-{
-	const F32 d = textureLod(depthLow, nearestAnyClamp, uv, 0.0).r;
-	const F32 linearD = linearizeDepthOptimal(d, linearDepthCf.x, linearDepthCf.y);
-	return 1.0 / (kEpsilonf + abs(ref - linearD));
-}
-
-Vec4 _sampleAndWeight(texture2D depthLow, texture2D colorLow, sampler linearAnyClamp, sampler nearestAnyClamp,
-					  const Vec2 lowInvSize, Vec2 uv, const Vec2 offset, const F32 ref, const F32 weight,
-					  const Vec2 linearDepthCf, inout F32 normalize)
-{
-	uv += offset * lowInvSize;
-	const F32 dw = _calcDepthWeight(depthLow, nearestAnyClamp, uv, ref, linearDepthCf);
-	const Vec4 v = textureLod(colorLow, linearAnyClamp, uv, 0.0);
-	normalize += weight * dw;
-	return v * dw * weight;
-}
-
-Vec4 bilateralUpsample(texture2D depthHigh, texture2D depthLow, texture2D colorLow, sampler linearAnyClamp,
-					   sampler nearestAnyClamp, const Vec2 lowInvSize, const Vec2 uv, const Vec2 linearDepthCf)
-{
-	const Vec3 kWeights = Vec3(0.25, 0.125, 0.0625);
-	const F32 depthRef =
-		linearizeDepthOptimal(textureLod(depthHigh, nearestAnyClamp, uv, 0.0).r, linearDepthCf.x, linearDepthCf.y);
-	F32 normalize = 0.0;
-
-	Vec4 sum = _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(0.0, 0.0),
-								depthRef, kWeights.x, linearDepthCf, normalize);
-	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(-1.0, 0.0),
-							depthRef, kWeights.y, linearDepthCf, normalize);
-	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(0.0, -1.0),
-							depthRef, kWeights.y, linearDepthCf, normalize);
-	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(1.0, 0.0),
-							depthRef, kWeights.y, linearDepthCf, normalize);
-	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(0.0, 1.0),
-							depthRef, kWeights.y, linearDepthCf, normalize);
-	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(1.0, 1.0),
-							depthRef, kWeights.z, linearDepthCf, normalize);
-	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(1.0, -1.0),
-							depthRef, kWeights.z, linearDepthCf, normalize);
-	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(-1.0, 1.0),
-							depthRef, kWeights.z, linearDepthCf, normalize);
-	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(-1.0, -1.0),
-							depthRef, kWeights.z, linearDepthCf, normalize);
-
-	return sum / normalize;
-}
-#endif
-
-Vec3 getCubemapDirection(const Vec2 norm, const U32 faceIdx)
-{
-	Vec3 zDir = Vec3((faceIdx <= 1u) ? 1 : 0, (faceIdx & 2u) >> 1u, (faceIdx & 4u) >> 2u);
-	zDir *= (((faceIdx & 1u) == 1u) ? -1.0 : 1.0);
-	const Vec3 yDir = (faceIdx == 2u)   ? Vec3(0.0, 0.0, 1.0)
-					  : (faceIdx == 3u) ? Vec3(0.0, 0.0, -1.0)
-										: Vec3(0.0, -1.0, 0.0);
-	const Vec3 xDir = cross(zDir, yDir);
-	return normalize(norm.x * xDir + norm.y * yDir + zDir);
-}
-
-// Convert 3D cubemap coordinates to 2D plus face index. v doesn't need to be normalized.
-Vec2 convertCubeUvs(const Vec3 v, out F32 faceIndex)
-{
-	const Vec3 absV = abs(v);
-	F32 mag;
-	Vec2 uv;
-
-	if(absV.z >= absV.x && absV.z >= absV.y)
-	{
-		faceIndex = (v.z < 0.0) ? 5.0 : 4.0;
-		uv = Vec2((v.z < 0.0) ? -v.x : v.x, -v.y);
-		mag = absV.z;
-	}
-	else if(absV.y >= absV.x)
-	{
-		faceIndex = (v.y < 0.0) ? 3.0 : 2.0;
-		uv = Vec2(v.x, (v.y < 0.0) ? -v.z : v.z);
-		mag = absV.y;
-	}
-	else
-	{
-		faceIndex = (v.x < 0.0) ? 1.0 : 0.0;
-		uv = Vec2((v.x < 0.0) ? v.z : -v.z, -v.y);
-		mag = absV.x;
-	}
-
-	return 0.5 / mag * uv + 0.5;
-}
-
-// Same as convertCubeUvs but it returns the faceIndex as unsigned I32.
-Vec2 convertCubeUvsu(const Vec3 v, out U32 faceIndex)
-{
-	const Vec3 absV = abs(v);
-	F32 mag;
-	Vec2 uv;
-
-	if(absV.z >= absV.x && absV.z >= absV.y)
-	{
-		faceIndex = (v.z < 0.0) ? 5u : 4u;
-		uv = Vec2((v.z < 0.0) ? -v.x : v.x, -v.y);
-		mag = absV.z;
-	}
-	else if(absV.y >= absV.x)
-	{
-		faceIndex = (v.y < 0.0) ? 3u : 2u;
-		uv = Vec2(v.x, (v.y < 0.0) ? -v.z : v.z);
-		mag = absV.y;
-	}
-	else
-	{
-		faceIndex = (v.x < 0.0) ? 1u : 0u;
-		uv = Vec2((v.x < 0.0) ? v.z : -v.z, -v.y);
-		mag = absV.x;
-	}
-
-	return 0.5 / mag * uv + 0.5;
-}
-
-#if ANKI_GLSL
-ANKI_RP Vec3 grayScale(const ANKI_RP Vec3 col)
-{
-	const ANKI_RP F32 grey = (col.r + col.g + col.b) * (1.0 / 3.0);
-	return Vec3(grey);
-}
-#endif
-
-Vec3 saturateColor(const Vec3 col, const F32 factor)
-{
-	const Vec3 lumCoeff = Vec3(0.2125, 0.7154, 0.0721);
-	const F32 d = dot(col, lumCoeff);
-	const Vec3 intensity = Vec3(d, d, d);
-	return lerp(intensity, col, factor);
-}
-
-Vec3 gammaCorrection(Vec3 gamma, Vec3 col)
-{
-	return pow(col, 1.0 / gamma);
-}
-
-#if ANKI_GLSL
-// Can use 0.15 for sharpenFactor
-Vec3 readSharpen(texture2D tex, sampler sampl, Vec2 uv, F32 sharpenFactor, Bool detailed)
-{
-	Vec3 col = textureLod(tex, sampl, uv, 0.0).rgb;
-
-	Vec3 col2 = textureLodOffset(sampler2D(tex, sampl), uv, 0.0, IVec2(1, 1)).rgb;
-	col2 += textureLodOffset(sampler2D(tex, sampl), uv, 0.0, IVec2(-1, -1)).rgb;
-	col2 += textureLodOffset(sampler2D(tex, sampl), uv, 0.0, IVec2(1, -1)).rgb;
-	col2 += textureLodOffset(sampler2D(tex, sampl), uv, 0.0, IVec2(-1, 1)).rgb;
-
-	F32 f = 4.0;
-	if(detailed)
-	{
-		col2 += textureLodOffset(sampler2D(tex, sampl), uv, 0.0, IVec2(0, 1)).rgb;
-		col2 += textureLodOffset(sampler2D(tex, sampl), uv, 0.0, IVec2(1, 0)).rgb;
-		col2 += textureLodOffset(sampler2D(tex, sampl), uv, 0.0, IVec2(-1, 0)).rgb;
-		col2 += textureLodOffset(sampler2D(tex, sampl), uv, 0.0, IVec2(0, -1)).rgb;
-
-		f = 8.0;
-	}
-
-	col = col * (f * sharpenFactor + 1.0) - sharpenFactor * col2;
-	return max(Vec3(0.0), col);
-}
-
-Vec3 readErosion(texture2D tex, sampler sampl, const Vec2 uv)
-{
-	Vec3 minValue = textureLod(tex, sampl, uv, 0.0).rgb;
-
-#	define ANKI_EROSION(x, y) \
-		col2 = textureLodOffset(sampler2D(tex, sampl), uv, 0.0, IVec2(x, y)).rgb; \
-		minValue = min(col2, minValue);
-
-	Vec3 col2;
-	ANKI_EROSION(1, 1);
-	ANKI_EROSION(-1, -1);
-	ANKI_EROSION(1, -1);
-	ANKI_EROSION(-1, 1);
-	ANKI_EROSION(0, 1);
-	ANKI_EROSION(1, 0);
-	ANKI_EROSION(-1, 0);
-	ANKI_EROSION(0, -1);
-
-#	undef ANKI_EROSION
-
-	return minValue;
-}
-#endif
-
-// 5 color heatmap from a factor.
-Vec3 heatmap(const F32 factor)
-{
-	F32 intPart;
-	const F32 fractional = modf(factor * 4.0, intPart);
-
-	if(intPart < 1.0)
-	{
-		return lerp(Vec3(0.0, 0.0, 0.0), Vec3(0.0, 0.0, 1.0), fractional);
-	}
-	else if(intPart < 2.0)
-	{
-		return lerp(Vec3(0.0, 0.0, 1.0), Vec3(0.0, 1.0, 0.0), fractional);
-	}
-	else if(intPart < 3.0)
-	{
-		return lerp(Vec3(0.0, 1.0, 0.0), Vec3(1.0, 1.0, 0.0), fractional);
-	}
-	else
-	{
-		return lerp(Vec3(1.0, 1.0, 0.0), Vec3(1.0, 0.0, 0.0), fractional);
-	}
-}
-
-// Return a color per cubemap face. The +X is red, -X dark red, +Y green, -Y dark green, +Z blue, -Z dark blue
-Vec3 colorPerCubeFace(const U32 dir)
-{
-	Vec3 color;
-	switch(dir)
-	{
-	case 0:
-		color = Vec3(1.0, 0.0, 0.0);
-		break;
-	case 1:
-		color = Vec3(0.25, 0.0, 0.0);
-		break;
-	case 2:
-		color = Vec3(0.0, 1.0, 0.0);
-		break;
-	case 3:
-		color = Vec3(0.0, 0.25, 0.0);
-		break;
-	case 4:
-		color = Vec3(0.0, 0.0, 1.0);
-		break;
-	default:
-		color = Vec3(0.0, 0.0, 0.25);
-	}
-	return color;
-}
-
-Bool incorrectColor(const Vec3 c)
-{
-	return isnan(c.x) || isnan(c.y) || isnan(c.z) || isinf(c.x) || isinf(c.y) || isinf(c.z);
-}
-
-F32 areaElement(const F32 x, const F32 y)
-{
-	return atan2(x * y, sqrt(x * x + y * y + 1.0));
-}
-
-// Compute the solid angle of a cube. Solid angle is the area of a sphere when projected into a cubemap. It's also the
-// delta omega (dω) in the irradiance integral and other integrals that operate in a sphere.
-// http://www.rorydriscoll.com/2012/01/15/cubemap-texel-solid-angle/
-F32 cubeCoordSolidAngle(Vec2 norm, F32 cubeFaceSize)
-{
-	const F32 s = 1.0f / cubeFaceSize;
-	const Vec2 invSize = Vec2(s, s);
-	const Vec2 v0 = norm - invSize;
-	const Vec2 v1 = norm + invSize;
-	return areaElement(v0.x, v0.y) - areaElement(v0.x, v1.y) - areaElement(v1.x, v0.y) + areaElement(v1.x, v1.y);
-}
-
-// A convenience function to skip out of bounds invocations on post-process compute shaders. Both the arguments should
-// be constexpr.
-#if defined(ANKI_COMPUTE_SHADER) && ANKI_GLSL
-Bool skipOutOfBoundsInvocations(UVec2 workgroupSize, UVec2 globalInvocationCount)
-{
-	if((globalInvocationCount.x % workgroupSize.x) != 0u || (globalInvocationCount.y % workgroupSize.y) != 0u)
-	{
-		if(gl_GlobalInvocationID.x >= globalInvocationCount.x || gl_GlobalInvocationID.y >= globalInvocationCount.y)
-		{
-			return true;
-		}
-	}
-
-	return false;
-}
-#endif
-
-// Create a matrix from some direction.
-Mat3 rotationFromDirection(Vec3 zAxis)
-{
-#if 0
-	const Vec3 z = zAxis;
-	const Bool alignsWithXBasis = abs(z.x - 1.0) <= kEpsilonf; // aka z == Vec3(1.0, 0.0, 0.0)
-	Vec3 x = (alignsWithXBasis) ? Vec3(0.0, 0.0, 1.0) : Vec3(1.0, 0.0, 0.0);
-	const Vec3 y = normalize(cross(x, z));
-	x = normalize(cross(z, y));
-	return Mat3(x, y, z);
-#else
-	// http://jcgt.org/published/0006/01/01/
-	const Vec3 z = zAxis;
-	const F32 sign = (z.z >= 0.0) ? 1.0 : -1.0;
-	const F32 a = -1.0 / (sign + z.z);
-	const F32 b = z.x * z.y * a;
-
-	const Vec3 x = Vec3(1.0 + sign * a * pow(z.x, 2.0), sign * b, -sign * z.x);
-	const Vec3 y = Vec3(b, sign + a * pow(z.y, 2.0), -z.y);
-
-	return Mat3(x, y, z);
-#endif
-}
-
-#if defined(ANKI_COMPUTE_SHADER) && ANKI_GLSL
-// See getOptimalGlobalInvocationId8x8Amd
-U32 _ABfiM(U32 src, U32 ins, U32 bits)
-{
-	const U32 mask = (1u << bits) - 1u;
-	return (ins & mask) | (src & (~mask));
-}
-
-// See getOptimalGlobalInvocationId8x8Amd
-U32 _ABfe(U32 src, U32 off, U32 bits)
-{
-	const U32 mask = (1u << bits) - 1u;
-	return (src >> off) & mask;
-}
-
-// See getOptimalGlobalInvocationId8x8Amd
-UVec2 _ARmpRed8x8(U32 a)
-{
-	return UVec2(_ABfiM(_ABfe(a, 2u, 3u), a, 1u), _ABfiM(_ABfe(a, 3u, 3u), _ABfe(a, 1u, 2u), 2u));
-}
-
-// https://github.com/GPUOpen-Effects/FidelityFX-CAS/blob/master/ffx-cas/ffx_a.h
-UVec2 getOptimalGlobalInvocationId8x8Amd()
-{
-	const UVec2 localInvocationId = _ARmpRed8x8(gl_LocalInvocationIndex);
-	return gl_WorkGroupID.xy * UVec2(8u) + localInvocationId;
-}
-
-// https://github.com/LouisBavoil/ThreadGroupIDSwizzling/blob/master/ThreadGroupTilingX.hlsl
-UVec2 getOptimalGlobalInvocationId8x8Nvidia()
-{
-	const U32 maxTileWidth = 8u;
-	const UVec2 workgroupSize = UVec2(8u);
-
-	const U32 workgroupsInAPerfectTile = maxTileWidth * gl_NumWorkGroups.y;
-
-	const U32 perfectTileCount = gl_NumWorkGroups.x / maxTileWidth;
-
-	const U32 totalWorkgroupsInAllPerfectTiles = perfectTileCount * maxTileWidth * gl_NumWorkGroups.y;
-	const U32 vThreadGroupIDFlattened = gl_NumWorkGroups.x * gl_WorkGroupID.y + gl_WorkGroupID.x;
-
-	const U32 tileIdOfCurrentWorkgroup = vThreadGroupIDFlattened / workgroupsInAPerfectTile;
-	const U32 localWorkgroupIdWithinCurrentTile = vThreadGroupIDFlattened % workgroupsInAPerfectTile;
-	U32 localWorkgroupIdYWithinCurrentTile;
-	U32 localWorgroupIdXWithinCurrentTile;
-
-	if(totalWorkgroupsInAllPerfectTiles <= vThreadGroupIDFlattened)
-	{
-		U32 xDimensionOfLastTile = gl_NumWorkGroups.x % maxTileWidth;
-		localWorkgroupIdYWithinCurrentTile = localWorkgroupIdWithinCurrentTile / xDimensionOfLastTile;
-		localWorgroupIdXWithinCurrentTile = localWorkgroupIdWithinCurrentTile % xDimensionOfLastTile;
-	}
-	else
-	{
-		localWorkgroupIdYWithinCurrentTile = localWorkgroupIdWithinCurrentTile / maxTileWidth;
-		localWorgroupIdXWithinCurrentTile = localWorkgroupIdWithinCurrentTile % maxTileWidth;
-	}
-
-	const U32 swizzledvThreadGroupIdFlattened = tileIdOfCurrentWorkgroup * maxTileWidth
-												+ localWorkgroupIdYWithinCurrentTile * gl_NumWorkGroups.x
-												+ localWorgroupIdXWithinCurrentTile;
-
-	UVec2 swizzledvThreadGroupId;
-	swizzledvThreadGroupId.y = swizzledvThreadGroupIdFlattened / gl_NumWorkGroups.x;
-	swizzledvThreadGroupId.x = swizzledvThreadGroupIdFlattened % gl_NumWorkGroups.x;
-
-	UVec2 swizzledGlobalId;
-	swizzledGlobalId.x = workgroupSize.x * swizzledvThreadGroupId.x + gl_LocalInvocationID.x;
-	swizzledGlobalId.y = workgroupSize.y * swizzledvThreadGroupId.y + gl_LocalInvocationID.y;
-
-	return swizzledGlobalId.xy;
-}
-#endif
-
-// Gaussian distrubution function
-F32 gaussianWeight(F32 s, F32 x)
-{
-	F32 p = 1.0 / (s * sqrt(2.0 * kPi));
-	p *= exp((x * x) / (-2.0 * s * s));
-	return p;
-}
-
-#if ANKI_GLSL
-Vec4 bilinearFiltering(texture2D tex, sampler nearestSampler, Vec2 uv, F32 lod, Vec2 textureSize)
-{
-	const Vec2 texelSize = 1.0 / textureSize;
-	const Vec2 unnormTexCoord = (uv * textureSize) - 0.5;
-	const Vec2 f = frac(unnormTexCoord);
-	const Vec2 snapTexCoord = (floor(unnormTexCoord) + 0.5) / textureSize;
-	const Vec4 s1 = textureLod(tex, nearestSampler, uv, lod);
-	const Vec4 s2 = textureLod(tex, nearestSampler, uv + Vec2(texelSize.x, 0.0), lod);
-	const Vec4 s3 = textureLod(tex, nearestSampler, uv + Vec2(0.0, texelSize.y), lod);
-	const Vec4 s4 = textureLod(tex, nearestSampler, uv + texelSize, lod);
-	return mix(mix(s1, s2, f.x), mix(s3, s4, f.x), f.y);
-}
-#endif
-
-// https://www.shadertoy.com/view/WsfBDf
-Vec3 animateBlueNoise(Vec3 inputBlueNoise, U32 frameIdx)
-{
-	const F32 goldenRatioConjugate = 0.61803398875;
-	return frac(inputBlueNoise + F32(frameIdx % 64u) * goldenRatioConjugate);
-}
-
-#if defined(ANKI_FRAGMENT_SHADER)
-/// https://bgolus.medium.com/distinctive-derivative-differences-cce38d36797b
-/// normalizedUvs is uv*textureResolution
-F32 computeMipLevel(Vec2 normalizedUvs)
-{
-	const Vec2 dx = dFdxCoarse(normalizedUvs);
-	const Vec2 dy = dFdyCoarse(normalizedUvs);
-	const F32 deltaMax2 = max(dot(dx, dx), dot(dy, dy));
-	return max(0.0, 0.5 * log2(deltaMax2));
-}
-#endif
-
-#if ANKI_GLSL
-#	if ANKI_SUPPORTS_64BIT_TYPES
-/// The regular findLSB in glslang has some issues since it invokes a builtin that is only supposed to be used with
-/// 32bit input. This is an alternative implementation but it expects that the input is not zero.
-I32 findLSB2(U64 v)
-{
-	const I32 lsb1 = findLSB(U32(v));
-	const I32 lsb2 = findLSB(U32(v >> 32ul));
-	return (lsb1 >= 0) ? lsb1 : lsb2 + 32;
-}
-#	endif
-
-/// Define an alternative findLSB to go in pair with the 64bit version.
-I32 findLSB2(U32 v)
-{
-	return findLSB(v);
-}
-#endif
-
-/// Encode the shading rate to be stored in an SRI. The rates should be power of two, can't be zero and can't exceed 4.
-/// So the possible values are 1,2,4
-U32 encodeVrsRate(UVec2 rateXY)
-{
-	return (rateXY.y >> 1u) | ((rateXY.x << 1u) & 12u);
-}
-
-Vec3 visualizeVrsRate(UVec2 rate)
-{
-	if(all(rate == UVec2(1u, 1u)))
-	{
-		return Vec3(1.0, 0.0, 0.0);
-	}
-	else if(all(rate == UVec2(2u, 1u)) || all(rate == UVec2(1u, 2u)))
-	{
-		return Vec3(1.0, 0.5, 0.0);
-	}
-	else if(all(rate == UVec2(2u, 2u)) || all(rate == UVec2(4u, 1u)) || all(rate == UVec2(1u, 4u)))
-	{
-		return Vec3(1.0, 1.0, 0.0);
-	}
-	else if(all(rate == UVec2(4u, 2u)) || all(rate == UVec2(2u, 4u)))
-	{
-		return Vec3(0.65, 1.0, 0.0);
-	}
-	else if(all(rate == UVec2(4u, 4u)))
-	{
-		return Vec3(0.0, 1.0, 0.0);
-	}
-	else
-	{
-		return Vec3(0.0, 0.0, 0.0);
-	}
-}
-
-/// Decodes a number produced by encodeVrsRate(). Returns the shading rates.
-UVec2 decodeVrsRate(U32 texel)
-{
-	UVec2 rateXY;
-	rateXY.x = 1u << ((texel >> 2u) & 3u);
-	rateXY.y = 1u << (texel & 3u);
-	return rateXY;
-}
-
-/// 3D coordinates to equirectangular 2D coordinates.
-Vec2 equirectangularMapping(Vec3 v)
-{
-	Vec2 uv = Vec2(atan2(v.z, v.x), asin(v.y));
-	uv *= Vec2(0.1591, 0.3183);
-	uv += 0.5;
-	return uv;
-}
-
-Vec3 linearToSRgb(Vec3 linearRgb)
-{
-	const F32 a = 6.10352e-5;
-	const F32 b = 1.0 / 2.4;
-	linearRgb = max(Vec3(a, a, a), linearRgb);
-	return min(linearRgb * 12.92, pow(max(linearRgb, 0.00313067), Vec3(b, b, b)) * 1.055 - 0.055);
-}
-
-Vec3 sRgbToLinear(Vec3 sRgb)
-{
-#if ANKI_GLSL
-	const bvec3 cutoff = lessThan(sRgb, Vec3(0.04045));
-	const Vec3 higher = pow((sRgb + 0.055) / 1.055, Vec3(2.4));
-	const Vec3 lower = sRgb / 12.92;
-	return mix(higher, lower, cutoff);
-#else
-	const bool3 cutoff = sRgb < Vec3(0.04045, 0.04045, 0.04045);
-	const Vec3 higher = pow((sRgb + 0.055) / 1.055, Vec3(2.4, 2.4, 2.4));
-	const Vec3 lower = sRgb / 12.92;
-	return lerp(higher, lower, cutoff);
-#endif
-}
-
-#if ANKI_GLSL
-ANKI_RP Vec3 filmGrain(ANKI_RP Vec3 color, Vec2 uv, ANKI_RP F32 strength, ANKI_RP F32 time)
-{
-	const F32 x = (uv.x + 4.0) * (uv.y + 4.0) * time;
-	const F32 grain = 1.0 - (mod((mod(x, 13.0) + 1.0) * (mod(x, 123.0) + 1.0), 0.01) - 0.005) * strength;
-	return color * grain;
-}
-#else
-template<typename TVec3, typename TFloat>
-TVec3 filmGrain(TVec3 color, Vec2 uv, TFloat strength, TFloat time)
-{
-	const TFloat x = (uv.x + 4.0) * (uv.y + 4.0) * time;
-	const TFloat grain = 1.0 - (mod((mod(x, 13.0) + 1.0) * (mod(x, 123.0) + 1.0), 0.01) - 0.005) * strength;
-	return color * grain;
-}
-#endif
-
-/// Sin approximation: https://www.desmos.com/calculator/svgcjfskne
-F32 fastSin(F32 x)
-{
-	const F32 k2Pi = 2.0 * kPi;
-	const F32 kPiOver2 = kPi / 2.0;
-
-	x = (x + kPiOver2) / (k2Pi) + 0.75;
-	x = frac(x);
-	x = x * 2.0 - 1.0;
-	x = x * abs(x) - x;
-	x *= 4.0;
-	return x;
-}
-
-/// Cos approximation
-F32 fastCos(F32 x)
-{
-	return fastSin(x + kPi / 2.0);
-}
-
-/// Transform using a 3x4 matrix. mat is row major.
-Vec3 transform(Vec4 mat[3u], Vec4 v)
-{
-	const F32 a = dot(mat[0], v);
-	const F32 b = dot(mat[1], v);
-	const F32 c = dot(mat[2], v);
-	return Vec3(a, b, c);
-}
-
-/// Rotate using a 3x3 matrix. mat is row major.
-Vec3 rotate(Vec3 mat[3u], Vec3 v)
-{
-	const F32 a = dot(mat[0], v);
-	const F32 b = dot(mat[1], v);
-	const F32 c = dot(mat[2], v);
-	return Vec3(a, b, c);
-}

+ 0 - 12
AnKi/Shaders/GaussianBlur.ankiprog

@@ -1,12 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma anki start vert
-#include <AnKi/Shaders/QuadVert.glsl>
-#pragma anki end
-
-#pragma anki start frag
-#include <AnKi/Shaders/GaussianBlur.glsl>
-#pragma anki end

+ 0 - 125
AnKi/Shaders/GaussianBlur.glsl

@@ -1,125 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#pragma anki mutator ORIENTATION 0 1 2 // 0: VERTICAL, 1: HORIZONTAL, 2: BOX
-#pragma anki mutator KERNEL_SIZE 3 5 7 9 11
-#pragma anki mutator COLOR_COMPONENTS 4 3 1
-
-#include <AnKi/Shaders/GaussianBlurCommon.glsl>
-
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(kTextureSize, 0u);
-
-#if defined(ANKI_COMPUTE_SHADER)
-const UVec2 kWorkgroupSize = UVec2(8, 8);
-#	define USE_COMPUTE 1
-#else
-#	define USE_COMPUTE 0
-#endif
-
-#if ORIENTATION == 0
-#	define VERTICAL 1
-#elif ORIENTATION == 1
-#	define HORIZONTAL 1
-#else
-#	define BOX 1
-#endif
-
-// Determine color type
-#if COLOR_COMPONENTS == 4
-#	define COL_TYPE Vec4
-#	define TEX_FETCH rgba
-#	define TO_VEC4(x_) x_
-#elif COLOR_COMPONENTS == 3
-#	define COL_TYPE Vec3
-#	define TEX_FETCH rgb
-#	define TO_VEC4(x_) Vec4(x_, 0.0)
-#elif COLOR_COMPONENTS == 1
-#	define COL_TYPE F32
-#	define TEX_FETCH r
-#	define TO_VEC4(x_) Vec4(x_, 0.0, 0.0, 0.0)
-#else
-#	error See file
-#endif
-
-layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
-layout(set = 0, binding = 1) uniform texture2D u_tex; ///< Input texture
-
-#if USE_COMPUTE
-layout(local_size_x = kWorkgroupSize.x, local_size_y = kWorkgroupSize.y, local_size_z = 1) in;
-layout(set = 0, binding = 2) writeonly uniform image2D u_outImg;
-#else
-layout(location = 0) in Vec2 in_uv;
-layout(location = 0) out COL_TYPE out_color;
-#endif
-
-void main()
-{
-	// Set UVs
-#if USE_COMPUTE
-	[branch] if(gl_GlobalInvocationID.x >= kTextureSize.x || gl_GlobalInvocationID.y >= kTextureSize.y)
-	{
-		// Out of bounds
-		return;
-	}
-
-	const Vec2 uv = (Vec2(gl_GlobalInvocationID.xy) + 0.5) / Vec2(kTextureSize);
-#else
-	const Vec2 uv = in_uv;
-#endif
-
-	const Vec2 TEXEL_SIZE = 1.0 / Vec2(kTextureSize);
-
-#if !defined(BOX)
-	// Do seperable
-
-#	if defined(HORIZONTAL)
-#		define X_OR_Y x
-#	else
-#		define X_OR_Y y
-#	endif
-
-	COL_TYPE color = textureLod(u_tex, u_linearAnyClampSampler, uv, 0.0).TEX_FETCH * kWeights[0u];
-
-	Vec2 uvOffset = Vec2(0.0);
-	uvOffset.X_OR_Y = 1.5 * TEXEL_SIZE.X_OR_Y;
-
-	[unroll] for(U32 i = 0u; i < kStepCount; ++i)
-	{
-		COL_TYPE col = textureLod(u_tex, u_linearAnyClampSampler, uv + uvOffset, 0.0).TEX_FETCH;
-		col += textureLod(u_tex, u_linearAnyClampSampler, uv - uvOffset, 0.0).TEX_FETCH;
-		color += kWeights[i + 1u] * col;
-
-		uvOffset.X_OR_Y += 2.0 * TEXEL_SIZE.X_OR_Y;
-	}
-#else
-	// Do box
-
-	const Vec2 OFFSET = 1.5 * TEXEL_SIZE;
-
-	COL_TYPE color = textureLod(u_tex, u_linearAnyClampSampler, uv, 0.0).TEX_FETCH * kBoxWeights[0u];
-
-	COL_TYPE col;
-	col = textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(OFFSET.x, 0.0), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(0.0, OFFSET.y), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(-OFFSET.x, 0.0), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(0.0, -OFFSET.y), 0.0).TEX_FETCH;
-	color += col * kBoxWeights[1u];
-
-	col = textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(+OFFSET.x, +OFFSET.y), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(+OFFSET.x, -OFFSET.y), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(-OFFSET.x, +OFFSET.y), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(-OFFSET.x, -OFFSET.y), 0.0).TEX_FETCH;
-	color += col * kBoxWeights[2u];
-#endif
-
-	// Write value
-#if USE_COMPUTE
-	imageStore(u_outImg, IVec2(gl_GlobalInvocationID.xy), TO_VEC4(color));
-#else
-	out_color = color;
-#endif
-}

+ 0 - 37
AnKi/Shaders/GaussianBlurCommon.glsl

@@ -1,37 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Common.glsl>
-
-#if KERNEL_SIZE == 3
-const U32 kStepCount = 1u;
-const F32 kWeights[kStepCount + 1u] = {0.361069, 0.319466};
-#elif KERNEL_SIZE == 5
-const U32 kStepCount = 2u;
-const F32 kWeights[kStepCount + 1u] = {0.250301, 0.221461, 0.153388};
-#elif KERNEL_SIZE == 7
-const U32 kStepCount = 3u;
-const F32 kWeights[kStepCount + 1u] = {0.214607, 0.189879, 0.131514, 0.071303};
-#elif KERNEL_SIZE == 9
-const U32 kStepCount = 4u;
-const F32 kWeights[kStepCount + 1u] = {0.20236, 0.179044, 0.124009, 0.067234, 0.028532};
-#elif KERNEL_SIZE == 11
-const U32 kStepCount = 5u;
-const F32 kWeights[kStepCount + 1u] = {0.198596, 0.175713, 0.121703, 0.065984, 0.028002, 0.0093};
-#endif
-
-// Imagine you are sampling a 3x3 area:
-// +-+-+-+
-// |c|b|c|
-// +-+-+-+
-// |b|a|b|
-// +-+-+-+
-// |c|b|c|
-// +-+-+-+
-// It's kBoxWeights[0] for the a texels. kBoxWeights[1] for the b texels. kBoxWeights[2] for the c texels.
-// Note: kBoxWeights[0] + kBoxWeights[1] * 4 + kBoxWeights[2] * 4 == 1.0
-const Vec3 kBoxWeights = Vec3(0.25, 0.125, 0.0625);

+ 0 - 8
AnKi/Shaders/GaussianBlurCompute.ankiprog

@@ -1,8 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma anki start comp
-#include <AnKi/Shaders/GaussianBlur.glsl>
-#pragma anki end

+ 0 - 77
AnKi/Shaders/ImportanceSampling.glsl

@@ -1,77 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-// NOTE: To visualize some of these functions go to https://www.shadertoy.com/view/wsBBzV
-
-#pragma once
-
-#include <AnKi/Shaders/Common.glsl>
-
-/// http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
-/// Using bitfieldReverse instead of bitwise ops
-F32 radicalInverseVdC(U32 bits)
-{
-	bits = bitfieldReverse(bits);
-	return F32(bits) * 2.3283064365386963e-10; // / 0x100000000
-}
-
-/// http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
-Vec2 hammersley2d(U32 i, U32 N)
-{
-	return Vec2(F32(i) / F32(N), radicalInverseVdC(i));
-}
-
-/// Stolen from Unreal
-/// Returns three elements with 16 random bits each (0-0xffff)
-UVec3 rand3DPCG16(UVec3 v)
-{
-	v = v * 1664525u + 1013904223u;
-
-	v.x += v.y * v.z;
-	v.y += v.z * v.x;
-	v.z += v.x * v.y;
-	v.x += v.y * v.z;
-	v.y += v.z * v.x;
-	v.z += v.x * v.y;
-
-	return v >> 16u;
-}
-
-/// Stolen from Unreal
-/// It will return a uniform 2D point inside [0.0, 1.0]. For random use rand3DPCG16()
-Vec2 hammersleyRandom16(U32 sampleIdx, U32 sampleCount, UVec2 random)
-{
-	const F32 e1 = fract(F32(sampleIdx) / F32(sampleCount) + F32(random.x) * (1.0 / 65536.0));
-	const F32 e2 = F32((bitfieldReverse(sampleIdx) >> 16u) ^ random.y) * (1.0 / 65536.0);
-	return Vec2(e1, e2);
-}
-
-/// http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
-/// From a uniform 2D point inside a circle get a 3D point in the surface of a hemisphere. It's oriented in the z axis
-Vec3 hemisphereSampleUniform(Vec2 uv)
-{
-	const F32 phi = uv.y * 2.0 * kPi;
-	const F32 cosTheta = 1.0 - uv.x;
-	const F32 sinTheta = sqrt(1.0 - cosTheta * cosTheta);
-	return Vec3(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta);
-}
-
-/// http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
-/// Same as hemisphereSampleUniform but it distributes points closer to the z axis
-Vec3 hemisphereSampleCos(Vec2 uv)
-{
-	const F32 phi = uv.y * 2.0 * kPi;
-	const F32 cosTheta = sqrt(1.0 - uv.x);
-	const F32 sinTheta = sqrt(1.0 - cosTheta * cosTheta);
-	return Vec3(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta);
-}
-
-/// PCG hash function.
-U32 hashPcg(U32 u)
-{
-	const U32 state = u * 747796405u + 2891336453u;
-	const U32 word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
-	return (word >> 22u) ^ word;
-}

+ 0 - 532
AnKi/Shaders/LightFunctions.glsl

@@ -1,532 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-// Contains functions for light calculations
-
-#pragma once
-
-#include <AnKi/Shaders/Functions.glsl>
-#include <AnKi/Shaders/CollisionFunctions.glsl>
-#include <AnKi/Shaders/PackFunctions.glsl>
-#include <AnKi/Shaders/Include/ClusteredShadingTypes.h>
-#include <AnKi/Shaders/Include/MiscRendererTypes.h>
-
-const Vec2 kPoissonDisk[4u] = {Vec2(-0.94201624, -0.39906216), Vec2(0.94558609, -0.76890725),
-							   Vec2(-0.094184101, -0.92938870), Vec2(0.34495938, 0.29387760)};
-const ANKI_RP F32 kPcfScale = 2.0f;
-
-// Fresnel term unreal
-// specular: The specular color aka F0
-Vec3 F_Unreal(Vec3 specular, F32 VoH)
-{
-	return specular + (1.0 - specular) * pow(2.0, (-5.55473 * VoH - 6.98316) * VoH);
-}
-
-// Fresnel Schlick: "An Inexpensive BRDF Model for Physically-Based Rendering"
-// It has lower VGRPs than F_Unreal
-ANKI_RP Vec3 F_Schlick(ANKI_RP Vec3 f0, ANKI_RP F32 VoH)
-{
-	const ANKI_RP F32 f = pow(1.0 - VoH, 5.0);
-	return f + f0 * (1.0 - f);
-}
-
-// D(n,h) aka NDF: GGX Trowbridge-Reitz
-ANKI_RP F32 D_GGX(ANKI_RP F32 roughness, ANKI_RP F32 NoH, ANKI_RP Vec3 h, ANKI_RP Vec3 worldNormal)
-{
-#if 0 && ANKI_PLATFORM_MOBILE
-	const ANKI_RP Vec3 NxH = cross(worldNormal, h);
-	const ANKI_RP F32 oneMinusNoHSquared = dot(NxH, NxH);
-#else
-	const ANKI_RP F32 oneMinusNoHSquared = 1.0 - NoH * NoH;
-#endif
-
-	const ANKI_RP F32 a = roughness * roughness;
-	const ANKI_RP F32 v = NoH * a;
-	const ANKI_RP F32 k = a / (oneMinusNoHSquared + v * v);
-	const ANKI_RP F32 d = k * k * (1.0 / kPi);
-	return saturateRp(d);
-}
-
-// Visibility term: Geometric shadowing divided by BRDF denominator
-ANKI_RP F32 V_Schlick(ANKI_RP F32 roughness, ANKI_RP F32 NoV, ANKI_RP F32 NoL)
-{
-	const ANKI_RP F32 k = (roughness * roughness) * 0.5;
-	const ANKI_RP F32 Vis_SchlickV = NoV * (1.0 - k) + k;
-	const ANKI_RP F32 Vis_SchlickL = NoL * (1.0 - k) + k;
-	return 0.25 / (Vis_SchlickV * Vis_SchlickL);
-}
-
-// Visibility term: Hammon 2017, "PBR Diffuse Lighting for GGX+Smith Microsurfaces"
-ANKI_RP F32 V_SmithGGXCorrelatedFast(ANKI_RP F32 roughness, ANKI_RP F32 NoV, ANKI_RP F32 NoL)
-{
-	const ANKI_RP F32 a = roughness * roughness;
-	const ANKI_RP F32 v = 0.5 / mix(2.0 * NoL * NoV, NoL + NoV, a);
-	return saturateRp(v);
-}
-
-ANKI_RP F32 Fd_Lambert()
-{
-	return 1.0 / kPi;
-}
-
-ANKI_RP Vec3 diffuseLobe(ANKI_RP Vec3 diffuse)
-{
-	return diffuse * Fd_Lambert();
-}
-
-// Performs BRDF specular lighting
-ANKI_RP Vec3 specularIsotropicLobe(GbufferInfo gbuffer, Vec3 viewDir, Vec3 frag2Light)
-{
-	const ANKI_RP Vec3 H = normalize(frag2Light + viewDir);
-
-	const ANKI_RP F32 NoL = max(0.0, dot(gbuffer.m_normal, frag2Light));
-	const ANKI_RP F32 VoH = max(0.0, dot(viewDir, H));
-	const ANKI_RP F32 NoH = max(0.0, dot(gbuffer.m_normal, H));
-	const ANKI_RP F32 NoV = max(0.05, dot(gbuffer.m_normal, viewDir));
-
-	// F
-	const ANKI_RP Vec3 F = F_Schlick(gbuffer.m_f0, VoH);
-
-	// D
-	const ANKI_RP F32 D = D_GGX(gbuffer.m_roughness, NoH, H, gbuffer.m_normal);
-
-	// Vis
-	const ANKI_RP F32 V = V_SmithGGXCorrelatedFast(gbuffer.m_roughness, NoV, NoL);
-
-	return F * (V * D);
-}
-
-Vec3 specularDFG(Vec3 F0, F32 roughness, texture2D integrationLut, sampler integrationLutSampler, F32 NoV)
-{
-	const Vec2 envBRDF = textureLod(integrationLut, integrationLutSampler, Vec2(roughness, NoV), 0.0).xy;
-	return mix(envBRDF.xxx, envBRDF.yyy, F0);
-}
-
-ANKI_RP F32 computeSpotFactor(ANKI_RP Vec3 l, ANKI_RP F32 outerCos, ANKI_RP F32 innerCos, ANKI_RP Vec3 spotDir)
-{
-	const ANKI_RP F32 costheta = -dot(l, spotDir);
-	const ANKI_RP F32 spotFactor = smoothstep(outerCos, innerCos, costheta);
-	return spotFactor;
-}
-
-ANKI_RP F32 computeShadowFactorSpotLightPcf(SpotLight light, Vec3 worldPos, texture2D shadowTex,
-											samplerShadow shadowMapSampler, ANKI_RP F32 randFactor)
-{
-	const Vec4 texCoords4 = light.m_textureMatrix * Vec4(worldPos, 1.0);
-	const Vec3 texCoords3 = texCoords4.xyz / texCoords4.w;
-
-	const Vec2 smTexelSize = 1.0 / Vec2(textureSize(shadowTex, 0).xy);
-
-	const F32 sinTheta = sin(randFactor * 2.0 * kPi);
-	const F32 cosTheta = cos(randFactor * 2.0 * kPi);
-
-	ANKI_RP F32 shadow = 0.0;
-	[unroll] for(U32 i = 0u; i < 4u; ++i)
-	{
-		const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
-
-		// Rotate the disk point
-		Vec2 rotatedDiskPoint;
-		rotatedDiskPoint.x = diskPoint.x * cosTheta - diskPoint.y * sinTheta;
-		rotatedDiskPoint.y = diskPoint.y * cosTheta + diskPoint.x * sinTheta;
-
-		// Offset calculation
-		const Vec2 newUv = texCoords3.xy + rotatedDiskPoint * smTexelSize;
-
-		shadow += textureLod(shadowTex, shadowMapSampler, Vec3(newUv, texCoords3.z), 0.0);
-	}
-
-	shadow /= 4.0;
-
-	return shadow;
-}
-
-ANKI_RP F32 computeShadowFactorSpotLight(SpotLight light, Vec3 worldPos, texture2D shadowTex,
-										 samplerShadow shadowMapSampler)
-{
-	const Vec4 texCoords4 = light.m_textureMatrix * Vec4(worldPos, 1.0);
-	const Vec3 texCoords3 = texCoords4.xyz / texCoords4.w;
-	return textureLod(shadowTex, shadowMapSampler, texCoords3, 0.0);
-}
-
-// Compute the shadow factor of point (omni) lights.
-ANKI_RP F32 computeShadowFactorPointLightGeneric(PointLight light, Vec3 frag2Light, texture2D shadowMap,
-												 samplerShadow shadowMapSampler, ANKI_RP F32 randFactor, Bool pcf)
-{
-	const Vec3 dir = -frag2Light;
-	const Vec3 dirabs = abs(dir);
-	const F32 dist = max(dirabs.x, max(dirabs.y, dirabs.z));
-
-	// 1) Project the dist to light's proj mat
-	//
-	const F32 near = kClusterObjectFrustumNearPlane;
-	const F32 far = light.m_radius;
-	const F32 g = near - far;
-
-	const F32 zVSpace = -dist;
-	const F32 w = -zVSpace;
-	F32 z = (far * zVSpace + far * near) / g;
-	z /= w;
-
-	// 2) Read shadow tex
-	//
-
-	// Convert cube coords
-	U32 faceIdxu;
-	Vec2 uv = convertCubeUvsu(dir, faceIdxu);
-
-	// Get the atlas offset
-	const Vec2 atlasOffset = light.m_shadowAtlasTileOffsets[faceIdxu].xy;
-
-	// Compute UV
-	uv *= Vec2(light.m_shadowAtlasTileScale);
-	uv += atlasOffset;
-
-	// Sample
-	ANKI_RP F32 shadow;
-	if(pcf)
-	{
-		const Vec2 smTexelSize = 1.0 / Vec2(textureSize(shadowMap, 0).xy);
-
-		const F32 sinTheta = sin(randFactor * 2.0 * kPi);
-		const F32 cosTheta = cos(randFactor * 2.0 * kPi);
-
-		shadow = 0.0;
-		[unroll] for(U32 i = 0u; i < 4u; ++i)
-		{
-			const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
-
-			// Rotate the disk point
-			Vec2 rotatedDiskPoint;
-			rotatedDiskPoint.x = diskPoint.x * cosTheta - diskPoint.y * sinTheta;
-			rotatedDiskPoint.y = diskPoint.y * cosTheta + diskPoint.x * sinTheta;
-
-			// Offset calculation
-			const Vec2 newUv = uv + rotatedDiskPoint * smTexelSize;
-
-			shadow += textureLod(shadowMap, shadowMapSampler, Vec3(newUv, z), 0.0);
-		}
-
-		shadow /= 4.0;
-	}
-	else
-	{
-		shadow = textureLod(shadowMap, shadowMapSampler, Vec3(uv, z), 0.0);
-	}
-
-	return shadow;
-}
-
-ANKI_RP F32 computeShadowFactorPointLight(PointLight light, Vec3 frag2Light, texture2D shadowMap,
-										  samplerShadow shadowMapSampler)
-{
-	return computeShadowFactorPointLightGeneric(light, frag2Light, shadowMap, shadowMapSampler, -1.0, false);
-}
-
-ANKI_RP F32 computeShadowFactorPointLightPcf(PointLight light, Vec3 frag2Light, texture2D shadowMap,
-											 samplerShadow shadowMapSampler, ANKI_RP F32 randFactor)
-{
-	return computeShadowFactorPointLightGeneric(light, frag2Light, shadowMap, shadowMapSampler, randFactor, true);
-}
-
-// Compute the shadow factor of a directional light
-ANKI_RP F32 computeShadowFactorDirLightGeneric(DirectionalLight light, U32 cascadeIdx, Vec3 worldPos,
-											   texture2D shadowMap, samplerShadow shadowMapSampler,
-											   ANKI_RP F32 randFactor, Bool pcf)
-{
-#define ANKI_FAST_CASCADES_WORKAROUND 1 // Doesn't make sense but it's super fast
-
-#if ANKI_FAST_CASCADES_WORKAROUND
-	// Assumes kMaxShadowCascades is 4
-	Mat4 lightProjectionMat;
-	switch(cascadeIdx)
-	{
-	case 0:
-		lightProjectionMat = light.m_textureMatrices[0];
-		break;
-	case 1:
-		lightProjectionMat = light.m_textureMatrices[1];
-		break;
-	case 2:
-		lightProjectionMat = light.m_textureMatrices[2];
-		break;
-	default:
-		lightProjectionMat = light.m_textureMatrices[3];
-	}
-#else
-	const Mat4 lightProjectionMat = light.m_textureMatrices[cascadeIdx];
-#endif
-
-	const Vec4 texCoords4 = lightProjectionMat * Vec4(worldPos, 1.0);
-	Vec3 texCoords3 = texCoords4.xyz / texCoords4.w;
-
-	ANKI_RP F32 shadow;
-	if(pcf)
-	{
-		const Vec2 smTexelSize = 1.0 / Vec2(textureSize(shadowMap, 0).xy);
-
-		const F32 sinTheta = sin(randFactor * 2.0 * kPi);
-		const F32 cosTheta = cos(randFactor * 2.0 * kPi);
-
-		shadow = 0.0;
-		[unroll] for(U32 i = 0u; i < 4u; ++i)
-		{
-			const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
-
-			// Rotate the disk point
-			Vec2 rotatedDiskPoint;
-			rotatedDiskPoint.x = diskPoint.x * cosTheta - diskPoint.y * sinTheta;
-			rotatedDiskPoint.y = diskPoint.y * cosTheta + diskPoint.x * sinTheta;
-
-			// Offset calculation
-			Vec2 newUv = texCoords3.xy + rotatedDiskPoint * smTexelSize;
-
-			shadow += textureLod(shadowMap, shadowMapSampler, Vec3(newUv, texCoords3.z), 0.0);
-		}
-
-		shadow /= 4.0;
-	}
-	else
-	{
-		shadow = textureLod(shadowMap, shadowMapSampler, texCoords3, 0.0);
-	}
-
-	return shadow;
-}
-
-ANKI_RP F32 computeShadowFactorDirLight(DirectionalLight light, U32 cascadeIdx, Vec3 worldPos, texture2D shadowMap,
-										samplerShadow shadowMapSampler)
-{
-	return computeShadowFactorDirLightGeneric(light, cascadeIdx, worldPos, shadowMap, shadowMapSampler, -1.0, false);
-}
-
-ANKI_RP F32 computeShadowFactorDirLightPcf(DirectionalLight light, U32 cascadeIdx, Vec3 worldPos, texture2D shadowMap,
-										   samplerShadow shadowMapSampler, F32 randFactor)
-{
-	return computeShadowFactorDirLightGeneric(light, cascadeIdx, worldPos, shadowMap, shadowMapSampler, randFactor,
-											  true);
-}
-
-// Compute the shadow factor of a directional light
-ANKI_RP F32 computeShadowFactorDirLight(Mat4 lightProjectionMat, Vec3 worldPos, texture2D shadowMap,
-										samplerShadow shadowMapSampler)
-{
-	const Vec4 texCoords4 = lightProjectionMat * Vec4(worldPos, 1.0);
-	const Vec3 texCoords3 = texCoords4.xyz / texCoords4.w;
-
-	const ANKI_RP F32 shadowFactor = textureLod(shadowMap, shadowMapSampler, texCoords3, 0.0);
-	return shadowFactor;
-}
-
-// Compute the cubemap texture lookup vector given the reflection vector (r) the radius squared of the probe (R2) and
-// the frag pos in sphere space (f)
-Vec3 computeCubemapVecAccurate(Vec3 r, F32 R2, Vec3 f)
-{
-	// Compute the collision of the r to the inner part of the sphere
-	// From now on we work on the sphere's space
-
-	// Project the center of the sphere (it's zero now since we are in sphere space) in ray "f,r"
-	const Vec3 p = f - r * dot(f, r);
-
-	// The collision to the sphere is point x where x = p + T * r
-	// Because of the pythagorean theorem: R^2 = dot(p, p) + dot(T * r, T * r)
-	// solving for T, T = R / |p|
-	// then x becomes x = sqrt(R^2 - dot(p, p)) * r + p;
-	F32 pp = dot(p, p);
-	pp = min(pp, R2);
-	const F32 sq = sqrt(R2 - pp);
-	const Vec3 x = p + sq * r;
-
-	return x;
-}
-
-// Cheap version of computeCubemapVecAccurate
-Vec3 computeCubemapVecCheap(Vec3 r, F32 R2, Vec3 f)
-{
-	return r;
-}
-
-ANKI_RP F32 computeAttenuationFactor(ANKI_RP F32 squareRadiusOverOne, ANKI_RP Vec3 frag2Light)
-{
-	const ANKI_RP F32 fragLightDist = dot(frag2Light, frag2Light);
-	ANKI_RP F32 att = 1.0 - fragLightDist * squareRadiusOverOne;
-	att = max(0.0, att);
-	return att * att;
-}
-
-// Given the probe properties trace a ray inside the probe and find the cube tex coordinates to sample
-Vec3 intersectProbe(Vec3 fragPos, // Ray origin
-					Vec3 rayDir, // Ray direction
-					Vec3 probeAabbMin, Vec3 probeAabbMax,
-					Vec3 probeOrigin // Cubemap origin
-)
-{
-	// Compute the intersection point
-	const F32 intresectionDist = testRayAabbInside(fragPos, rayDir, probeAabbMin, probeAabbMax);
-	const Vec3 intersectionPoint = fragPos + intresectionDist * rayDir;
-
-	// Compute the cubemap vector
-	return intersectionPoint - probeOrigin;
-}
-
-// Compute a weight (factor) of fragPos against some probe's bounds. The weight will be zero when fragPos is close to
-// AABB bounds and 1.0 at fadeDistance and less.
-F32 computeProbeBlendWeight(Vec3 fragPos, // Doesn't need to be inside the AABB
-							Vec3 probeAabbMin, Vec3 probeAabbMax, F32 fadeDistance)
-{
-	// Compute the min distance of fragPos from the edges of the AABB
-	const Vec3 distFromMin = fragPos - probeAabbMin;
-	const Vec3 distFromMax = probeAabbMax - fragPos;
-	const Vec3 minDistVec = min(distFromMin, distFromMax);
-	const F32 minDist = min(minDistVec.x, min(minDistVec.y, minDistVec.z));
-
-	// Use saturate because minDist might be negative.
-	return saturate(minDist / fadeDistance);
-}
-
-// Given the value of the 6 faces of the dice and a normal, sample the correct weighted value.
-// https://www.shadertoy.com/view/XtcBDB
-ANKI_RP Vec3 sampleAmbientDice(ANKI_RP Vec3 posx, ANKI_RP Vec3 negx, ANKI_RP Vec3 posy, ANKI_RP Vec3 negy,
-							   ANKI_RP Vec3 posz, ANKI_RP Vec3 negz, ANKI_RP Vec3 normal)
-{
-	const ANKI_RP Vec3 axisWeights = abs(normal);
-	const ANKI_RP Vec3 uv = NDC_TO_UV(normal);
-
-	ANKI_RP Vec3 col = mix(negx, posx, uv.x) * axisWeights.x;
-	col += mix(negy, posy, uv.y) * axisWeights.y;
-	col += mix(negz, posz, uv.z) * axisWeights.z;
-
-	// Divide by weight
-	col /= axisWeights.x + axisWeights.y + axisWeights.z + kEpsilonRp;
-
-	return col;
-}
-
-// Sample the irradiance term from the clipmap
-ANKI_RP Vec3 sampleGlobalIllumination(const Vec3 worldPos, const Vec3 normal, const GlobalIlluminationProbe probe,
-									  ANKI_RP texture3D textures[kMaxVisibleGlobalIlluminationProbes],
-									  sampler linearAnyClampSampler)
-{
-	// Find the UVW
-	Vec3 uvw = (worldPos - probe.m_aabbMin) / (probe.m_aabbMax - probe.m_aabbMin);
-
-	// The U contains the 6 directions so divide
-	uvw.x /= 6.0;
-
-	// Calmp it to avoid direction leaking
-	uvw.x = clamp(uvw.x, probe.m_halfTexelSizeU, (1.0 / 6.0) - probe.m_halfTexelSizeU);
-
-	// Read the irradiance
-	ANKI_RP Vec3 irradiancePerDir[6u];
-	[unroll] for(U32 dir = 0u; dir < 6u; ++dir)
-	{
-		// Point to the correct UV
-		Vec3 shiftedUVw = uvw;
-		shiftedUVw.x += (1.0 / 6.0) * F32(dir);
-
-		irradiancePerDir[dir] =
-			textureLod(textures[nonuniformEXT(probe.m_textureIndex)], linearAnyClampSampler, shiftedUVw, 0.0).rgb;
-	}
-
-	// Sample the irradiance
-	const ANKI_RP Vec3 irradiance =
-		sampleAmbientDice(irradiancePerDir[0], irradiancePerDir[1], irradiancePerDir[2], irradiancePerDir[3],
-						  irradiancePerDir[4], irradiancePerDir[5], normal);
-
-	return irradiance;
-}
-
-/// To play with it use https://www.shadertoy.com/view/sttSDf
-/// http://jcgt.org/published/0007/04/01/paper.pdf by Eric Heitz
-/// Input v: view direction
-/// Input alphaX, alphaY: roughness parameters
-/// Input u1, u2: uniform random numbers
-/// Output: normal sampled with PDF D_Ve(nE) = G1(v) * max(0, dot(v, nE)) * D(nE) / v.z
-Vec3 sampleGgxVndf(Vec3 v, F32 alphaX, F32 alphaY, F32 u1, F32 u2)
-{
-	// Section 3.2: transforming the view direction to the hemisphere configuration
-	const Vec3 vH = normalize(Vec3(alphaX * v.x, alphaY * v.y, v.z));
-
-	// Section 4.1: orthonormal basis (with special case if cross product is zero)
-	const F32 lensq = vH.x * vH.x + vH.y * vH.y;
-	const Vec3 tangent1 = (lensq > 0.0) ? Vec3(-vH.y, vH.x, 0) * inversesqrt(lensq) : Vec3(1.0, 0.0, 0.0);
-	const Vec3 tangent2 = cross(vH, tangent1);
-
-	// Section 4.2: parameterization of the projected area
-	const F32 r = sqrt(u1);
-	const F32 phi = 2.0 * kPi * u2;
-	const F32 t1 = r * cos(phi);
-	F32 t2 = r * sin(phi);
-	const F32 s = 0.5 * (1.0 + vH.z);
-	t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
-
-	// Section 4.3: reprojection onto hemisphere
-	const Vec3 nH = t1 * tangent1 + t2 * tangent2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * vH;
-
-	// Section 3.4: transforming the normal back to the ellipsoid configuration
-	const Vec3 nE = normalize(Vec3(alphaX * nH.x, alphaY * nH.y, max(0.0, nH.z)));
-
-	return nE;
-}
-
-/// Calculate the reflection vector based on roughness.
-Vec3 sampleReflectionVector(Vec3 viewDir, Vec3 normal, F32 roughness, Vec2 uniformRandom)
-{
-	const Mat3 tbn = rotationFromDirection(normal);
-	const Mat3 tbnT = transpose(tbn);
-	const Vec3 viewDirTbn = tbnT * viewDir;
-
-	Vec3 sampledNormalTbn = sampleGgxVndf(viewDirTbn, roughness, roughness, uniformRandom.x, uniformRandom.y);
-	const Bool perfectReflection = false; // For debugging
-	if(perfectReflection)
-	{
-		sampledNormalTbn = Vec3(0.0, 0.0, 1.0);
-	}
-
-	const Vec3 reflectedDirTbn = reflect(-viewDirTbn, sampledNormalTbn);
-
-	// Transform reflected_direction back to the initial space.
-	return tbn * reflectedDirTbn;
-}
-
-/// Get the index of the cascade given the distance from zero.
-U32 computeShadowCascadeIndex(F32 distance, Vec4 cascadeDistances, U32 shadowCascadeCount)
-{
-	U32 cascade;
-	if(distance < cascadeDistances[0u])
-	{
-		cascade = 0u;
-	}
-	else if(distance < cascadeDistances[1u])
-	{
-		cascade = 1u;
-	}
-	else if(distance < cascadeDistances[2u])
-	{
-		cascade = 2u;
-	}
-	else
-	{
-		cascade = 3u;
-	}
-
-	return min(shadowCascadeCount - 1u, cascade);
-}
-
-/// Bring the indices of the closest cascades and a factor to blend them. To visualize what's going on go to:
-/// https://www.desmos.com/calculator/g1ibye6ebg
-UVec2 computeShadowCascadeIndex2(F32 distance, Vec4 cascadeDistances, U32 shadowCascadeCount, out ANKI_RP F32 factor)
-{
-	const U32 cascade = computeShadowCascadeIndex(distance, cascadeDistances, shadowCascadeCount);
-	const U32 nextCascade = min(cascade + 1u, shadowCascadeCount - 1u);
-
-	const F32 minDist = (cascade == 0u) ? 0.0f : cascadeDistances[cascade - 1u];
-	const F32 maxDist = cascadeDistances[cascade];
-
-	factor = (distance - minDist) / max(kEpsilonf, maxDist - minDist);
-	factor = pow(factor, 16.0f);
-
-	return UVec2(cascade, nextCascade);
-}

+ 0 - 195
AnKi/Shaders/PackFunctions.glsl

@@ -1,195 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Common.glsl>
-#include <AnKi/Shaders/TonemappingFunctions.glsl>
-
-const ANKI_RP F32 kMinRoughness = 0.05;
-
-/// Pack 3D normal to 2D vector
-/// See the clean code in comments in revision < r467
-Vec2 packNormal(const Vec3 normal)
-{
-	const F32 scale = 1.7777;
-	const F32 scalar1 = (normal.z + 1.0) * (scale * 2.0);
-	return normal.xy / scalar1 + 0.5;
-}
-
-/// Reverse the packNormal
-Vec3 unpackNormal(const Vec2 enc)
-{
-	const F32 scale = 1.7777;
-	const Vec2 nn = enc * (2.0 * scale) - scale;
-	const F32 g = 2.0 / (dot(nn.xy, nn.xy) + 1.0);
-	Vec3 normal;
-	normal.xy = g * nn.xy;
-	normal.z = g - 1.0;
-	return normalize(normal);
-}
-
-// See http://johnwhite3d.blogspot.no/2017/10/signed-octahedron-normal-encoding.html
-// Result in [0.0, 1.0]
-Vec3 signedOctEncode(Vec3 n)
-{
-	Vec3 outn;
-
-	const Vec3 nabs = abs(n);
-	n /= nabs.x + nabs.y + nabs.z;
-
-	outn.y = n.y * 0.5 + 0.5;
-	outn.x = n.x * 0.5 + outn.y;
-	outn.y = n.x * -0.5 + outn.y;
-
-	outn.z = saturate(n.z * kMaxF32);
-	return outn;
-}
-
-// See http://johnwhite3d.blogspot.no/2017/10/signed-octahedron-normal-encoding.html
-Vec3 signedOctDecode(const Vec3 n)
-{
-	Vec3 outn;
-
-	outn.x = n.x - n.y;
-	outn.y = n.x + n.y - 1.0;
-	outn.z = n.z * 2.0 - 1.0;
-	outn.z = outn.z * (1.0 - abs(outn.x) - abs(outn.y));
-
-	outn = normalize(outn);
-	return outn;
-}
-
-// Vectorized version. Assumes that v is in [0.0, 1.0]
-U32 newPackUnorm4x8(const Vec4 v)
-{
-	Vec4 a = v * 255.0;
-	UVec4 b = UVec4(a) << UVec4(0u, 8u, 16u, 24u);
-	UVec2 c = b.xy | b.zw;
-	return c.x | c.y;
-}
-
-// Vectorized version
-Vec4 newUnpackUnorm4x8(const U32 u)
-{
-	const UVec4 a = UVec4(u) >> UVec4(0u, 8u, 16u, 24u);
-	const UVec4 b = a & UVec4(0xFFu);
-	const Vec4 c = Vec4(b);
-	return c * (1.0 / 255.0);
-}
-
-// Convert from RGB to YCbCr.
-// The RGB should be in [0, 1] and the output YCbCr will be in [0, 1] as well.
-Vec3 rgbToYCbCr(const Vec3 rgb)
-{
-	const F32 y = dot(rgb, Vec3(0.299, 0.587, 0.114));
-	const F32 cb = 0.5 + dot(rgb, Vec3(-0.168736, -0.331264, 0.5));
-	const F32 cr = 0.5 + dot(rgb, Vec3(0.5, -0.418688, -0.081312));
-	return Vec3(y, cb, cr);
-}
-
-// Convert the output of rgbToYCbCr back to RGB.
-Vec3 yCbCrToRgb(const Vec3 ycbcr)
-{
-	const F32 cb = ycbcr.y - 0.5;
-	const F32 cr = ycbcr.z - 0.5;
-	const F32 y = ycbcr.x;
-	const F32 r = 1.402 * cr;
-	const F32 g = -0.344 * cb - 0.714 * cr;
-	const F32 b = 1.772 * cb;
-	return Vec3(r, g, b) + y;
-}
-
-// Pack a Vec2 to a single F32.
-// comp should be in [0, 1] and the output will be in [0, 1].
-F32 packUnorm2ToUnorm1(const Vec2 comp)
-{
-	return dot(round(comp * 15.0), Vec2(1.0 / (255.0 / 16.0), 1.0 / 255.0));
-}
-
-// Unpack a single F32 to Vec2. Does the oposite of packUnorm2ToUnorm1.
-Vec2 unpackUnorm1ToUnorm2(F32 c)
-{
-#if 1
-	const F32 temp = c * (255.0 / 16.0);
-	const F32 a = floor(temp);
-	const F32 b = temp - a; // b = fract(temp)
-	return Vec2(a, b) * Vec2(1.0 / 15.0, 16.0 / 15.0);
-#else
-	const U32 temp = U32(c * 255.0);
-	const U32 a = temp >> 4;
-	const U32 b = temp & 0xF;
-	return Vec2(a, b) / 15.0;
-#endif
-}
-
-// G-Buffer structure
-struct GbufferInfo
-{
-	ANKI_RP Vec3 m_diffuse;
-	ANKI_RP Vec3 m_f0; ///< Freshnel at zero angles.
-	ANKI_RP Vec3 m_normal;
-	ANKI_RP F32 m_roughness;
-	ANKI_RP F32 m_metallic;
-	ANKI_RP F32 m_subsurface;
-	ANKI_RP Vec3 m_emission;
-	Vec2 m_velocity;
-};
-
-// Populate the G buffer
-void packGBuffer(GbufferInfo g, out Vec4 rt0, out Vec4 rt1, out Vec4 rt2, out Vec2 rt3)
-{
-	const F32 packedSubsurfaceMetallic = packUnorm2ToUnorm1(Vec2(g.m_subsurface, g.m_metallic));
-
-	const Vec3 tonemappedEmission = reinhardTonemap(g.m_emission);
-
-	rt0 = Vec4(g.m_diffuse, packedSubsurfaceMetallic);
-	rt1 = Vec4(g.m_roughness, g.m_f0.x, tonemappedEmission.rb);
-
-	const Vec3 encNorm = signedOctEncode(g.m_normal);
-	rt2 = Vec4(tonemappedEmission.g, encNorm);
-
-	rt3 = g.m_velocity;
-}
-
-ANKI_RP Vec3 unpackDiffuseFromGBuffer(ANKI_RP Vec4 rt0, ANKI_RP F32 metallic)
-{
-	return rt0.xyz *= 1.0 - metallic;
-}
-
-ANKI_RP Vec3 unpackNormalFromGBuffer(ANKI_RP Vec4 rt2)
-{
-	return signedOctDecode(rt2.yzw);
-}
-
-ANKI_RP F32 unpackRoughnessFromGBuffer(ANKI_RP Vec4 rt1)
-{
-	ANKI_RP F32 r = rt1.x;
-	r = r * (1.0 - kMinRoughness) + kMinRoughness;
-	return r;
-}
-
-// Read part of the G-buffer
-void unpackGBufferNoVelocity(ANKI_RP Vec4 rt0, ANKI_RP Vec4 rt1, ANKI_RP Vec4 rt2, out GbufferInfo g)
-{
-	g.m_diffuse = rt0.xyz;
-	const Vec2 unpackedSubsurfaceMetallic = unpackUnorm1ToUnorm2(rt0.w);
-	g.m_subsurface = unpackedSubsurfaceMetallic.x;
-	g.m_metallic = unpackedSubsurfaceMetallic.y;
-
-	g.m_roughness = unpackRoughnessFromGBuffer(rt1);
-	g.m_f0 = Vec3(rt1.y);
-	g.m_emission = invertReinhardTonemap(Vec3(rt1.z, rt2.x, rt1.w));
-
-	g.m_normal = signedOctDecode(rt2.yzw);
-
-	g.m_velocity = Vec2(kMaxF32); // Put something random
-
-	// Compute reflectance
-	g.m_f0 = mix(g.m_f0, g.m_diffuse, g.m_metallic);
-
-	// Compute diffuse
-	g.m_diffuse *= 1.0 - g.m_metallic;
-}

+ 0 - 16
AnKi/Shaders/QuadVert.glsl

@@ -1,16 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Shaders/Common.glsl>
-
-layout(location = 0) out Vec2 out_uv;
-
-void main()
-{
-	out_uv = Vec2(gl_VertexIndex & 1, gl_VertexIndex >> 1) * 2.0;
-	const Vec2 pos = out_uv * 2.0 - 1.0;
-
-	gl_Position = Vec4(pos, 0.0, 1.0);
-}

+ 0 - 40
AnKi/Shaders/RtShadows.glsl

@@ -1,40 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Include/MiscRendererTypes.h>
-#include <AnKi/Shaders/PackFunctions.glsl>
-
-const F32 kRtShadowsMaxHistoryLength = 16.0;
-
-UVec4 packRtShadows(F32 shadowFactors[kMaxRtShadowLayers])
-{
-	const U32 a = newPackUnorm4x8(Vec4(shadowFactors[0], shadowFactors[1], shadowFactors[2], shadowFactors[3]));
-	const U32 b = newPackUnorm4x8(Vec4(shadowFactors[4], shadowFactors[5], shadowFactors[6], shadowFactors[7]));
-	return UVec4(a, b, 0, 0);
-}
-
-void unpackRtShadows(UVec4 packed, out F32 shadowFactors[kMaxRtShadowLayers])
-{
-	const Vec4 a = newUnpackUnorm4x8(packed.x);
-	const Vec4 b = newUnpackUnorm4x8(packed.y);
-	shadowFactors[0] = a[0];
-	shadowFactors[1] = a[1];
-	shadowFactors[2] = a[2];
-	shadowFactors[3] = a[3];
-	shadowFactors[4] = b[0];
-	shadowFactors[5] = b[1];
-	shadowFactors[6] = b[2];
-	shadowFactors[7] = b[3];
-}
-
-void zeroRtShadowLayers(out F32 shadowFactors[kMaxRtShadowLayers])
-{
-	[unroll] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
-	{
-		shadowFactors[i] = 0.0;
-	}
-}

+ 0 - 1117
AnKi/Shaders/TextureFunctions.glsl

@@ -1,1117 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-// WARNING: THIS FILE IS AUTO-GENERATED. DON'T CHANGE IT BY HAND.
-// This file contains some convenience texture functions.
-
-#pragma once
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(texture1D tex, sampler sampl, float P, float bias)
-{
-	return texture(sampler1D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utexture1D tex, sampler sampl, float P, float bias)
-{
-	return texture(usampler1D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itexture1D tex, sampler sampl, float P, float bias)
-{
-	return texture(isampler1D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(texture1D tex, sampler sampl, float P)
-{
-	return texture(sampler1D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utexture1D tex, sampler sampl, float P)
-{
-	return texture(usampler1D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itexture1D tex, sampler sampl, float P)
-{
-	return texture(isampler1D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(texture2D tex, sampler sampl, vec2 P, float bias)
-{
-	return texture(sampler2D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utexture2D tex, sampler sampl, vec2 P, float bias)
-{
-	return texture(usampler2D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itexture2D tex, sampler sampl, vec2 P, float bias)
-{
-	return texture(isampler2D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(texture2D tex, sampler sampl, vec2 P)
-{
-	return texture(sampler2D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utexture2D tex, sampler sampl, vec2 P)
-{
-	return texture(usampler2D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itexture2D tex, sampler sampl, vec2 P)
-{
-	return texture(isampler2D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(texture3D tex, sampler sampl, vec3 P, float bias)
-{
-	return texture(sampler3D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utexture3D tex, sampler sampl, vec3 P, float bias)
-{
-	return texture(usampler3D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itexture3D tex, sampler sampl, vec3 P, float bias)
-{
-	return texture(isampler3D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(texture3D tex, sampler sampl, vec3 P)
-{
-	return texture(sampler3D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utexture3D tex, sampler sampl, vec3 P)
-{
-	return texture(usampler3D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itexture3D tex, sampler sampl, vec3 P)
-{
-	return texture(isampler3D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(textureCube tex, sampler sampl, vec3 P, float bias)
-{
-	return texture(samplerCube(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utextureCube tex, sampler sampl, vec3 P, float bias)
-{
-	return texture(usamplerCube(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itextureCube tex, sampler sampl, vec3 P, float bias)
-{
-	return texture(isamplerCube(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(textureCube tex, sampler sampl, vec3 P)
-{
-	return texture(samplerCube(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utextureCube tex, sampler sampl, vec3 P)
-{
-	return texture(usamplerCube(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itextureCube tex, sampler sampl, vec3 P)
-{
-	return texture(isamplerCube(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float texture(texture1D tex, samplerShadow sampl, vec3 P, float bias)
-{
-	return texture(sampler1DShadow(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float texture(texture1D tex, samplerShadow sampl, vec3 P)
-{
-	return texture(sampler1DShadow(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float texture(texture2D tex, samplerShadow sampl, vec3 P, float bias)
-{
-	return texture(sampler2DShadow(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float texture(texture2D tex, samplerShadow sampl, vec3 P)
-{
-	return texture(sampler2DShadow(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float texture(textureCube tex, samplerShadow sampl, vec4 P, float bias)
-{
-	return texture(samplerCubeShadow(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float texture(textureCube tex, samplerShadow sampl, vec4 P)
-{
-	return texture(samplerCubeShadow(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(texture2DArray tex, sampler sampl, vec3 P, float bias)
-{
-	return texture(sampler2DArray(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utexture2DArray tex, sampler sampl, vec3 P, float bias)
-{
-	return texture(usampler2DArray(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itexture2DArray tex, sampler sampl, vec3 P, float bias)
-{
-	return texture(isampler2DArray(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(texture2DArray tex, sampler sampl, vec3 P)
-{
-	return texture(sampler2DArray(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utexture2DArray tex, sampler sampl, vec3 P)
-{
-	return texture(usampler2DArray(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itexture2DArray tex, sampler sampl, vec3 P)
-{
-	return texture(isampler2DArray(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(textureCubeArray tex, sampler sampl, vec4 P, float bias)
-{
-	return texture(samplerCubeArray(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utextureCubeArray tex, sampler sampl, vec4 P, float bias)
-{
-	return texture(usamplerCubeArray(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itextureCubeArray tex, sampler sampl, vec4 P, float bias)
-{
-	return texture(isamplerCubeArray(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(textureCubeArray tex, sampler sampl, vec4 P)
-{
-	return texture(samplerCubeArray(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utextureCubeArray tex, sampler sampl, vec4 P)
-{
-	return texture(usamplerCubeArray(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itextureCubeArray tex, sampler sampl, vec4 P)
-{
-	return texture(isamplerCubeArray(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(texture1DArray tex, sampler sampl, vec2 P, float bias)
-{
-	return texture(sampler1DArray(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utexture1DArray tex, sampler sampl, vec2 P, float bias)
-{
-	return texture(usampler1DArray(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itexture1DArray tex, sampler sampl, vec2 P, float bias)
-{
-	return texture(isampler1DArray(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 texture(texture1DArray tex, sampler sampl, vec2 P)
-{
-	return texture(sampler1DArray(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 texture(utexture1DArray tex, sampler sampl, vec2 P)
-{
-	return texture(usampler1DArray(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 texture(itexture1DArray tex, sampler sampl, vec2 P)
-{
-	return texture(isampler1DArray(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float texture(texture1DArray tex, samplerShadow sampl, vec3 P, float bias)
-{
-	return texture(sampler1DArrayShadow(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float texture(texture1DArray tex, samplerShadow sampl, vec3 P)
-{
-	return texture(sampler1DArrayShadow(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float texture(texture2DArray tex, samplerShadow sampl, vec4 P)
-{
-	return texture(sampler2DArrayShadow(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float texture(textureCubeArray tex, samplerShadow sampl, vec4 P, float compare)
-{
-	return texture(samplerCubeArrayShadow(tex, sampl), P, compare);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProj(texture1D tex, sampler sampl, vec2 P, float bias)
-{
-	return textureProj(sampler1D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProj(utexture1D tex, sampler sampl, vec2 P, float bias)
-{
-	return textureProj(usampler1D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProj(itexture1D tex, sampler sampl, vec2 P, float bias)
-{
-	return textureProj(isampler1D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProj(texture1D tex, sampler sampl, vec2 P)
-{
-	return textureProj(sampler1D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProj(utexture1D tex, sampler sampl, vec2 P)
-{
-	return textureProj(usampler1D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProj(itexture1D tex, sampler sampl, vec2 P)
-{
-	return textureProj(isampler1D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProj(texture1D tex, sampler sampl, vec4 P, float bias)
-{
-	return textureProj(sampler1D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProj(utexture1D tex, sampler sampl, vec4 P, float bias)
-{
-	return textureProj(usampler1D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProj(itexture1D tex, sampler sampl, vec4 P, float bias)
-{
-	return textureProj(isampler1D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProj(texture1D tex, sampler sampl, vec4 P)
-{
-	return textureProj(sampler1D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProj(utexture1D tex, sampler sampl, vec4 P)
-{
-	return textureProj(usampler1D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProj(itexture1D tex, sampler sampl, vec4 P)
-{
-	return textureProj(isampler1D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProj(texture2D tex, sampler sampl, vec3 P, float bias)
-{
-	return textureProj(sampler2D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProj(utexture2D tex, sampler sampl, vec3 P, float bias)
-{
-	return textureProj(usampler2D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProj(itexture2D tex, sampler sampl, vec3 P, float bias)
-{
-	return textureProj(isampler2D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProj(texture2D tex, sampler sampl, vec3 P)
-{
-	return textureProj(sampler2D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProj(utexture2D tex, sampler sampl, vec3 P)
-{
-	return textureProj(usampler2D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProj(itexture2D tex, sampler sampl, vec3 P)
-{
-	return textureProj(isampler2D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProj(texture2D tex, sampler sampl, vec4 P, float bias)
-{
-	return textureProj(sampler2D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProj(utexture2D tex, sampler sampl, vec4 P, float bias)
-{
-	return textureProj(usampler2D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProj(itexture2D tex, sampler sampl, vec4 P, float bias)
-{
-	return textureProj(isampler2D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProj(texture2D tex, sampler sampl, vec4 P)
-{
-	return textureProj(sampler2D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProj(utexture2D tex, sampler sampl, vec4 P)
-{
-	return textureProj(usampler2D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProj(itexture2D tex, sampler sampl, vec4 P)
-{
-	return textureProj(isampler2D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProj(texture3D tex, sampler sampl, vec4 P, float bias)
-{
-	return textureProj(sampler3D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProj(utexture3D tex, sampler sampl, vec4 P, float bias)
-{
-	return textureProj(usampler3D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProj(itexture3D tex, sampler sampl, vec4 P, float bias)
-{
-	return textureProj(isampler3D(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProj(texture3D tex, sampler sampl, vec4 P)
-{
-	return textureProj(sampler3D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProj(utexture3D tex, sampler sampl, vec4 P)
-{
-	return textureProj(usampler3D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProj(itexture3D tex, sampler sampl, vec4 P)
-{
-	return textureProj(isampler3D(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float textureProj(texture1D tex, samplerShadow sampl, vec4 P, float bias)
-{
-	return textureProj(sampler1DShadow(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float textureProj(texture1D tex, samplerShadow sampl, vec4 P)
-{
-	return textureProj(sampler1DShadow(tex, sampl), P);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float textureProj(texture2D tex, samplerShadow sampl, vec4 P, float bias)
-{
-	return textureProj(sampler2DShadow(tex, sampl), P, bias);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float textureProj(texture2D tex, samplerShadow sampl, vec4 P)
-{
-	return textureProj(sampler2DShadow(tex, sampl), P);
-}
-#endif
-
-vec4 textureLod(texture1D tex, sampler sampl, float P, float lod)
-{
-	return textureLod(sampler1D(tex, sampl), P, lod);
-}
-
-uvec4 textureLod(utexture1D tex, sampler sampl, float P, float lod)
-{
-	return textureLod(usampler1D(tex, sampl), P, lod);
-}
-
-ivec4 textureLod(itexture1D tex, sampler sampl, float P, float lod)
-{
-	return textureLod(isampler1D(tex, sampl), P, lod);
-}
-
-vec4 textureLod(texture2D tex, sampler sampl, vec2 P, float lod)
-{
-	return textureLod(sampler2D(tex, sampl), P, lod);
-}
-
-uvec4 textureLod(utexture2D tex, sampler sampl, vec2 P, float lod)
-{
-	return textureLod(usampler2D(tex, sampl), P, lod);
-}
-
-ivec4 textureLod(itexture2D tex, sampler sampl, vec2 P, float lod)
-{
-	return textureLod(isampler2D(tex, sampl), P, lod);
-}
-
-vec4 textureLod(texture3D tex, sampler sampl, vec3 P, float lod)
-{
-	return textureLod(sampler3D(tex, sampl), P, lod);
-}
-
-uvec4 textureLod(utexture3D tex, sampler sampl, vec3 P, float lod)
-{
-	return textureLod(usampler3D(tex, sampl), P, lod);
-}
-
-ivec4 textureLod(itexture3D tex, sampler sampl, vec3 P, float lod)
-{
-	return textureLod(isampler3D(tex, sampl), P, lod);
-}
-
-vec4 textureLod(textureCube tex, sampler sampl, vec3 P, float lod)
-{
-	return textureLod(samplerCube(tex, sampl), P, lod);
-}
-
-uvec4 textureLod(utextureCube tex, sampler sampl, vec3 P, float lod)
-{
-	return textureLod(usamplerCube(tex, sampl), P, lod);
-}
-
-ivec4 textureLod(itextureCube tex, sampler sampl, vec3 P, float lod)
-{
-	return textureLod(isamplerCube(tex, sampl), P, lod);
-}
-
-float textureLod(texture2D tex, samplerShadow sampl, vec3 P, float lod)
-{
-	return textureLod(sampler2DShadow(tex, sampl), P, lod);
-}
-
-float textureLod(texture1D tex, samplerShadow sampl, vec3 P, float lod)
-{
-	return textureLod(sampler1DShadow(tex, sampl), P, lod);
-}
-
-vec4 textureLod(texture1DArray tex, sampler sampl, vec2 P, float lod)
-{
-	return textureLod(sampler1DArray(tex, sampl), P, lod);
-}
-
-uvec4 textureLod(utexture1DArray tex, sampler sampl, vec2 P, float lod)
-{
-	return textureLod(usampler1DArray(tex, sampl), P, lod);
-}
-
-ivec4 textureLod(itexture1DArray tex, sampler sampl, vec2 P, float lod)
-{
-	return textureLod(isampler1DArray(tex, sampl), P, lod);
-}
-
-float textureLod(texture1DArray tex, samplerShadow sampl, vec3 P, float lod)
-{
-	return textureLod(sampler1DArrayShadow(tex, sampl), P, lod);
-}
-
-vec4 textureLod(texture2DArray tex, sampler sampl, vec3 P, float lod)
-{
-	return textureLod(sampler2DArray(tex, sampl), P, lod);
-}
-
-uvec4 textureLod(utexture2DArray tex, sampler sampl, vec3 P, float lod)
-{
-	return textureLod(usampler2DArray(tex, sampl), P, lod);
-}
-
-ivec4 textureLod(itexture2DArray tex, sampler sampl, vec3 P, float lod)
-{
-	return textureLod(isampler2DArray(tex, sampl), P, lod);
-}
-
-vec4 textureLod(textureCubeArray tex, sampler sampl, vec4 P, float lod)
-{
-	return textureLod(samplerCubeArray(tex, sampl), P, lod);
-}
-
-uvec4 textureLod(utextureCubeArray tex, sampler sampl, vec4 P, float lod)
-{
-	return textureLod(usamplerCubeArray(tex, sampl), P, lod);
-}
-
-ivec4 textureLod(itextureCubeArray tex, sampler sampl, vec4 P, float lod)
-{
-	return textureLod(isamplerCubeArray(tex, sampl), P, lod);
-}
-
-vec4 textureProjLod(texture1D tex, sampler sampl, vec2 P, float lod)
-{
-	return textureProjLod(sampler1D(tex, sampl), P, lod);
-}
-
-uvec4 textureProjLod(utexture1D tex, sampler sampl, vec2 P, float lod)
-{
-	return textureProjLod(usampler1D(tex, sampl), P, lod);
-}
-
-ivec4 textureProjLod(itexture1D tex, sampler sampl, vec2 P, float lod)
-{
-	return textureProjLod(isampler1D(tex, sampl), P, lod);
-}
-
-vec4 textureProjLod(texture1D tex, sampler sampl, vec4 P, float lod)
-{
-	return textureProjLod(sampler1D(tex, sampl), P, lod);
-}
-
-uvec4 textureProjLod(utexture1D tex, sampler sampl, vec4 P, float lod)
-{
-	return textureProjLod(usampler1D(tex, sampl), P, lod);
-}
-
-ivec4 textureProjLod(itexture1D tex, sampler sampl, vec4 P, float lod)
-{
-	return textureProjLod(isampler1D(tex, sampl), P, lod);
-}
-
-vec4 textureProjLod(texture2D tex, sampler sampl, vec3 P, float lod)
-{
-	return textureProjLod(sampler2D(tex, sampl), P, lod);
-}
-
-uvec4 textureProjLod(utexture2D tex, sampler sampl, vec3 P, float lod)
-{
-	return textureProjLod(usampler2D(tex, sampl), P, lod);
-}
-
-ivec4 textureProjLod(itexture2D tex, sampler sampl, vec3 P, float lod)
-{
-	return textureProjLod(isampler2D(tex, sampl), P, lod);
-}
-
-vec4 textureProjLod(texture2D tex, sampler sampl, vec4 P, float lod)
-{
-	return textureProjLod(sampler2D(tex, sampl), P, lod);
-}
-
-uvec4 textureProjLod(utexture2D tex, sampler sampl, vec4 P, float lod)
-{
-	return textureProjLod(usampler2D(tex, sampl), P, lod);
-}
-
-ivec4 textureProjLod(itexture2D tex, sampler sampl, vec4 P, float lod)
-{
-	return textureProjLod(isampler2D(tex, sampl), P, lod);
-}
-
-vec4 textureProjLod(texture3D tex, sampler sampl, vec4 P, float lod)
-{
-	return textureProjLod(sampler3D(tex, sampl), P, lod);
-}
-
-uvec4 textureProjLod(utexture3D tex, sampler sampl, vec4 P, float lod)
-{
-	return textureProjLod(usampler3D(tex, sampl), P, lod);
-}
-
-ivec4 textureProjLod(itexture3D tex, sampler sampl, vec4 P, float lod)
-{
-	return textureProjLod(isampler3D(tex, sampl), P, lod);
-}
-
-float textureProjLod(texture1D tex, samplerShadow sampl, vec4 P, float lod)
-{
-	return textureProjLod(sampler1DShadow(tex, sampl), P, lod);
-}
-
-float textureProjLod(texture2D tex, samplerShadow sampl, vec4 P, float lod)
-{
-	return textureProjLod(sampler2DShadow(tex, sampl), P, lod);
-}
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureGrad(texture1D tex, sampler sampl, float P, float dPdx, float dPdy)
-{
-	return textureGrad(sampler1D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureGrad(utexture1D tex, sampler sampl, float P, float dPdx, float dPdy)
-{
-	return textureGrad(usampler1D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureGrad(itexture1D tex, sampler sampl, float P, float dPdx, float dPdy)
-{
-	return textureGrad(isampler1D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureGrad(texture2D tex, sampler sampl, vec2 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureGrad(sampler2D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureGrad(utexture2D tex, sampler sampl, vec2 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureGrad(usampler2D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureGrad(itexture2D tex, sampler sampl, vec2 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureGrad(isampler2D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureGrad(texture3D tex, sampler sampl, vec3 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureGrad(sampler3D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureGrad(utexture3D tex, sampler sampl, vec3 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureGrad(usampler3D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureGrad(itexture3D tex, sampler sampl, vec3 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureGrad(isampler3D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureGrad(textureCube tex, sampler sampl, vec3 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureGrad(samplerCube(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureGrad(utextureCube tex, sampler sampl, vec3 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureGrad(usamplerCube(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureGrad(itextureCube tex, sampler sampl, vec3 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureGrad(isamplerCube(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float textureGrad(texture1D tex, samplerShadow sampl, vec3 P, float dPdx, float dPdy)
-{
-	return textureGrad(sampler1DShadow(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureGrad(texture1DArray tex, sampler sampl, vec2 P, float dPdx, float dPdy)
-{
-	return textureGrad(sampler1DArray(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureGrad(utexture1DArray tex, sampler sampl, vec2 P, float dPdx, float dPdy)
-{
-	return textureGrad(usampler1DArray(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureGrad(itexture1DArray tex, sampler sampl, vec2 P, float dPdx, float dPdy)
-{
-	return textureGrad(isampler1DArray(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureGrad(texture2DArray tex, sampler sampl, vec3 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureGrad(sampler2DArray(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureGrad(utexture2DArray tex, sampler sampl, vec3 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureGrad(usampler2DArray(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureGrad(itexture2DArray tex, sampler sampl, vec3 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureGrad(isampler2DArray(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float textureGrad(texture1DArray tex, samplerShadow sampl, vec3 P, float dPdx, float dPdy)
-{
-	return textureGrad(sampler1DArrayShadow(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float textureGrad(texture2D tex, samplerShadow sampl, vec3 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureGrad(sampler2DShadow(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float textureGrad(textureCube tex, samplerShadow sampl, vec4 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureGrad(samplerCubeShadow(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float textureGrad(texture2DArray tex, samplerShadow sampl, vec4 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureGrad(sampler2DArrayShadow(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureGrad(textureCubeArray tex, sampler sampl, vec4 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureGrad(samplerCubeArray(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureGrad(utextureCubeArray tex, sampler sampl, vec4 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureGrad(usamplerCubeArray(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureGrad(itextureCubeArray tex, sampler sampl, vec4 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureGrad(isamplerCubeArray(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProjGrad(texture1D tex, sampler sampl, vec2 P, float dPdx, float dPdy)
-{
-	return textureProjGrad(sampler1D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProjGrad(utexture1D tex, sampler sampl, vec2 P, float dPdx, float dPdy)
-{
-	return textureProjGrad(usampler1D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProjGrad(itexture1D tex, sampler sampl, vec2 P, float dPdx, float dPdy)
-{
-	return textureProjGrad(isampler1D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProjGrad(texture1D tex, sampler sampl, vec4 P, float dPdx, float dPdy)
-{
-	return textureProjGrad(sampler1D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProjGrad(utexture1D tex, sampler sampl, vec4 P, float dPdx, float dPdy)
-{
-	return textureProjGrad(usampler1D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProjGrad(itexture1D tex, sampler sampl, vec4 P, float dPdx, float dPdy)
-{
-	return textureProjGrad(isampler1D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProjGrad(texture2D tex, sampler sampl, vec3 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureProjGrad(sampler2D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProjGrad(utexture2D tex, sampler sampl, vec3 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureProjGrad(usampler2D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProjGrad(itexture2D tex, sampler sampl, vec3 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureProjGrad(isampler2D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProjGrad(texture2D tex, sampler sampl, vec4 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureProjGrad(sampler2D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProjGrad(utexture2D tex, sampler sampl, vec4 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureProjGrad(usampler2D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProjGrad(itexture2D tex, sampler sampl, vec4 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureProjGrad(isampler2D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-vec4 textureProjGrad(texture3D tex, sampler sampl, vec4 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureProjGrad(sampler3D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-uvec4 textureProjGrad(utexture3D tex, sampler sampl, vec4 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureProjGrad(usampler3D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-ivec4 textureProjGrad(itexture3D tex, sampler sampl, vec4 P, vec3 dPdx, vec3 dPdy)
-{
-	return textureProjGrad(isampler3D(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float textureProjGrad(texture1D tex, samplerShadow sampl, vec4 P, float dPdx, float dPdy)
-{
-	return textureProjGrad(sampler1DShadow(tex, sampl), P, dPdx, dPdy);
-}
-#endif
-
-#if defined(ANKI_FRAGMENT_SHADER)
-float textureProjGrad(texture2D tex, samplerShadow sampl, vec4 P, vec2 dPdx, vec2 dPdy)
-{
-	return textureProjGrad(sampler2DShadow(tex, sampl), P, dPdx, dPdy);
-}
-#endif

+ 0 - 126
AnKi/Shaders/TonemappingFunctions.glsl

@@ -1,126 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Common.glsl>
-
-// A tick to compute log of base 10
-ANKI_RP F32 log10(ANKI_RP F32 x)
-{
-	return log(x) / log(10.0);
-}
-
-ANKI_RP F32 computeLuminance(ANKI_RP Vec3 color)
-{
-	return max(dot(Vec3(0.30, 0.59, 0.11), color), kEpsilonRp);
-}
-
-ANKI_RP F32 computeExposure(ANKI_RP F32 avgLum, ANKI_RP F32 threshold)
-{
-	const ANKI_RP F32 keyValue = 1.03 - (2.0 / (2.0 + log10(avgLum + 1.0)));
-	const ANKI_RP F32 linearExposure = (keyValue / avgLum);
-	ANKI_RP F32 exposure = log2(linearExposure);
-
-	exposure -= threshold;
-	return exp2(exposure);
-}
-
-ANKI_RP Vec3 computeExposedColor(ANKI_RP Vec3 color, ANKI_RP F32 avgLum, ANKI_RP F32 threshold)
-{
-	return computeExposure(avgLum, threshold) * color;
-}
-
-// Reinhard operator
-ANKI_RP Vec3 tonemapReinhard(ANKI_RP Vec3 color, ANKI_RP F32 saturation)
-{
-	const ANKI_RP F32 lum = computeLuminance(color);
-	const ANKI_RP F32 toneMappedLuminance = lum / (lum + 1.0);
-	return toneMappedLuminance * pow(color / lum, Vec3(saturation, saturation, saturation));
-}
-
-// Uncharted 2 operator
-ANKI_RP Vec3 tonemapUncharted2(ANKI_RP Vec3 color)
-{
-	const F32 A = 0.15;
-	const F32 B = 0.50;
-	const F32 C = 0.10;
-	const F32 D = 0.20;
-	const F32 E = 0.02;
-	const F32 F = 0.30;
-
-	return ((color * (A * color + C * B) + D * E) / (color * (A * color + B) + D * F)) - E / F;
-}
-
-const ANKI_RP F32 kACESA = 2.51;
-const ANKI_RP F32 kACESB = 0.03;
-const ANKI_RP F32 kACESC = 2.43;
-const ANKI_RP F32 kACESD = 0.59;
-const ANKI_RP F32 kACESE = 0.14;
-
-// See ACES in action and its inverse at https://www.desmos.com/calculator/n1lkpc6hwq
-ANKI_RP Vec3 tonemapACESFilm(ANKI_RP Vec3 x)
-{
-	return saturate((x * (kACESA * x + kACESB)) / (x * (kACESC * x + kACESD) + kACESE));
-}
-
-// https://www.desmos.com/calculator/n1lkpc6hwq
-ANKI_RP Vec3 invertTonemapACESFilm(ANKI_RP Vec3 x)
-{
-	ANKI_RP Vec3 res = kACESD * x - kACESB;
-	res += sqrt(x * x * (kACESD * kACESD - 4.0 * kACESE * kACESC) + x * (4.0 * kACESE * kACESA - 2.0 * kACESB * kACESD)
-				+ kACESB * kACESB);
-	res /= 2.0 * kACESA - 2.0 * kACESC * x;
-
-	return res;
-}
-
-ANKI_RP Vec3 tonemap(ANKI_RP Vec3 color, ANKI_RP F32 exposure)
-{
-	color *= exposure;
-	return tonemapACESFilm(color);
-}
-
-ANKI_RP Vec3 invertTonemap(ANKI_RP Vec3 color, ANKI_RP F32 exposure)
-{
-	color = invertTonemapACESFilm(color);
-	color /= max(kEpsilonf, exposure);
-	return color;
-}
-
-ANKI_RP Vec3 tonemap(ANKI_RP Vec3 color, ANKI_RP F32 avgLum, ANKI_RP F32 threshold)
-{
-	const ANKI_RP F32 exposure = computeExposure(avgLum, threshold);
-	return tonemap(color, exposure);
-}
-
-// https://graphicrants.blogspot.com/2013/12/tone-mapping.html
-Vec3 reinhardTonemap(Vec3 colour)
-{
-	// rgb / (1 + max(rgb))
-	return colour / (1.0 + max(max(colour.r, colour.g), colour.b));
-}
-
-F32 reinhardTonemap(F32 value)
-{
-	return value / (1.0 + value);
-}
-
-F16 reinhardTonemap(F16 value)
-{
-	return value / (1.0hf + value);
-}
-
-Vec3 invertReinhardTonemap(Vec3 colour)
-{
-	// rgb / (1 - max(rgb))
-	return colour / max(1.0 / 32768.0, 1.0 - max(max(colour.r, colour.g), colour.b));
-}
-
-HVec3 invertReinhardTonemap(HVec3 colour)
-{
-	// rgb / (1 - max(rgb))
-	return colour / max(F16(1.0 / 32768.0), 1.0hf - max(max(colour.r, colour.g), colour.b));
-}

+ 0 - 32
AnKi/Shaders/TonemappingResources.glsl

@@ -1,32 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-// Tonemapping resources
-
-#pragma once
-
-#include <AnKi/Shaders/Common.glsl>
-
-#if !defined(TONEMAPPING_RESOURCE_AS_WRITE_IMAGE)
-#	define TONEMAPPING_RESOURCE_AS_WRITE_IMAGE 0
-#endif
-
-#if TONEMAPPING_RESOURCE_AS_WRITE_IMAGE
-layout(set = 0, binding = kTonemappingBinding) ANKI_RP uniform coherent image2D u_tonemappingImage;
-#else
-layout(set = 0, binding = kTonemappingBinding) ANKI_RP uniform readonly image2D u_tonemappingImage;
-#endif
-
-#if TONEMAPPING_RESOURCE_AS_WRITE_IMAGE
-void writeExposureAndAverageLuminance(ANKI_RP F32 exposure, ANKI_RP F32 avgLuminance)
-{
-	imageStore(u_tonemappingImage, IVec2(0), Vec4(exposure, avgLuminance, 0.0f, 0.0f));
-}
-#endif
-
-ANKI_RP Vec2 readExposureAndAverageLuminance()
-{
-	return imageLoad(u_tonemappingImage, IVec2(0)).xy;
-}