Skip to content

Instantly share code, notes, and snippets.

@rasteron
Created August 22, 2015 03:09
Show Gist options
  • Save rasteron/5a2b94874b23faa18ea1 to your computer and use it in GitHub Desktop.
Save rasteron/5a2b94874b23faa18ea1 to your computer and use it in GitHub Desktop.
#include "Uniforms.glsl"
#include "Samplers.glsl"
#include "Transform.glsl"
#include "ScreenPos.glsl"
varying vec2 vScreenPos;
#ifdef COMPILEPS
const float cRadius = 0.75;
const float cSoftness = 0.45;
#endif
void VS()
{
mat4 modelMatrix = iModelMatrix;
vec3 worldPos = GetWorldPos(modelMatrix);
gl_Position = GetClipPos(worldPos);
vScreenPos = GetScreenPosPreDiv(gl_Position);
}
void PS() {
vec4 Color = texture2D(sDiffMap, vScreenPos.xy);
float dist = distance(vScreenPos.xy, vec2(0.5,0.5));
float vignette = smoothstep(cRadius, cRadius-cSoftness, dist);
//vignette opacity (50%)
Color.rgb = mix(Color.rgb, Color.rgb * vignette, 0.5);
gl_FragColor = Color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment