final colour, multiplied by vertex colour gl_FragColor = texColor * vColor TexColor.rgb = mix(texColor.rgb, sepiaColor, 0.75) again we'll use mix so that the sepia effect is at 75% SEPIA //create our sepia tone from some constant value vec3 sepiaColor = vec3(gray) * SEPIA GRAYSCALE //convert to grayscale using NTSC conversion weights float gray = dot(texColor.rgb, vec3( 0.299, 0.587, 0.114)) ![]() TexColor.rgb = mix(texColor.rgb, texColor.rgb * vignette, 0.5) use smoothstep to create a smooth vignette float vignette = smoothstep(RADIUS, RADIUS -SOFTNESS, len) determine the vector length of the center position float len = length(position) ![]() VIGNETTE //determine center position vec2 position = ( gl_FragCoord.xy / resolution.xy) - vec2( 0.5) sample our texture vec4 texColor = texture2D(u_texture, vTexCoord) sepia colour, adjust to taste const vec3 SEPIA = vec3( 1.2, 1.0, 0.8) softness of our vignette, between 0.0 and 1.0 const float SOFTNESS = 0.45 RADIUS of our vignette, where 0.5 results in a circle fitting the screen const float RADIUS = 0.75 ![]() "in" attributes from our vertex shader varying vec4 vColor our screen resolution, set from Java whenever the display is resized uniform vec2 resolution
0 Comments
Leave a Reply. |