NazaraEngine/assets/shaders/bloom_bright.nzsl

43 lines
1.0 KiB
Plaintext

[nzsl_version("1.0")]
module;
import VertOut, VertexShader from Engine.FullscreenVertex;
import ViewerData from Engine.ViewerData;
external
{
[set(0), binding(0)] viewerData: uniform[ViewerData],
[set(0), binding(1)] colorTexture: sampler2D[f32],
}
struct FragOut
{
[location(0)] color: vec4[f32]
}
[entry(frag)]
fn main(input: VertOut) -> FragOut
{
/*let BrightLuminance = 0.8;
let BrightMiddleGrey = 0.5;
let BrightThreshold = 0.7;
let color = colorTexture.Sample(input.uv).rgb;
color *= BrightMiddleGrey / BrightLuminance;
color *= vec3[f32](1.0, 1.0, 1.0) + (color / (BrightThreshold*BrightThreshold));
color -= vec3[f32](0.5, 0.5, 0.5);
color /= vec3[f32](1.0, 1.0, 1.0) + color;*/
let output: FragOut;
//output.color = vec4[f32](max(color, vec3[f32](0.0, 0.0, 0.0)), 1.0);
let color = colorTexture.Sample(input.uv).rgb;
let brightness = dot(color, vec3[f32](0.2126, 0.7152, 0.0722));
if (brightness > 1.0)
output.color = vec4[f32](color, 1.0);
else
output.color = vec4[f32](0.0, 0.0, 0.0, 1.0);
return output;
}