From 648ee61ae84216d0236e0dbc211addc13b2cfa3a Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:52:06 -0700 Subject: Expand tabs --- assets/shaders/ub_vshader.glsl | 232 ++++++++++++++++++++--------------------- 1 file changed, 116 insertions(+), 116 deletions(-) (limited to 'assets/shaders/ub_vshader.glsl') diff --git a/assets/shaders/ub_vshader.glsl b/assets/shaders/ub_vshader.glsl index a559d844..da8a8660 100755 --- a/assets/shaders/ub_vshader.glsl +++ b/assets/shaders/ub_vshader.glsl @@ -44,65 +44,65 @@ uniform vec3 u_eye; // attributes #if defined( MATERIAL ) - uniform vec4 u_ambientColor; - uniform vec4 u_diffuseColor; - uniform vec4 u_specularColor; - uniform float u_specularPower; + uniform vec4 u_ambientColor; + uniform vec4 u_diffuseColor; + uniform vec4 u_specularColor; + uniform float u_specularPower; #endif #if defined( LIGHTING ) - varying vec3 v_normal; - #if defined( LIGHT_0 ) - uniform int u_light0Type; - uniform vec3 u_light0Pos; - uniform vec3 u_light0Dir; - uniform vec3 u_light0Atten; - uniform vec2 u_light0Spot; - uniform vec4 u_light0Color; - uniform vec4 u_light0Specular; - varying vec3 v_light0Dir; - varying vec3 v_light0SpotDir; - #endif - - #if defined( LIGHT_1 ) - uniform int u_light1Type; - uniform vec3 u_light1Pos; - uniform vec3 u_light1Dir; - uniform vec3 u_light1Atten; - uniform vec2 u_light1Spot; - uniform vec3 u_light1Color; - uniform vec4 u_light1Specular; - varying vec3 v_light1Dir; - varying vec3 v_light1SpotDir; - #endif - - #if defined( LIGHT_2 ) - uniform int u_light2Type; // 0 - dir, 1 - point, 2 - spot - uniform vec3 u_light2Pos; - uniform vec3 u_light2Dir; - uniform vec3 u_light2Atten; - uniform vec2 u_light2Spot; // 0 - spot light cutoff angle, 1 - spot light exponent - uniform vec3 u_light2Color; - uniform vec4 u_light2Specular; - varying vec3 v_light2Dir; - varying vec3 v_light2SpotDir; - #endif - - #if defined( LIGHT_3 ) - uniform int u_light3Type; - uniform vec3 u_light3Pos; - uniform vec3 u_light3Dir; - uniform vec3 u_light3Atten; - uniform vec2 u_light3Spot; - uniform vec3 u_light3Color; - uniform vec4 u_light3Specular; - varying vec3 v_light3Dir; - varying vec3 v_light3SpotDir; - #endif + varying vec3 v_normal; + #if defined( LIGHT_0 ) + uniform int u_light0Type; + uniform vec3 u_light0Pos; + uniform vec3 u_light0Dir; + uniform vec3 u_light0Atten; + uniform vec2 u_light0Spot; + uniform vec4 u_light0Color; + uniform vec4 u_light0Specular; + varying vec3 v_light0Dir; + varying vec3 v_light0SpotDir; + #endif + + #if defined( LIGHT_1 ) + uniform int u_light1Type; + uniform vec3 u_light1Pos; + uniform vec3 u_light1Dir; + uniform vec3 u_light1Atten; + uniform vec2 u_light1Spot; + uniform vec3 u_light1Color; + uniform vec4 u_light1Specular; + varying vec3 v_light1Dir; + varying vec3 v_light1SpotDir; + #endif + + #if defined( LIGHT_2 ) + uniform int u_light2Type; // 0 - dir, 1 - point, 2 - spot + uniform vec3 u_light2Pos; + uniform vec3 u_light2Dir; + uniform vec3 u_light2Atten; + uniform vec2 u_light2Spot; // 0 - spot light cutoff angle, 1 - spot light exponent + uniform vec3 u_light2Color; + uniform vec4 u_light2Specular; + varying vec3 v_light2Dir; + varying vec3 v_light2SpotDir; + #endif + + #if defined( LIGHT_3 ) + uniform int u_light3Type; + uniform vec3 u_light3Pos; + uniform vec3 u_light3Dir; + uniform vec3 u_light3Atten; + uniform vec2 u_light3Spot; + uniform vec3 u_light3Color; + uniform vec4 u_light3Specular; + varying vec3 v_light3Dir; + varying vec3 v_light3SpotDir; + #endif #endif #if defined( ENVIRONMENT_MAP ) - uniform float u_envReflection; + uniform float u_envReflection; #endif varying vec3 v_mvPos; @@ -111,76 +111,76 @@ varying vec2 v_texcoord; #if defined( PC ) void main() { - // position normals and vert - v_mvPos = ( u_mvMatrix * vec4( a_pos, 1.0 ) ).xyz; + // position normals and vert + v_mvPos = ( u_mvMatrix * vec4( a_pos, 1.0 ) ).xyz; - v_texcoord = (u_uvMatrix * vec4(a_texcoord, 0, 1.0)).xy; + v_texcoord = (u_uvMatrix * vec4(a_texcoord, 0, 1.0)).xy; #if ( defined( LIGHTING ) || defined( ENVIRONMENT_MAP ) ) - v_normal = ( u_normalMatrix * vec4( a_normal, 0.0 ) ).xyz; + v_normal = ( u_normalMatrix * vec4( a_normal, 0.0 ) ).xyz; #endif #if defined( LIGHTING ) - v_eyeDir = vec3(-u_viewMatrix[3][0], -u_viewMatrix[3][1], -u_viewMatrix[3][2]); - #if defined( LIGHT_0 ) - { - vec3 lpos = ( u_viewMatrix * vec4( u_light0Pos, 1.0 ) ).xyz; - - #if ( LIGHT_0 == 0 ) - v_light0Dir = ( u_viewMatrix * vec4( -u_light0Dir, 0.0 ) ).xyz; - #else - v_light0Dir = lpos - v_mvPos; - #if ( LIGHT_0 == 2 ) - v_light0SpotDir = (u_viewMatrix * vec4( -u_light0Dir, 0.0 )).xyz; - #endif // ( LIGHT_0 == 2 ) - #endif // ( LIGHT_0 == 0 ) - } - #endif // defined( LIGHT_0 ) - #if defined( LIGHT_1 ) - { - vec3 lpos = ( u_viewMatrix * vec4( u_light1Pos, 1.0 ) ).xyz; - - #if ( LIGHT_1 == 0 ) - v_light1Dir = ( u_viewMatrix * vec4( -u_light1Dir, 0.0 ) ).xyz; - #else - v_light1Dir = lpos - v_mvPos; - #if ( LIGHT_1 == 2 ) - v_light1SpotDir = (u_viewMatrix * vec4( -u_light1Dir, 0.0 )).xyz; - #endif // ( LIGHT_1 == 2 ) - #endif // ( LIGHT_1 == 0 ) - } - #endif // defined( LIGHT_1 ) - #if defined( LIGHT_2 ) - { - vec3 lpos = ( u_viewMatrix * vec4( u_light2Pos, 1.0 ) ).xyz; - - #if ( LIGHT_2 == 0 ) - v_light2Dir = ( u_viewMatrix * vec4( -u_light2Dir, 0.0 ) ).xyz; - #else - v_light2Dir = lpos - v_mvPos; - #if ( LIGHT_2 == 2 ) - v_light2SpotDir = (u_viewMatrix * vec4( -u_light2Dir, 0.0 )).xyz; - #endif // ( LIGHT_2 == 2 ) - #endif // ( LIGHT_2 == 0 ) - } - #endif // defined( LIGHT_2 ) - #if defined( LIGHT_3 ) - { - vec3 lpos = ( u_viewMatrix * vec4( u_light3Pos, 1.0 ) ).xyz; - - #if ( LIGHT_3 == 0 ) - v_light3Dir = ( u_viewMatrix * vec4( -u_light3Dir, 0.0 ) ).xyz; - #else - v_light3Dir = lpos - v_mvPos; - #if ( LIGHT_3 == 2 ) - v_light3SpotDir = (u_viewMatrix * vec4( -u_light3Dir, 0.0 )).xyz; - #endif // ( LIGHT_3 == 2 ) - #endif // ( LIGHT_3 == 0 ) - } - #endif // defined( LIGHT_3 ) + v_eyeDir = vec3(-u_viewMatrix[3][0], -u_viewMatrix[3][1], -u_viewMatrix[3][2]); + #if defined( LIGHT_0 ) + { + vec3 lpos = ( u_viewMatrix * vec4( u_light0Pos, 1.0 ) ).xyz; + + #if ( LIGHT_0 == 0 ) + v_light0Dir = ( u_viewMatrix * vec4( -u_light0Dir, 0.0 ) ).xyz; + #else + v_light0Dir = lpos - v_mvPos; + #if ( LIGHT_0 == 2 ) + v_light0SpotDir = (u_viewMatrix * vec4( -u_light0Dir, 0.0 )).xyz; + #endif // ( LIGHT_0 == 2 ) + #endif // ( LIGHT_0 == 0 ) + } + #endif // defined( LIGHT_0 ) + #if defined( LIGHT_1 ) + { + vec3 lpos = ( u_viewMatrix * vec4( u_light1Pos, 1.0 ) ).xyz; + + #if ( LIGHT_1 == 0 ) + v_light1Dir = ( u_viewMatrix * vec4( -u_light1Dir, 0.0 ) ).xyz; + #else + v_light1Dir = lpos - v_mvPos; + #if ( LIGHT_1 == 2 ) + v_light1SpotDir = (u_viewMatrix * vec4( -u_light1Dir, 0.0 )).xyz; + #endif // ( LIGHT_1 == 2 ) + #endif // ( LIGHT_1 == 0 ) + } + #endif // defined( LIGHT_1 ) + #if defined( LIGHT_2 ) + { + vec3 lpos = ( u_viewMatrix * vec4( u_light2Pos, 1.0 ) ).xyz; + + #if ( LIGHT_2 == 0 ) + v_light2Dir = ( u_viewMatrix * vec4( -u_light2Dir, 0.0 ) ).xyz; + #else + v_light2Dir = lpos - v_mvPos; + #if ( LIGHT_2 == 2 ) + v_light2SpotDir = (u_viewMatrix * vec4( -u_light2Dir, 0.0 )).xyz; + #endif // ( LIGHT_2 == 2 ) + #endif // ( LIGHT_2 == 0 ) + } + #endif // defined( LIGHT_2 ) + #if defined( LIGHT_3 ) + { + vec3 lpos = ( u_viewMatrix * vec4( u_light3Pos, 1.0 ) ).xyz; + + #if ( LIGHT_3 == 0 ) + v_light3Dir = ( u_viewMatrix * vec4( -u_light3Dir, 0.0 ) ).xyz; + #else + v_light3Dir = lpos - v_mvPos; + #if ( LIGHT_3 == 2 ) + v_light3SpotDir = (u_viewMatrix * vec4( -u_light3Dir, 0.0 )).xyz; + #endif // ( LIGHT_3 == 2 ) + #endif // ( LIGHT_3 == 0 ) + } + #endif // defined( LIGHT_3 ) #endif // defined( LIGHTING ) - // pass along the geo - gl_Position = u_projMatrix * vec4(v_mvPos, 1.0); + // pass along the geo + gl_Position = u_projMatrix * vec4(v_mvPos, 1.0); } #endif -- cgit v1.2.3