-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding an ultima underworld inspired post process effect
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifdef GL_ES | ||
#define LOWP lowp | ||
precision mediump float; | ||
#else | ||
#define LOWP | ||
#endif | ||
|
||
varying LOWP vec4 v_color; | ||
varying vec2 v_texCoords; | ||
|
||
uniform sampler2D u_texture; | ||
uniform sampler2D u_texture1; | ||
|
||
uniform float u_brightness; | ||
|
||
uniform vec2 u_resolution; | ||
|
||
vec4 blur9(sampler2D image, vec2 uv, vec2 resolution, vec2 direction); | ||
|
||
void main() | ||
{ | ||
// downsample the resolution | ||
float lowResolution = 240.0; | ||
float d = 1.0 / lowResolution; | ||
float ar = u_resolution.x / u_resolution.y; | ||
|
||
float pixelX = floor( v_texCoords.x / d ); | ||
float u = pixelX * d; | ||
d = ar / lowResolution; | ||
|
||
float pixelY = floor( v_texCoords.y / d ); | ||
float v = pixelY * d; | ||
|
||
vec4 color = texture2D(u_texture, vec2(u, v)); | ||
|
||
// simple dither | ||
float ditherMod = mod(pixelY, 2.0); | ||
color.rgb -= mod(pixelX + ditherMod, 2.0) * 0.01; | ||
|
||
color.rg *= 16.0; | ||
color.b *= 8.0; | ||
color.rgb = floor(color.rgb); | ||
color.rg /= 16.0; | ||
color.b /= 8.0; | ||
|
||
gl_FragColor = color; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
attribute vec4 a_position; | ||
attribute vec2 a_texCoord0; | ||
attribute vec4 a_color; | ||
|
||
uniform mat4 u_projTrans; | ||
uniform mat4 u_proj; | ||
uniform mat4 u_trans; | ||
uniform float u_brightness; | ||
|
||
varying vec4 v_color; | ||
varying vec2 v_texCoords; | ||
|
||
void main() | ||
{ | ||
v_color = a_color; | ||
v_texCoords = a_texCoord0; | ||
gl_Position = u_projTrans * a_position; | ||
} |