Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moblur and crispy lighting added, shaders updated
- Loading branch information
Showing
17 changed files
with
354 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
OpenGL 4.0 Tessellation Test | ||
|
||
Just playing around with the new tessellation shaders. | ||
|
||
Requires OpenGL 4.x and a relatively new graphics card. | ||
|
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
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
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,92 @@ | ||
#version 400 core | ||
|
||
uniform sampler2D tex; | ||
uniform sampler2D posTex; | ||
uniform mat4 modelviewMatrix; | ||
uniform mat4 projMatrix; | ||
|
||
uniform vec3 lightPos; | ||
uniform mat4 modelviewMatrixPrev; | ||
uniform mat4 projMatrixPrev; | ||
uniform mat4 modelviewMatrixCurr; | ||
uniform mat4 projMatrixCurr; | ||
#ifdef _VERTEX_ | ||
in vec3 in_Position; | ||
in vec3 in_Normal; | ||
in vec3 in_TexCoord; | ||
out vec3 pass_TexCoord; | ||
void main(void) { | ||
pass_TexCoord = in_TexCoord; | ||
gl_Position = projMatrix * modelviewMatrix * vec4(in_Position,1.0); | ||
} | ||
|
||
#endif | ||
|
||
#ifdef _FRAGMENT_ | ||
in vec3 pass_TexCoord; | ||
out vec4 out_Color; | ||
|
||
vec4 moblur(vec2 velocity) { | ||
velocity = clamp(velocity, vec2(-0.003, -0.003), vec2(0.003, 0.003)); | ||
vec2 texCoord = pass_TexCoord.st; | ||
vec4 color = texture(tex, texCoord); | ||
int nSamples = 3; | ||
texCoord += velocity; | ||
for(int i = 1; i < nSamples; ++i, texCoord += velocity) { | ||
color += texture(tex, clamp(texCoord, vec2(0.001, 0.001), | ||
vec2(0.999, 0.999))); | ||
} | ||
return color / nSamples; | ||
} | ||
|
||
|
||
vec3 godrays(vec2 texCoord) { | ||
vec4 lightPosSS = projMatrixCurr * modelviewMatrixCurr * vec4(lightPos*5000, 1.0); | ||
lightPosSS /= lightPosSS.w; | ||
float Exposure = .001f; | ||
|
||
vec3 color = vec3(0.0); | ||
|
||
if(lightPosSS.z < 1.0) { //if were facing the light source | ||
lightPosSS += 1.0; | ||
lightPosSS /= 2.0; | ||
const int samples = 70; | ||
float density = 0.975; | ||
float Weight = 6.65; | ||
|
||
float Decay = 1.0; | ||
vec2 deltaTexCoord = (texCoord - lightPosSS.xy); | ||
deltaTexCoord *= 1.0f / samples * density; | ||
vec2 tc = texCoord; | ||
float illuminationDecay = 1.0; | ||
for (int i = 0; i < samples; i++) { | ||
tc -= deltaTexCoord; | ||
vec4 textureColor = texture(tex, tc); | ||
vec3 sampled = textureColor.xyz * textureColor.w; | ||
sampled *= illuminationDecay * Weight; | ||
color += sampled; | ||
illuminationDecay *= Decay; | ||
} | ||
} | ||
|
||
//return vec3(color * Exposure); | ||
return vec3(texture(tex, texCoord).xyz + color * Exposure); | ||
} | ||
|
||
void main() { | ||
/* vec4 pos = texture(posTex, pass_TexCoord.st); | ||
vec4 previousPos = projMatrixPrev * modelviewMatrixPrev * pos; | ||
previousPos /= previousPos.w; | ||
vec2 currentPos = vec2(pass_TexCoord.x * 2 - 1, (pass_TexCoord.y) * 2 - 1); | ||
vec2 velocity = (currentPos-previousPos.st) * 0.5; | ||
out_Color = moblur(velocity).xyz;*/ | ||
// out_Color = texture(tex, pass_TexCoord.st).xyz*1.1; | ||
|
||
const vec3 luminace = vec3(0.2125f, 0.7154f, 0.0721f); | ||
out_Color = vec4(godrays(pass_TexCoord.st), 1.0); | ||
out_Color.w = log(dot(out_Color.xyz, luminace)+0.1); | ||
} | ||
#endif | ||
|
||
|
||
//vec3 color = texture(tex, vec3(pass_TexCoord.st, 1.0)).xxx; |
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,56 @@ | ||
/*float4 ToneMapping( PS_INPUT psInput ) : SV_Target | ||
{ | ||
int2 iScreenCoord = int2(psInput.Tex * depthInfo.yz); | ||
float4 sample = tex2D.Load(int3(iScreenCoord, 0)); | ||
float4 ramp = colorramp.Sample(linearSampler, float2(cOffset, 0.f)); | ||
sample.r += ramp.r - 0.5 * (ramp.g + ramp.b); | ||
sample.g += ramp.g - 0.5 * (ramp.r + ramp.b); | ||
sample.b += ramp.b - 0.5 * (ramp.r + ramp.g); | ||
float Y = dot(sample, CIEXYZ); | ||
float Yw = 0.95; | ||
float Yp = exp(tex2D.Load(int3(0,0,maxMipmapLevel-1)).w); //adaptation luminance | ||
float Yr = alpha * Y / Yp; | ||
float D = (Yr * (1.0 + Yr / (Yw * Yw)) / (1 + Yr)); | ||
return sample * D / Y; | ||
} | ||
*/ | ||
|
||
|
||
#version 400 core | ||
|
||
uniform sampler2D tex; | ||
|
||
uniform mat4 modelviewMatrix; | ||
uniform mat4 projMatrix; | ||
|
||
#ifdef _VERTEX_ | ||
in vec3 in_Position; | ||
in vec3 in_Normal; | ||
in vec3 in_TexCoord; | ||
out vec3 pass_TexCoord; | ||
void main(void) { | ||
pass_TexCoord = in_TexCoord; | ||
gl_Position = projMatrix * modelviewMatrix * vec4(in_Position,1.0); | ||
} | ||
|
||
#endif | ||
|
||
#ifdef _FRAGMENT_ | ||
in vec3 pass_TexCoord; | ||
out vec3 out_Color; | ||
uniform float alpha = 0.75; | ||
vec4 tonemap(vec4 color) { | ||
const vec3 luminace = vec3(0.2125f, 0.7154f, 0.0721f); | ||
float Y = dot(color.xyz, luminace); | ||
float Yw = 0.95; | ||
float Yp = exp(textureLod(tex, vec2(0.5, 0.5), 10.0).w); //adaptation luminance | ||
float Yr = alpha * Y / Yp; | ||
float D = (Yr * (1.0 + Yr / (Yw * Yw)) / (1 + Yr)); | ||
return color * D / Y; | ||
} | ||
|
||
void main() { | ||
vec4 color = tonemap(texture(tex, pass_TexCoord.st)); | ||
out_Color = color.xyz; | ||
} | ||
#endif |
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
Oops, something went wrong.