SFML / SFML-Game-Development-Book

Full and up-to-date source code of the chapters of the "SFML Game Development" book
Other
923 stars 231 forks source link

Brightness.frag fails to load visual studio 2017 #10

Open dburchill opened 6 years ago

dburchill commented 6 years ago

sample code compiled with visual studio 2017 fails to load shader, to fix change Brightness.frag line 12 from: sourceFragment *= clamp(luminance - Threshold, 0.0, 1.0) * Factor; to: sourceFragment *= clamp(luminance - Threshold, 0.f, 1.f) * Factor;

Bromeon commented 5 years ago

That's strange, because both 0.0 and 1.0 are float literals in GLSL, and also the expression luminance - Threshold is float.

Do you know what OpenGL/GLSL versions you have?

Context:

uniform sampler2D source;

const float Threshold = 0.7;
const float Factor   = 4.0;

void main()
{
    vec4 sourceFragment = texture2D(source, gl_TexCoord[0].xy);
    float luminance = sourceFragment.r * 0.2126 + sourceFragment.g * 0.7152 + sourceFragment.b * 0.0722;
    sourceFragment *= clamp(luminance - Threshold, 0.0, 1.0) * Factor;
    gl_FragColor = sourceFragment;
}