Changeset View
Standalone View
binaries/data/mods/public/shaders/glsl/water_high.vs
#version 110 | #version 110 | ||||
// Uniforms | |||||
wraitii: Useless | |||||
Not Done Inline ActionsDo you think that it doesn't increase readability? vladislavbelov: Do you think that it doesn't increase readability? | |||||
Not Done Inline ActionsMy opinion is that the name of the variables is explicit enough here. I don't care that much about it though so feel free to commit it with those if you prefer. wraitii: My opinion is that the name of the variables is explicit enough here. I don't care that much… | |||||
uniform mat4 reflectionMatrix; | uniform mat4 reflectionMatrix; | ||||
uniform mat4 refractionMatrix; | uniform mat4 refractionMatrix; | ||||
uniform mat4 losMatrix; | uniform mat4 losMatrix; | ||||
uniform mat4 shadowTransform; | uniform mat4 shadowTransform; | ||||
uniform float repeatScale; | uniform float repeatScale; | ||||
uniform float windAngle; | uniform float windAngle; | ||||
uniform float waviness; // "Wildness" of the reflections and refractions; choose based on texture | uniform float waviness; // "Wildness" of the reflections and refractions; choose based on texture | ||||
StanUnsubmitted Not Done Inline ActionsOn top too :) Stan: On top too :) | |||||
uniform vec3 sunDir; | uniform vec3 sunDir; | ||||
#if USE_SHADOW_SAMPLER && USE_SHADOW_PCF | #if USE_SHADOW_SAMPLER && USE_SHADOW_PCF | ||||
uniform vec4 shadowScale; | uniform vec4 shadowScale; | ||||
#endif | #endif | ||||
uniform float time; | uniform float time; | ||||
uniform float mapSize; | uniform float mapSize; | ||||
varying float moddedTime; | |||||
uniform mat4 transform; | uniform mat4 transform; | ||||
uniform vec3 cameraPos; | |||||
// Varyings | |||||
Not Done Inline ActionsUseless wraitii: Useless | |||||
varying float moddedTime; | |||||
varying vec3 worldPos; | varying vec3 worldPos; | ||||
varying float waterDepth; | varying float waterDepth; | ||||
varying vec2 waterInfo; | varying vec2 waterInfo; | ||||
uniform vec3 cameraPos; | |||||
varying vec3 v; | varying vec3 v; | ||||
varying vec4 normalCoords; | varying vec4 normalCoords; | ||||
varying vec3 reflectionCoords; | varying vec3 reflectionCoords; | ||||
varying vec3 refractionCoords; | varying vec3 refractionCoords; | ||||
varying vec2 losCoords; | varying vec2 losCoords; | ||||
varying float fwaviness; | varying float fwaviness; | ||||
varying vec2 WindCosSin; | varying vec2 WindCosSin; | ||||
#if USE_SHADOW && USE_SHADOWS_ON_WATER | #if USE_SHADOW && USE_SHADOWS_ON_WATER | ||||
varying vec4 v_shadow; | varying vec4 v_shadow; | ||||
#endif | #endif | ||||
// Attributes | |||||
Not Done Inline ActionsUseless wraitii: Useless | |||||
attribute vec3 a_vertex; | attribute vec3 a_vertex; | ||||
attribute vec2 a_waterInfo; | attribute vec2 a_waterInfo; | ||||
attribute vec3 a_otherPosition; | attribute vec3 a_otherPosition; | ||||
void main() | void main() | ||||
{ | { | ||||
worldPos = vec3(a_vertex.x,15.0,a_vertex.z); | worldPos = a_vertex; | ||||
waterInfo = a_waterInfo; | waterInfo = a_waterInfo; | ||||
waterDepth = a_waterInfo.g; | waterDepth = a_waterInfo.g; | ||||
WindCosSin = vec2(cos(-windAngle),sin(-windAngle)); | WindCosSin = vec2(cos(-windAngle), sin(-windAngle)); | ||||
float newX = a_vertex.x * WindCosSin.x - a_vertex.z * WindCosSin.y; | float newX = a_vertex.x * WindCosSin.x - a_vertex.z * WindCosSin.y; | ||||
float newY = a_vertex.x * WindCosSin.y + a_vertex.z * WindCosSin.x; | float newY = a_vertex.x * WindCosSin.y + a_vertex.z * WindCosSin.x; | ||||
Not Done Inline ActionsWhy is it a_vertex.x and not a_vertex.y ? Stan: Why is it a_vertex.x and not a_vertex.y ? | |||||
Not Done Inline ActionsBecause we have a horizontal plane, defined by xOz. But the Y-axis looks upward. The normal has a different space (2D with additional params), so a_vertex.y isn't equal to normalCoords.y. vladislavbelov: Because we have a horizontal plane, defined by `xOz`. But the `Y`-axis looks upward.
The… | |||||
normalCoords = vec4(newX,newY,time,0.0); | normalCoords = vec4(newX, newY, time, 0.0); | ||||
normalCoords.xy *= repeatScale; | normalCoords.xy *= repeatScale; | ||||
reflectionCoords = (reflectionMatrix * vec4(a_vertex, 1.0)).rga; // projective texturing | // Projective texturing | ||||
reflectionCoords = (reflectionMatrix * vec4(a_vertex, 1.0)).rga; | |||||
Done Inline ActionsComment on top, Start with caps Stan: Comment on top, Start with caps | |||||
refractionCoords = (refractionMatrix * vec4(a_vertex, 1.0)).rga; | refractionCoords = (refractionMatrix * vec4(a_vertex, 1.0)).rga; | ||||
losCoords = (losMatrix * vec4(a_vertex, 1.0)).rg; | losCoords = (losMatrix * vec4(a_vertex, 1.0)).rg; | ||||
#if USE_SHADOW && USE_SHADOWS_ON_WATER | #if USE_SHADOW && USE_SHADOWS_ON_WATER | ||||
v_shadow = shadowTransform * vec4(a_vertex, 1.0); | v_shadow = shadowTransform * vec4(a_vertex, 1.0); | ||||
#if USE_SHADOW_SAMPLER && USE_SHADOW_PCF | #if USE_SHADOW_SAMPLER && USE_SHADOW_PCF | ||||
v_shadow.xy *= shadowScale.xy; | v_shadow.xy *= shadowScale.xy; | ||||
#endif | #endif | ||||
#endif | #endif | ||||
v = normalize(cameraPos - worldPos); | v = normalize(cameraPos - worldPos); | ||||
moddedTime = mod(time * 60.0, 8.0) / 8.0; | moddedTime = mod(time * 60.0, 8.0) / 8.0; | ||||
// Fix the waviness for local wind strength | // Fix the waviness for local wind strength | ||||
fwaviness = waviness * ((0.15+a_waterInfo.r/1.15)); | fwaviness = waviness * (0.15 + a_waterInfo.r / 1.15); | ||||
StanUnsubmitted Not Done Inline ActionsAre you sure they didn't just mess up the parenthesis a * ( b + c / d) instead of a * ((b+c) /d) Stan: Are you sure they didn't just mess up the parenthesis
```
a * ( b + c / d)
```
instead of… | |||||
vladislavbelovAuthorUnsubmitted Not Done Inline ActionsI didn't change the expression, you can compare it with the old one: ((0.15+a_waterInfo.r/1.15)) Why the original is so? Because a_waterInfo.r is in [0, 1] as I understand the code. vladislavbelov: I didn't change the expression, you can compare it with the old one:
```lang=cpp
((0. | |||||
StanUnsubmitted Not Done Inline ActionsYeah, I know I was just wondering if they didn't mess up somehow :) Sounds like magic numbers tho Stan: Yeah, I know I was just wondering if they didn't mess up somehow :)
Sounds like magic numbers… | |||||
vladislavbelovAuthorUnsubmitted Not Done Inline ActionsThere are many magic number in shaders sadly. We need to fix it somewhen. vladislavbelov: There are many magic number in shaders sadly. We need to fix it somewhen. | |||||
wraitiiUnsubmitted Not Done Inline ActionsThese don't really have semantic value, I think. calling them WAVINESS_FIX_CONSTANT won't help the issue. wraitii: These don't really have semantic value, I think. calling them WAVINESS_FIX_CONSTANT won't help… | |||||
gl_Position = transform * vec4(a_vertex, 1.0); | gl_Position = transform * vec4(a_vertex, 1.0); | ||||
} | } |
Useless