3 // =================================================================================================
\r
5 // =================================================================================================
\r
8 <Sampler id="colormap" />
\r
10 <Sampler id="detailmap" />
\r
12 <Context id="ATTRIBPASS">
\r
13 <Shaders vertex="VS_GENERAL" fragment="FS_ATTRIBPASS" />
\r
16 <Context id="SHADOWMAP">
\r
17 <Shaders vertex="VS_SHADOWMAP" fragment="FS_SHADOWMAP" />
\r
20 <Context id="LIGHTING">
\r
21 <Shaders vertex="VS_GENERAL" fragment="FS_LIGHTING" />
\r
22 <RenderConfig writeDepth="false" blendMode="ADD" />
\r
25 <Context id="AMBIENT">
\r
26 <Shaders vertex="VS_GENERAL" fragment="FS_AMBIENT" />
\r
31 // =================================================================================================
\r
33 #include "shaders/utilityLib/vertCommon.glsl"
\r
35 uniform vec3 viewer;
\r
36 attribute vec2 texCoords0;
\r
37 attribute vec3 normal;
\r
39 varying vec4 pos, vsPos;
\r
40 varying vec2 texCoords;
\r
42 varying vec3 tsbNormal;
\r
48 vec3 _normal = calcWorldVec( normal );
\r
50 // Calculate tangent and bitangent
\r
51 tsbNormal = _normal;
\r
53 // Calculate world space position
\r
54 pos = calcWorldPos( gl_Vertex );
\r
56 vsPos = calcViewPos( pos );
\r
58 // Calculate tangent space eye vector
\r
60 // Calculate texture coordinates and clip space position
\r
61 texCoords = vec2(pos.x, pos.z) / 64.0;
\r
62 gl_Position = gl_ModelViewProjectionMatrix * pos;
\r
67 // =================================================================================================
\r
69 #include "shaders/utilityLib/fragDeferredWrite.glsl" />
\r
71 uniform vec4 specParams;
\r
72 uniform sampler2D colormap;
\r
75 varying vec2 texCoords;
\r
77 varying vec3 tsbNormal;
\r
81 vec3 newCoords = vec3( texCoords, 0 );
\r
83 // Flip texture vertically to match the GL coordinate system
\r
84 newCoords.t *= -1.0;
\r
86 vec3 albedo = texture2D( colormap, newCoords.st ).rgb;
\r
88 vec3 normal = tsbNormal;
\r
90 vec3 newPos = pos.xyz;
\r
94 setNormal( normalize( normal ) );
\r
95 setAlbedo( albedo );
\r
96 setSpecMask( specParams.x );
\r
101 // =================================================================================================
\r
103 #include "shaders/utilityLib/vertCommon.glsl"
\r
105 uniform vec4 lightPos;
\r
106 varying float dist;
\r
110 vec4 pos = calcWorldPos( gl_Vertex );
\r
111 dist = length( lightPos.xyz - pos.xyz ) / lightPos.w;
\r
113 gl_Position = gl_ModelViewProjectionMatrix * pos;
\r
118 // =================================================================================================
\r
120 uniform float shadowBias;
\r
121 varying float dist;
\r
125 gl_FragDepth = dist + shadowBias;
\r
127 // Clearly better bias but requires SM 3.0
\r
128 // gl_FragDepth = dist + abs( dFdx( dist ) ) + abs( dFdy( dist ) ) + shadowBias;
\r
133 // =================================================================================================
\r
135 #include "shaders/utilityLib/fragLighting.glsl" />
\r
137 uniform vec4 specParams;
\r
138 uniform sampler2D colormap;
\r
140 varying vec4 pos, vsPos;
\r
141 varying vec2 texCoords;
\r
143 varying vec3 tsbNormal;
\r
147 vec3 newCoords = vec3( texCoords, 0 );
\r
149 // Flip texture vertically to match the GL coordinate system
\r
150 newCoords.t *= -1.0;
\r
152 vec3 albedo = texture2D( colormap, newCoords.st ).rgb;
\r
154 vec3 normal = tsbNormal;
\r
156 vec3 newPos = pos.xyz;
\r
159 calcPhongSpotLight( newPos, normalize( normal ), albedo, specParams.x, specParams.y, -vsPos.z, 0.3 );
\r
164 // =================================================================================================
\r
166 #include "shaders/utilityLib/fragLighting.glsl" />
\r
168 uniform sampler2D colormap;
\r
169 uniform samplerCube ambientMap;
\r
173 varying vec2 texCoords;
\r
175 varying vec3 tsbNormal;
\r
179 vec3 newCoords = vec3( texCoords, 0 );
\r
181 // Flip texture vertically to match the GL coordinate system
\r
182 newCoords.t *= -1.0;
\r
184 vec3 albedo = texture2D( colormap, newCoords.st ).rgb;
\r
186 vec3 normal = tsbNormal;
\r
188 gl_FragColor.rgb = albedo * textureCube( ambientMap, normal ).rgb;
\r