Created
September 3, 2015 03:53
-
-
Save rasteron/aceec4f3e9525269ddbe to your computer and use it in GitHub Desktop.
Simple Emboss Effect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Uniforms.glsl" | |
#include "Samplers.glsl" | |
#include "Transform.glsl" | |
#include "ScreenPos.glsl" | |
varying vec2 vScreenPos; | |
varying vec2 vTexCoord; | |
varying vec4 vColor; | |
uniform float pixelWidth = 1024.0; | |
uniform float pixelHeight = 768.0; | |
void VS() | |
{ | |
mat4 modelMatrix = iModelMatrix; | |
vec3 worldPos = GetWorldPos(modelMatrix); | |
gl_Position = GetClipPos(worldPos); | |
vScreenPos = GetScreenPosPreDiv(gl_Position); | |
vTexCoord = GetQuadTexCoord(gl_Position); | |
vColor = iColor; | |
} | |
void PS() | |
{ | |
vec2 onePixel = vec2(1.0 / pixelWidth, 1.0 / pixelHeight); | |
vec2 texCoord = vScreenPos; | |
vec4 color1; | |
color1.rgb = vec3(0.5); | |
color1 -= texture2D(sDiffMap, texCoord - onePixel) * 5.0; | |
color1 += texture2D(sDiffMap, texCoord + onePixel) * 5.0; | |
color1.rgb = vec3((color1.r + color1.g + color1.b) / 3.0); | |
gl_FragColor = vec4(color1.rgb, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment