it works somewhat, but not really
This commit is contained in:
@@ -272,3 +272,47 @@ kernel void computeKernel(
|
||||
accumulator.write(result, threadId);
|
||||
image.write(pow(max(result * resolver, 0), float4(0.45f)), threadId);
|
||||
}
|
||||
|
||||
|
||||
// Screen filling quad in normalized device coordinates.
|
||||
constant float2 quadVertices[] = {
|
||||
float2(-1, -1),
|
||||
float2(-1, 1),
|
||||
float2( 1, 1),
|
||||
float2(-1, -1),
|
||||
float2( 1, 1),
|
||||
float2( 1, -1)
|
||||
};
|
||||
|
||||
struct CopyVertexOut {
|
||||
float4 position [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
// Simple vertex shader that passes through NDC quad positions.
|
||||
vertex CopyVertexOut copyVertex(unsigned short vid [[vertex_id]]) {
|
||||
float2 position = quadVertices[vid];
|
||||
|
||||
CopyVertexOut out;
|
||||
|
||||
out.position = float4(position, 0, 1);
|
||||
out.uv = position * 0.5f + 0.5f;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// Simple fragment shader that copies a texture and applies a simple tonemapping function.
|
||||
fragment float4 copyFragment(CopyVertexOut in [[stage_in]],
|
||||
texture2d<float> tex)
|
||||
{
|
||||
constexpr sampler sam(min_filter::nearest, mag_filter::nearest, mip_filter::none);
|
||||
|
||||
float3 color = tex.sample(sam, in.uv).xyz;
|
||||
|
||||
// Apply a simple tonemapping function to reduce the dynamic range of the
|
||||
// input image into a range which the screen can display.
|
||||
color = color / (1.0f + color);
|
||||
|
||||
return float4(color, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user