|
|
@@ -1,7 +1,9 @@
|
|
|
-#include "Uniforms.frag"
|
|
|
-#include "Samplers.frag"
|
|
|
-#include "Lighting.frag"
|
|
|
-#include "Fog.frag"
|
|
|
+#include "Uniforms.glsl"
|
|
|
+#include "Samplers.glsl"
|
|
|
+#include "Transform.glsl"
|
|
|
+#include "ScreenPos.glsl"
|
|
|
+#include "Lighting.glsl"
|
|
|
+#include "Fog.glsl"
|
|
|
|
|
|
varying vec2 vTexCoord;
|
|
|
#ifdef HEIGHTFOG
|
|
|
@@ -28,14 +30,67 @@ varying vec2 vTexCoord;
|
|
|
varying vec4 vScreenPos;
|
|
|
#endif
|
|
|
|
|
|
+#ifdef COMPILEPS
|
|
|
uniform sampler2D sWeightMap0;
|
|
|
uniform sampler2D sDetailMap1;
|
|
|
uniform sampler2D sDetailMap2;
|
|
|
uniform sampler2D sDetailMap3;
|
|
|
-
|
|
|
uniform vec2 cDetailTiling;
|
|
|
+#endif
|
|
|
+
|
|
|
+void VS()
|
|
|
+{
|
|
|
+ mat4 modelMatrix = iModelMatrix;
|
|
|
+ vec3 worldPos = GetWorldPos(modelMatrix);
|
|
|
+ gl_Position = GetClipPos(worldPos);
|
|
|
+ vTexCoord = GetTexCoord(iTexCoord);
|
|
|
+ vNormal = GetWorldNormal(modelMatrix);
|
|
|
+
|
|
|
+ #ifdef HEIGHTFOG
|
|
|
+ vWorldPos = worldPos;
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #ifdef PERPIXEL
|
|
|
+ // Per-pixel forward lighting
|
|
|
+ vec4 projWorldPos = vec4(worldPos, 1.0);
|
|
|
+
|
|
|
+ #ifdef SHADOW
|
|
|
+ // Shadow projection: transform from world space to shadow space
|
|
|
+ for (int i = 0; i < NUMCASCADES; i++)
|
|
|
+ vShadowPos[i] = GetShadowPos(i, projWorldPos);
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #ifdef SPOTLIGHT
|
|
|
+ // Spotlight projection: transform from world space to projector texture coordinates
|
|
|
+ vSpotPos = cLightMatrices[0] * projWorldPos;
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #ifdef POINTLIGHT
|
|
|
+ vCubeMaskVec = mat3(cLightMatrices[0][0].xyz, cLightMatrices[0][1].xyz, cLightMatrices[0][2].xyz) * (cLightPos.xyz - worldPos);
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #ifdef DIRLIGHT
|
|
|
+ vLightVec = vec4(cLightDir, GetDepth(gl_Position));
|
|
|
+ #else
|
|
|
+ vLightVec = vec4((cLightPos.xyz - worldPos) * cLightPos.w, GetDepth(gl_Position));
|
|
|
+ #endif
|
|
|
+ #ifdef SPECULAR
|
|
|
+ vEyeVec = cCameraPos - worldPos;
|
|
|
+ #endif
|
|
|
+ #else
|
|
|
+ // Ambient & per-vertex lighting
|
|
|
+ vVertexLight = vec4(GetAmbient(GetZonePos(worldPos)), GetDepth(gl_Position));
|
|
|
+
|
|
|
+ #ifdef NUMVERTEXLIGHTS
|
|
|
+ for (int i = 0; i < NUMVERTEXLIGHTS; ++i)
|
|
|
+ vVertexLight.rgb += GetVertexLight(i, worldPos, vNormal) * cVertexLights[i * 3].rgb;
|
|
|
+ #endif
|
|
|
+
|
|
|
+ vScreenPos = GetScreenPos(gl_Position);
|
|
|
+ #endif
|
|
|
+}
|
|
|
|
|
|
-void main()
|
|
|
+void PS()
|
|
|
{
|
|
|
// Get material diffuse albedo
|
|
|
vec3 weights = texture2D(sWeightMap0, vTexCoord).rgb;
|