You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
535 B
21 lines
535 B
#ifndef BLOOM_COMMON
|
|
#define BLOOM_COMMON
|
|
|
|
// Quadratic color thresholding
|
|
// curve = (threshold - knee, knee * 2, 0.25 / knee)
|
|
float3 QuadraticThreshold(float3 color, float threshold, float3 curve)
|
|
{
|
|
// Pixel brightness
|
|
float br = Max3(color.r, color.g, color.b);
|
|
|
|
// Under-threshold part
|
|
float rq = clamp(br - curve.x, 0.0, curve.y);
|
|
rq = curve.z * rq * rq;
|
|
|
|
// Combine and apply the brightness response curve
|
|
color *= max(rq, br - threshold) / max(br, 1e-4);
|
|
|
|
return color;
|
|
}
|
|
|
|
#endif // BLOOM_COMMON
|