Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*hope you like subtly trippy glsl map water, because that's what you …
…get for now until i fix the flowmap!
- Loading branch information
Showing
2 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
uniform sampler2D diffuse_texture; | ||
uniform sampler2D diffuse_texture2; | ||
|
||
uniform sampler2D normal_texture; | ||
uniform sampler2D env_texture; | ||
uniform vec4 vFogColor; | ||
uniform vec4 output_gamma; | ||
uniform vec4 output_gamma_inv; | ||
uniform float reflection_factor; | ||
varying vec4 Color; | ||
varying vec2 Tex0; | ||
varying vec3 LightDir; | ||
varying vec3 CameraDir; | ||
varying vec4 PosWater; | ||
varying float Fog; | ||
|
||
varying vec2 _worldpos; //swy-- pass the world pos to pixel shader | ||
varying vec2 _sawtooth_fn; // together with the sawtooth for sampling | ||
varying float _triangle_fn; // and the synced triangle wave for masking... | ||
|
||
void main () | ||
{ | ||
vec4 tmpvar_1; | ||
tmpvar_1.zw = PosWater.zw; | ||
vec3 normal_2; | ||
vec4 tex_col_3; | ||
vec4 tmpvar_4; | ||
tmpvar_4.w = Color.w; | ||
vec4 tmpvar_5; | ||
|
||
|
||
|
||
//swy-- unpack vector range from 0.0f - 1.0f to -1.0f - 1.0f | ||
|
||
vec4 flow_sample = texture2D(diffuse_texture2, _worldpos.xy); | ||
vec2 flow_vector = (flow_sample.rg * 2.0f) - 1.0f; | ||
float noise_sample = flow_sample.b; | ||
|
||
flow_vector.x *= -1.f; | ||
|
||
//swy-- sample two times at different points, and show the less | ||
// stretched one at the right time in cycles, permuted by the noise to limit pulsing... | ||
|
||
vec4 sample_a = texture2D(diffuse_texture, vec2((_worldpos.xy*32.0) + (flow_vector*(_sawtooth_fn.x - noise_sample) * 0.5))); | ||
vec4 sample_b = texture2D(diffuse_texture, vec2((_worldpos.xy*32.0) + (flow_vector*(_sawtooth_fn.y - noise_sample) * 0.5))); | ||
|
||
vec4 tex_col = mix(sample_a.rgba, sample_b.rgba, _triangle_fn); | ||
|
||
|
||
|
||
tmpvar_5 = tex_col; | ||
tex_col_3.w = tmpvar_5.w; | ||
tex_col_3.xyz = pow (tmpvar_5.xyz, vec3(2.2, 2.2, 2.2)); | ||
normal_2.xy = ((2.0 * texture2D (normal_texture, (Tex0 * 8.0)).wy) - 1.0); | ||
normal_2.z = sqrt(max (1e-06, (1.0 - | ||
dot (normal_2.xy, normal_2.xy) | ||
))); | ||
vec3 tmpvar_6; | ||
tmpvar_6 = normalize(normal_2); | ||
normal_2 = tmpvar_6; | ||
float tmpvar_7; | ||
tmpvar_7 = (1.0 - clamp (dot ( | ||
normalize(CameraDir) | ||
, tmpvar_6), 0.0, 1.0)); | ||
tmpvar_4.xyz = (Color.xyz + ((0.0204 + | ||
(((0.9796 * tmpvar_7) * (tmpvar_7 * tmpvar_7)) * (tmpvar_7 * tmpvar_7)) | ||
) * Color.xyz)); | ||
vec4 tex_8; | ||
tmpvar_1.xy = (PosWater.xy + (0.35 * tmpvar_6.xy)); | ||
vec4 tmpvar_9; | ||
tmpvar_9 = texture2DProj (env_texture, tmpvar_1); | ||
tex_8.w = tmpvar_9.w; | ||
tex_8.xyz = pow (tmpvar_9.xyz, output_gamma.xyz); | ||
tex_8.xyz = min (tex_8.xyz, 4.0); | ||
tmpvar_4.xyz = (tmpvar_4.xyz * (clamp ( | ||
dot (tmpvar_6, LightDir) | ||
, 0.0, 1.0) * mix (tex_col_3.xyz, tex_8.xyz, reflection_factor))); | ||
tmpvar_4.xyz = pow (tmpvar_4.xyz, output_gamma_inv.xyz); | ||
tmpvar_4.xyz = mix (vFogColor.xyz, tmpvar_4.xyz, Fog); | ||
tmpvar_4.w = (Color.w * tmpvar_5.w); | ||
|
||
|
||
tmpvar_4.a = tmpvar_4.a * tmpvar_4.a * tmpvar_4.a; | ||
|
||
//swy-- tint tweaks | ||
//Output.RGBColor.b *= pow(1.f, 1.f-tex_col.a); | ||
tmpvar_4 *= vec4(0.77f, 0.77f, 0.80f, 0.95f); | ||
tmpvar_4.rgb += (flow_sample.x * 0.03f); | ||
|
||
gl_FragColor = tmpvar_4; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
uniform vec4 vMaterialColor; | ||
uniform vec4 vSunDir; | ||
uniform vec4 vSunColor; | ||
uniform vec4 vAmbientColor; | ||
uniform vec4 vSkyLightDir; | ||
uniform vec4 vSkyLightColor; | ||
uniform float fFogDensity; | ||
uniform mat4 matWorldViewProj; | ||
uniform mat4 matWorldView; | ||
uniform mat4 matWorld; | ||
uniform mat4 matWaterViewProj; | ||
uniform vec4 vCameraPos; | ||
uniform vec4 texture_offset; | ||
uniform vec4 vDepthRT_HalfPixel_ViewportSizeInv; | ||
attribute vec3 inPosition; | ||
attribute vec3 inNormal; | ||
attribute vec4 inColor0; | ||
attribute vec4 inColor1; | ||
attribute vec2 inTexCoord; | ||
varying vec4 Color; | ||
varying vec2 Tex0; | ||
varying vec3 LightDir; | ||
varying vec3 CameraDir; | ||
varying vec4 PosWater; | ||
varying float Fog; | ||
|
||
uniform float time_var; | ||
|
||
varying vec2 _worldpos; //swy-- pass the world pos to pixel shader | ||
varying vec2 _sawtooth_fn; // together with the sawtooth for sampling | ||
varying float _triangle_fn; // and the synced triangle wave for masking... | ||
|
||
void main () | ||
{ | ||
vec4 tmpvar_1; | ||
tmpvar_1.w = 1.0; | ||
tmpvar_1.xyz = inPosition; | ||
vec4 diffuse_light_2; | ||
vec4 tmpvar_3; | ||
vec4 vWorldPos = (matWorld * tmpvar_1); | ||
vec4 tmpvar_5; | ||
tmpvar_5.w = 0.0; | ||
tmpvar_5.xyz = inNormal; | ||
vec3 tmpvar_6; | ||
tmpvar_6 = normalize((matWorld * tmpvar_5).xyz); | ||
vec3 tmpvar_7; | ||
tmpvar_7 = (matWorldView * tmpvar_1).xyz; | ||
vec4 tmpvar_8; | ||
tmpvar_8 = (vAmbientColor + inColor1.zyxw); | ||
diffuse_light_2.w = tmpvar_8.w; | ||
diffuse_light_2.xyz = (tmpvar_8.xyz + (clamp ( | ||
dot (tmpvar_6, -(vSkyLightDir.xyz)) | ||
, 0.0, 1.0) * vSkyLightColor.xyz)); | ||
vec3 tmpvar_9; | ||
tmpvar_9 = -(vSunDir.xyz); | ||
diffuse_light_2.xyz = (diffuse_light_2.xyz + (max (0.0001, | ||
dot (tmpvar_6, tmpvar_9) | ||
) * vSunColor.xyz)); | ||
diffuse_light_2.w = 1.0; | ||
vec4 tmpvar_10; | ||
tmpvar_10 = (matWaterViewProj * vWorldPos); | ||
vec2 tmpvar_11; | ||
tmpvar_11.x = tmpvar_10.x; | ||
tmpvar_11.y = -(tmpvar_10.y); | ||
tmpvar_3.xy = ((tmpvar_11 + tmpvar_10.w) / 2.0); | ||
tmpvar_3.xy = (tmpvar_3.xy + (vDepthRT_HalfPixel_ViewportSizeInv.xy * tmpvar_10.w)); | ||
tmpvar_3.zw = tmpvar_10.zw; | ||
mat3 tmpvar_12; | ||
tmpvar_12[0] = vec3(1.0, 0.0, 0.0); | ||
tmpvar_12[1] = vec3(0.0, 1.0, 0.0); | ||
tmpvar_12[2] = vec3(0.0, 0.0, 1.0); | ||
gl_Position = (matWorldViewProj * tmpvar_1); | ||
Color = ((vMaterialColor * inColor0.zyxw) * diffuse_light_2); | ||
Tex0 = (inTexCoord + texture_offset.xy); | ||
LightDir = (tmpvar_12 * tmpvar_9); | ||
CameraDir = (tmpvar_12 * -(normalize( | ||
(vCameraPos.xyz - vWorldPos.xyz) | ||
))); | ||
PosWater = tmpvar_3; | ||
Fog = (1.0/(exp2(( | ||
sqrt(dot (tmpvar_7, tmpvar_7)) | ||
* fFogDensity)))); | ||
|
||
|
||
//swy-- flowmap time-varying sawtooth and triangle | ||
// functions for animating and masking the flow... | ||
|
||
float time_var_mod = time_var / 10.f; | ||
|
||
//swy-- specially tweaked functions for | ||
// both (n)ormals and diffuse (t)extures... | ||
|
||
float sawtooth_a_n = fract(time_var_mod); | ||
float sawtooth_b_n = fract(time_var_mod + 0.5f); | ||
|
||
float sawtooth_a_t = fract(time_var_mod) - 0.5f; | ||
float sawtooth_b_t = fract(time_var_mod + 0.5f) - 0.5f; | ||
|
||
//swy-- triangle function used for masking by lerp two samples, | ||
// all that is modulated by the upper sawtooths | ||
float triangle_fn = abs(0.5f - sawtooth_a_n) / 0.5f; | ||
|
||
_sawtooth_fn = vec2(sawtooth_a_t, sawtooth_b_t); | ||
_triangle_fn = triangle_fn; | ||
|
||
// ^ | ||
// '-> | ||
//swy-- fits pretty well! took me a long while, tho! | ||
_worldpos = vWorldPos.xy / 374.f; | ||
_worldpos.x -= 0.495f; | ||
_worldpos.y += 0.68f; | ||
|
||
_worldpos.x *= -1.f; | ||
} | ||
|