Skip to content

Commit

Permalink
Adding an ultima underworld inspired post process effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Interrupt committed Nov 17, 2018
1 parent 7857449 commit c45c96d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dungeoneer/assets/data/shaders.dat
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,10 @@
"name": "post_filter_Underworld",
"vertex": "post_filter_underworld.vert",
"fragment": "post_filter_underworld.frag"
},
{
"name": "post_filter_Retro",
"vertex": "post_filter_retro.vert",
"fragment": "post_filter_retro.frag"
}
]
47 changes: 47 additions & 0 deletions Dungeoneer/assets/shaders/post_filter_underworld.frag
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;
}
18 changes: 18 additions & 0 deletions Dungeoneer/assets/shaders/post_filter_underworld.vert
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;
}

0 comments on commit c45c96d

Please sign in to comment.