33a540806e
Added $reflection texture map for (water) shaders. Just renders the screen to an fbo before rendering the surface. hub/savegame fixes. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4034 fc73d0e0-1445-4013-8a0c-d673dee63da5
43 lines
1.3 KiB
GLSL
43 lines
1.3 KiB
GLSL
!!cvarf crep_decay
|
|
!!cvarf crep_density
|
|
!!cvarf crep_weight
|
|
|
|
//this is a post-processing shader, drawn in 2d
|
|
//there will be a render target containing sky surfaces drawn with crepuscular_sky, and everything else drawn with crepuscular_opaque (to mask out the sky)
|
|
//this shader then just smudges the sky out a bit as though its coming from the sun or whatever through the clouds.
|
|
//yoinked from http://fabiensanglard.net/lightScattering/index.php
|
|
|
|
varying vec2 tc;
|
|
#ifdef VERTEX_SHADER
|
|
attribute vec2 v_texcoord;
|
|
void main ()
|
|
{
|
|
tc = v_texcoord;
|
|
gl_Position = v_position;
|
|
}
|
|
#endif
|
|
#ifdef FRAGMENT_SHADER
|
|
const float crep_decay = 0.94;
|
|
const float crep_density = 0.5;
|
|
const float crep_weight = 0.2;
|
|
uniform vec3 l_lightcolour;
|
|
uniform vec3 l_lightscreen;
|
|
uniform sampler2D s_t0;
|
|
const int NUM_SAMPLES = 100;
|
|
void main()
|
|
{
|
|
vec2 deltaTextCoord = vec2(tc.st - l_lightscreen.xy);
|
|
vec2 textCoo = tc.st;
|
|
deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * crep_density;
|
|
float illuminationDecay = 1.0;
|
|
for(int i=0; i < NUM_SAMPLES ; i++)
|
|
{
|
|
textCoo -= deltaTextCoord;
|
|
vec4 sample = texture2D(s_t0, textCoo);
|
|
sample *= illuminationDecay * crep_weight;
|
|
gl_FragColor += sample;
|
|
illuminationDecay *= crep_decay;
|
|
}
|
|
gl_FragColor *= vec4(l_lightcolour, 1.0);
|
|
}
|
|
#endif
|