#include "macros.hlsl"

// https://iolite-engine.com/blog_posts/minimal_agx_implementation
float3 agxDefaultContrastApprox(float3 x) {
	float3 x2 = x * x;
	float3 x4 = x2 * x2;
	float3 x6 = x4 * x2;

	return - 17.86     * x6 * x
		+ 78.01     * x6
		- 126.7     * x4 * x
		+ 92.06     * x4
		- 28.72     * x2 * x
		+ 4.361     * x2
		- 0.1718    * x
		+ 0.002857;
}


CS
{
	Texture2D<float4> g_in;
	RWTexture2D<float4> g_out;

	[numthreads(1,1,1)]
	void csMain( int3 threadId : SV_DispatchThreadID )
	{
		float4 vColor = g_in.Load(threadId);
		vColor.xyz = agxDefaultContrastApprox(vColor.xyz);
		g_out.Store(threadId.xy, vColor);

	}
}
