Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5893: WIP commit, creating the cube map shader, some refactoring
- Loading branch information
1 parent
c437301
commit 22b34e1
Showing
13 changed files
with
101 additions
and
125 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 |
---|---|---|
@@ -1,15 +1,22 @@ | ||
#ifndef GLPROGRAMATTRIBUTES_H_ | ||
#define GLPROGRAMATTRIBUTES_H_ | ||
#pragma once | ||
|
||
namespace render | ||
{ | ||
|
||
/** | ||
* Enumeration for vertex attributes to be bound to a GLProgram, to avoid using | ||
* magic numbers. | ||
*/ | ||
enum GLProgramAttributes { | ||
ATTR_TEXCOORD = 8, | ||
ATTR_TANGENT = 9, | ||
ATTR_BITANGENT = 10, | ||
ATTR_NORMAL = 11 | ||
struct GLProgramAttribute | ||
{ | ||
enum Index | ||
{ | ||
Position = 0, | ||
TexCoord = 8, | ||
Tangent = 9, | ||
Bitangent = 10, | ||
Normal = 11, | ||
}; | ||
}; | ||
|
||
#endif /*GLPROGRAMATTRIBUTES_H_*/ | ||
} |
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,28 +1,12 @@ | ||
#version 120 | ||
|
||
uniform sampler2D u_diffusemap; | ||
uniform sampler2D u_bumpmap; | ||
uniform sampler2D u_specularmap; | ||
uniform sampler2D u_attenuationmap_xy; | ||
uniform sampler2D u_attenuationmap_z; | ||
uniform vec3 u_view_origin; | ||
uniform vec3 u_light_origin; | ||
uniform vec3 u_light_color; | ||
uniform float u_light_scale; | ||
uniform vec3 u_viewOrigin; | ||
|
||
// Invert vertex colour | ||
uniform bool uInvertVCol; | ||
varying vec4 var_TexCoord0; | ||
|
||
// Activate ambient light mode (brightness unaffected by direction) | ||
uniform bool uAmbientLight; | ||
|
||
varying vec3 var_vertex; | ||
varying vec4 var_tex_diffuse_bump; | ||
varying vec2 var_tex_specular; | ||
varying vec4 var_tex_atten_xy_z; | ||
varying mat3 var_mat_os2ts; | ||
|
||
void main() | ||
void main() | ||
{ | ||
gl_FragColor.rgb = vec3(1, 0, 1); | ||
gl_FragColor = vec4(1,1,1,1); | ||
//gl_FragColor.rgb = vec3(var_TexCoord0); | ||
} | ||
|
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,43 +1,21 @@ | ||
// vertex attributes | ||
attribute vec4 attr_TexCoord0; | ||
attribute vec3 attr_Tangent; | ||
attribute vec3 attr_Bitangent; | ||
attribute vec3 attr_Normal; | ||
|
||
varying vec3 var_vertex; | ||
varying vec4 var_tex_diffuse_bump; | ||
varying vec2 var_tex_specular; | ||
varying vec4 var_tex_atten_xy_z; | ||
varying mat3 var_mat_os2ts; | ||
|
||
void main() | ||
{ | ||
// transform vertex position into homogenous clip-space | ||
gl_Position = ftransform(); | ||
|
||
// assign position in object space | ||
var_vertex = gl_Vertex.xyz; | ||
#version 120 | ||
|
||
// transform texcoords into diffusemap texture space | ||
var_tex_diffuse_bump.st = (gl_TextureMatrix[0] * attr_TexCoord0).st; | ||
|
||
// transform texcoords into bumpmap texture space | ||
var_tex_diffuse_bump.pq = (gl_TextureMatrix[1] * attr_TexCoord0).st; | ||
// vertex attributes | ||
attribute vec4 attr_Position; | ||
attribute vec4 attr_TexCoord0; | ||
attribute vec3 attr_Tangent; | ||
attribute vec3 attr_Bitangent; | ||
attribute vec3 attr_Normal; | ||
|
||
// transform texcoords into specularmap texture space | ||
var_tex_specular = (gl_TextureMatrix[2] * attr_TexCoord0).st; | ||
uniform vec3 u_viewOrigin; | ||
|
||
// calc light xy,z attenuation in light space | ||
var_tex_atten_xy_z = gl_TextureMatrix[3] * gl_Vertex; | ||
varying vec4 var_TexCoord0; | ||
|
||
// construct object-space-to-tangent-space 3x3 matrix | ||
var_mat_os2ts = mat3( | ||
attr_Tangent.x, attr_Bitangent.x, attr_Normal.x, | ||
attr_Tangent.y, attr_Bitangent.y, attr_Normal.y, | ||
attr_Tangent.z, attr_Bitangent.z, attr_Normal.z | ||
); | ||
void main() | ||
{ | ||
//var_TexCoord0 = attr_Position - vec4(u_viewOrigin, 1); | ||
var_TexCoord0 = attr_TexCoord0; | ||
|
||
// Pass through vertex colour | ||
gl_FrontColor = gl_Color; | ||
gl_Position = attr_Position; | ||
gl_FrontColor = gl_Color; // Pass through vertex 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
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