-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/prophile/xsera
- Loading branch information
Showing
18 changed files
with
151 additions
and
26 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
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
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
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 |
---|---|---|
@@ -1,29 +1,33 @@ | ||
varying vec2 TX; | ||
varying vec3 N; | ||
varying vec3 V; | ||
varying vec3 T; | ||
|
||
const vec3 EyeDir = vec3(0.0, 0.0, 1.0); | ||
|
||
uniform sampler2D tex; | ||
uniform sampler2D tex0; | ||
|
||
uniform float shininess; | ||
uniform float specularScale; | ||
|
||
vec3 peturbNormal(in vec3 normal, in vec2 texCoords); | ||
vec2 peturbTexCoords(in vec3 normal, in vec2 texCoords); | ||
vec3 peturbNormal(in vec3 normal, in vec3 tangent, in vec2 texCoords); | ||
vec2 peturbTexCoords(in vec3 normal, in vec3 tangent, in vec2 texCoords); | ||
vec3 calculateDiffuseLight(in vec3 normal); | ||
vec3 calculateSpecularLight(in vec3 normal, in float exponent); | ||
|
||
vec3 lightDirection(in vec3 vertex); | ||
vec3 lightColour(in vec3 vertex); | ||
|
||
vec3 postprocessColour(in vec3 colour, in vec3 normal); | ||
|
||
void main() | ||
{ | ||
vec3 normal = normalize(N); | ||
normal = peturbNormal(normal, TX); | ||
vec2 texCoord = peturbTexCoords(normal, TX); | ||
vec4 sample = texture2D(tex, texCoord); | ||
vec3 tangent = normalize(T); | ||
normal = peturbNormal(normal, T, TX); | ||
vec2 texCoord = peturbTexCoords(normal, T, TX); | ||
vec4 sample = texture2D(tex0, texCoord); | ||
vec3 light = calculateDiffuseLight(normal); | ||
light += sample.a * specularScale * calculateSpecularLight(normal, shininess); | ||
gl_FragColor = vec4(light * sample.rgb, 1.0); | ||
gl_FragColor = vec4(postprocessColour(light * sample.rgb, normal), 1.0); | ||
} |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
vec3 peturbNormal(in vec3 normal, in vec2 texCoords) | ||
vec3 peturbNormal(in vec3 normal, in vec3 tangent, in vec2 texCoords) | ||
{ | ||
return normal; | ||
} | ||
|
||
vec2 peturbTexCoords(in vec3 normal, in vec2 texCoords) | ||
vec2 peturbTexCoords(in vec3 normal, in vec3 tangent, in vec2 texCoords) | ||
{ | ||
return texCoords; | ||
} |
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,11 @@ | ||
vec3 greyscale(in vec3 col) | ||
{ | ||
return vec3(dot(col, vec3(0.21, 0.66, 0.13))); | ||
} | ||
|
||
vec3 postprocessColour(in vec3 colour, in vec3 normal) | ||
{ | ||
float c = 1.0 - abs(normal.z); | ||
c = pow(c, 4.0); | ||
return mix(colour * 0.2, greyscale(normalize(colour)), c); | ||
} |
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,4 @@ | ||
vec3 postprocessColour(in vec3 colour, in vec3 normal) | ||
{ | ||
return colour; | ||
} |
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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
varying vec2 TX; | ||
varying vec3 N; | ||
varying vec3 V; | ||
varying vec3 T; | ||
attribute vec3 Tangent; | ||
|
||
void main() | ||
{ | ||
vec4 worldPosition = gl_ModelViewMatrix * gl_Vertex; | ||
V = worldPosition.xyz; | ||
TX = gl_MultiTexCoord0.st; | ||
N = gl_NormalMatrix * gl_Normal; | ||
T = gl_NormalMatrix * Tangent; | ||
gl_Position = gl_ProjectionMatrix * worldPosition; | ||
} |