Improved shaders_postprocessing example

This commit is contained in:
Ray 2017-05-16 00:14:14 +02:00
parent c9d6b7e356
commit 65e6a6db53
34 changed files with 24630 additions and 22395 deletions

View file

@ -13,22 +13,22 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
// NOTE: Render size values must be passed from code
const float renderWidth = 800;
const float renderHeight = 450;
const float renderWidth = 800.0;
const float renderHeight = 450.0;
float offset[3] = float[]( 0.0, 1.3846153846, 3.2307692308 );
float weight[3] = float[]( 0.2270270270, 0.3162162162, 0.0702702703 );
vec3 offset = vec3(0.0, 1.3846153846, 3.2307692308);
vec3 weight = vec3(0.2270270270, 0.3162162162, 0.0702702703);
void main()
{
// Texel color fetching from texture sampler
vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight[0];
for (int i = 1; i < 3; i++)
{
tc += texture2D(texture0, fragTexCoord + vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
tc += texture2D(texture0, fragTexCoord - vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
}
vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight.x;
tc += texture2D(texture0, fragTexCoord + vec2(offset.y)/renderWidth, 0.0).rgb*weight.y;
tc += texture2D(texture0, fragTexCoord - vec2(offset.y)/renderWidth, 0.0).rgb*weight.y;
tc += texture2D(texture0, fragTexCoord + vec2(offset.z)/renderWidth, 0.0).rgb*weight.z;
tc += texture2D(texture0, fragTexCoord - vec2(offset.z)/renderWidth, 0.0).rgb*weight.z;
gl_FragColor = vec4(tc, 1.0);
}

View file

@ -12,11 +12,11 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
float hatchOffsetY = 5.0f;
float lumThreshold01 = 0.9f;
float lumThreshold02 = 0.7f;
float lumThreshold03 = 0.5f;
float lumThreshold04 = 0.3f;
float hatchOffsetY = 5.0;
float lumThreshold01 = 0.9;
float lumThreshold02 = 0.7;
float lumThreshold03 = 0.5;
float lumThreshold04 = 0.3;
void main()
{

View file

@ -13,12 +13,11 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
// NOTE: Render size values must be passed from code
const float renderWidth = 800;
const float renderHeight = 450;
const float renderWidth = 800.0;
const float renderHeight = 450.0;
float stitchingSize = 6.0f;
uniform int invert = 0;
float stitchingSize = 6.0;
int invert = 0;
vec4 PostFX(sampler2D tex, vec2 uv)
{

View file

@ -16,11 +16,11 @@ const float PI = 3.1415926535;
void main()
{
float aperture = 178.0f;
float aperture = 178.0;
float apertureHalf = 0.5 * aperture * (PI / 180.0);
float maxFactor = sin(apertureHalf);
vec2 uv = vec2(0);
vec2 uv = vec2(0.0);
vec2 xy = 2.0 * fragTexCoord.xy - 1.0;
float d = length(xy);

View file

@ -13,11 +13,11 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
// NOTE: Render size values must be passed from code
const float renderWidth = 800;
const float renderHeight = 450;
const float renderWidth = 800.0;
const float renderHeight = 450.0;
uniform float pixelWidth = 5.0f;
uniform float pixelHeight = 5.0f;
float pixelWidth = 5.0;
float pixelHeight = 5.0;
void main()
{

View file

@ -13,7 +13,7 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
void main()
{
{
vec3 color = texture2D(texture0, fragTexCoord).rgb;
vec3 colors[3];
colors[0] = vec3(0.0, 0.0, 1.0);
@ -21,10 +21,11 @@ void main()
colors[2] = vec3(1.0, 0.0, 0.0);
float lum = (color.r + color.g + color.b)/3.0;
vec3 tc = vec3(0.0, 0.0, 0.0);
int ix = (lum < 0.5)? 0:1;
vec3 tc = mix(colors[ix], colors[ix+1], (lum-float(ix)*0.5)/0.5);
if (lum < 0.5) tc = mix(colors[0], colors[1], lum/0.5);
else tc = mix(colors[1], colors[2], (lum - 0.5)/0.5);
gl_FragColor = vec4(tc, 1.0);
}

View file

@ -12,8 +12,8 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
float offset = 0;
float frequency = 720/3.0;
float offset = 0.0;
float frequency = 450.0/3.0;
uniform float time;
@ -40,5 +40,5 @@ void main()
vec4 color = texture2D(texture0, fragTexCoord);
gl_FragColor = mix(vec4(0, 0.3, 0, 0), color, wavePos);
gl_FragColor = mix(vec4(0.0, 0.3, 0.0, 0.0), color, wavePos);
}

View file

@ -1,18 +1,17 @@
#version 330
#version 100
precision mediump float;
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
in vec4 fragColor;
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables
uniform vec2 resolution = vec2(800, 450);
vec2 resolution = vec2(800.0, 450.0);
void main()
{