Started on deferred rendering framework.

This commit is contained in:
Tleety
2014-04-24 00:11:16 +02:00
parent f9a7425249
commit 6d75336496
13 changed files with 289 additions and 150 deletions
+12
View File
@@ -0,0 +1,12 @@
#version 400
in vec3 p_eye;
in vec3 n_eye;
layout (location = 0) out vec4 def_p; // "go to GL_COLOR_ATTACHMENT0"
layout (location = 1) out vec4 def_n; // "go to GL_COLOR_ATTACHMENT1"
void main () {
def_p = vec4(p_eye, 1.0);
def_n = vec4(n_eye, 1.0);
}
+16
View File
@@ -0,0 +1,16 @@
#version 400
layout(location = 0) in vec3 vp;
layout(location = 1) in vec3 vn;
layout(location = 2) in vec2 TextureCoord;
uniform mat4 P, V, M;
out vec3 p_eye;
out vec3 n_eye;
void main () {
p_eye = (V * M * vec4 (vp, 1.0)).xyz;
n_eye = (V * M * vec4 (vn, 0.0)).xyz;
gl_Position = P * vec4 (p_eye, 1.0);
}
+24
View File
@@ -0,0 +1,24 @@
#version 430
uniform sampler2D tDiffuse;
uniform sampler2D tPosition;
uniform sampler2D tNormals;
uniform vec3 cameraPosition;
void main( void )
{
vec4 image = texture2D( tDiffuse, gl_TexCoord[0].xy );
vec4 position = texture2D( tPosition, gl_TexCoord[0].xy );
vec4 normal = texture2D( tNormals, gl_TexCoord[0].xy );
vec3 light = vec3(50,100,50);
vec3 lightDir = light - position.xyz ;
normal = normalize(normal);
lightDir = normalize(lightDir);
vec3 eyeDir = normalize(cameraPosition-position.xyz);
vec3 vHalfVector = normalize(lightDir.xyz+eyeDir);
gl_FragColor = max(dot(normal,lightDir),0) * image + pow(max(dot(normal,vHalfVector),0.0), 100) * 1.5;
}
+9
View File
@@ -0,0 +1,9 @@
#version 430
void main( void )
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_FrontColor = vec4(1.0, 1.0, 1.0, 1.0);
}
-20
View File
@@ -1,20 +0,0 @@
#version 430
in vec2 TexCoord0;
in vec3 Normal0;
in vec3 WorldPos0;
layout (location = 0) out vec3 WorldPosOut;
layout (location = 1) out vec3 DiffuseOut;
layout (location = 2) out vec3 NormalOut;
layout (location = 3) out vec3 TexCoordOut;
uniform sampler2D gColorMap;
void main()
{
WorldPosOut = WorldPos0;
DiffuseOut = texture(gColorMap, TexCoord0).xyz;
NormalOut = normalize(Normal0);
TexCoordOut = vec3(TexCoord0, 0.0);
}
-20
View File
@@ -1,20 +0,0 @@
#version 430
layout (location = 0) in vec3 Position;
layout (location = 1) in vec2 TexCoord;
layout (location = 2) in vec3 Normal;
uniform mat4 gWVP;
uniform mat4 gWorld;
out vec2 TexCoord0;
out vec3 Normal0;
out vec3 WorldPos0;
void main()
{
gl_Position = gWVP * vec4(Position, 1.0);
TexCoord0 = TexCoord;
Normal0 = (gWorld * vec4(Normal, 0.0)).xyz;
WorldPos0 = (gWorld * vec4(Position, 1.0)).xyz;
}