Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/shaders/glsl/model_waterfall.vs
#if USE_GPU_SKINNING | #if USE_GPU_SKINNING | ||||
// Skinning requires GLSL 1.30 for ivec4 vertex attributes | // Skinning requires GLSL 1.30 for ivec4 vertex attributes | ||||
#version 130 | #version 130 | ||||
#else | #else | ||||
#version 120 | #version 120 | ||||
#endif | #endif | ||||
#include "common/shadows_vertex.h" | |||||
uniform mat4 transform; | uniform mat4 transform; | ||||
uniform vec3 cameraPos; | uniform vec3 cameraPos; | ||||
uniform vec3 sunDir; | uniform vec3 sunDir; | ||||
uniform vec3 sunColor; | uniform vec3 sunColor; | ||||
uniform vec2 losTransform; | uniform vec2 losTransform; | ||||
uniform mat4 shadowTransform; | |||||
uniform mat4 instancingTransform; | uniform mat4 instancingTransform; | ||||
uniform float sim_time; | uniform float sim_time; | ||||
uniform vec2 translation; | uniform vec2 translation; | ||||
#if USE_SHADOW_SAMPLER && USE_SHADOW_PCF | |||||
uniform vec4 shadowScale; | |||||
#endif | |||||
attribute vec3 a_vertex; | attribute vec3 a_vertex; | ||||
attribute vec3 a_normal; | attribute vec3 a_normal; | ||||
attribute vec2 a_uv0; | attribute vec2 a_uv0; | ||||
attribute vec2 a_uv1; | attribute vec2 a_uv1; | ||||
varying vec4 worldPos; | varying vec4 worldPos; | ||||
varying vec4 v_tex; | varying vec4 v_tex; | ||||
varying vec4 v_shadow; | |||||
varying vec2 v_los; | varying vec2 v_los; | ||||
varying vec3 v_half; | varying vec3 v_half; | ||||
varying vec3 v_normal; | varying vec3 v_normal; | ||||
varying float v_transp; | varying float v_transp; | ||||
varying vec3 v_lighting; | varying vec3 v_lighting; | ||||
void main() | void main() | ||||
{ | { | ||||
worldPos = instancingTransform * vec4(a_vertex, 1.0); | worldPos = instancingTransform * vec4(a_vertex, 1.0); | ||||
v_tex.xy = a_uv0 + sim_time * translation; | v_tex.xy = a_uv0 + sim_time * translation; | ||||
v_transp = a_uv1.x; | v_transp = a_uv1.x; | ||||
#if USE_SHADOW | calculatePositionInShadowSpace(worldPos); | ||||
v_shadow = shadowTransform * worldPos; | |||||
#if USE_SHADOW_SAMPLER && USE_SHADOW_PCF | |||||
v_shadow.xy *= shadowScale.xy; | |||||
#endif | |||||
#endif | |||||
v_los = worldPos.xz * losTransform.x + losTransform.y; | v_los = worldPos.xz * losTransform.x + losTransform.y; | ||||
vec3 eyeVec = cameraPos.xyz - worldPos.xyz; | vec3 eyeVec = cameraPos.xyz - worldPos.xyz; | ||||
vec3 sunVec = -sunDir; | vec3 sunVec = -sunDir; | ||||
v_half = normalize(sunVec + normalize(eyeVec)); | v_half = normalize(sunVec + normalize(eyeVec)); | ||||
mat3 normalMatrix = mat3(instancingTransform[0].xyz, instancingTransform[1].xyz, instancingTransform[2].xyz); | mat3 normalMatrix = mat3(instancingTransform[0].xyz, instancingTransform[1].xyz, instancingTransform[2].xyz); | ||||
v_normal = normalMatrix * a_normal; | v_normal = normalMatrix * a_normal; | ||||
v_lighting = max(0.0, dot(v_normal, -sunDir)) * sunColor; | v_lighting = max(0.0, dot(v_normal, -sunDir)) * sunColor; | ||||
gl_Position = transform * worldPos; | gl_Position = transform * worldPos; | ||||
} | } | ||||
Wildfire Games · Phabricator