-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Corrected phong shading method to account for the camera position.
- Loading branch information
Showing
9 changed files
with
81 additions
and
157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,37 @@ | ||
#version 410 | ||
#version 420 // Keeping you on the bleeding edge! | ||
#extension GL_EXT_gpu_shader4 : enable | ||
//#extension GL_ARB_shading_language_420pack: enable // Use for GLSL versions before 420. | ||
|
||
// The modelview and projection matrices are no longer given in OpenGL 4.2 | ||
uniform mat4 M; | ||
uniform mat4 MVP; | ||
uniform mat4 N; // This is the inverse transpose of the MV matrix | ||
uniform mat4 M; | ||
uniform mat4 N; // This is the inverse transpose of the mv matrix | ||
|
||
// The vertex position attribute | ||
layout (location = 0) in vec3 inVert; | ||
layout (location=0) in vec3 inVert; | ||
|
||
// The texture coordinate attribute | ||
layout (location = 1) in vec2 inUV; | ||
layout (location=1) in vec2 inUV; | ||
|
||
// The vertex normal attribute | ||
layout (location = 2) in vec3 inNormal; | ||
layout (location=2) in vec3 inNormal; | ||
|
||
out vec3 FragmentPosition; | ||
out vec3 FragmentNormal; | ||
out vec2 texCoord; | ||
// These attributes are passed onto the shader (should they all be smoothed?) | ||
smooth out vec3 WSVertexPosition; | ||
smooth out vec3 WSVertexNormal; | ||
smooth out vec2 WSTexCoord; | ||
|
||
/************************************************************************************/ | ||
void main() | ||
{ | ||
// Set the position of the current vertex | ||
gl_Position = MVP * vec4(inVert, 1.0); | ||
FragmentPosition = vec3(M * vec4(inVert, 1.0)); | ||
FragmentNormal = vec3(N * vec4(inNormal, 1.0)); | ||
texCoord = inUV; | ||
} | ||
// Transform the vertex normal by the inverse transpose modelview matrix | ||
WSVertexNormal = normalize(vec3(N * vec4(inNormal, 1.0f))); | ||
|
||
// Compute the unprojected vertex position | ||
WSVertexPosition = vec3(M * vec4(inVert, 1.0) ); | ||
|
||
// Copy across the texture coordinates | ||
WSTexCoord = inUV; | ||
|
||
// Compute the position of the vertex | ||
gl_Position = MVP * vec4(inVert,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