Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/shaders/glsl/model_water.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; | ||||
#if USE_INSTANCING | #if USE_INSTANCING | ||||
attribute vec4 a_tangent; | attribute vec4 a_tangent; | ||||
#endif | #endif | ||||
attribute vec2 a_uv0; | attribute vec2 a_uv0; | ||||
attribute vec2 a_uv1; | attribute vec2 a_uv1; | ||||
#if USE_GPU_SKINNING | #if USE_GPU_SKINNING | ||||
const int MAX_INFLUENCES = 4; | const int MAX_INFLUENCES = 4; | ||||
const int MAX_BONES = 64; | const int MAX_BONES = 64; | ||||
uniform mat4 skinBlendMatrices[MAX_BONES]; | uniform mat4 skinBlendMatrices[MAX_BONES]; | ||||
attribute ivec4 a_skinJoints; | attribute ivec4 a_skinJoints; | ||||
attribute vec4 a_skinWeights; | attribute vec4 a_skinWeights; | ||||
#endif | #endif | ||||
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; | ||||
vec4 fakeCos(vec4 x) | vec4 fakeCos(vec4 x) | ||||
{ | { | ||||
vec4 tri = abs(fract(x + 0.5) * 2.0 - 1.0); | vec4 tri = abs(fract(x + 0.5) * 2.0 - 1.0); | ||||
return tri * tri *(3.0 - 2.0 * tri); | return tri * tri *(3.0 - 2.0 * tri); | ||||
} | } | ||||
void main() | void main() | ||||
{ | { | ||||
worldPos = instancingTransform * vec4(a_vertex, 1.0); | worldPos = instancingTransform * vec4(a_vertex, 1.0); | ||||
v_tex.xy = (a_uv0 + worldPos.xz) / 5.0 + sim_time * translation; | v_tex.xy = (a_uv0 + worldPos.xz) / 5.0 + sim_time * translation; | ||||
v_tex.zw = a_uv0; | v_tex.zw = a_uv0; | ||||
#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; | ||||
gl_Position = transform * worldPos; | gl_Position = transform * worldPos; | ||||
} | } | ||||
Wildfire Games · Phabricator