Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91208166
shader.frag
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 8, 23:55
Size
1 KB
Mime Type
text/x-c
Expires
Sun, Nov 10, 23:55 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22220462
Attached To
R9525 cellulo-lovr
shader.frag
View Options
precision highp float;
in vec2 texCoordHack;
const float texCoordHackScale = 0.05;
uniform vec4 CameraEye;
uniform vec4 FogColor;
uniform vec2 FogBounds;
uniform sampler2D causticsTexture;
uniform float time;
uniform float causticsScale;
uniform float causticsAmount;
const float timeScale = 0.04;
in vec4 sVertex;
float getFogFactor(float d) {
float FogMax = FogBounds.y;
float FogMin = FogBounds.x;
if (d>=FogMax) return 1.0;
if (d<=FogMin) return 0.0;
return 1.0 - pow((FogMax - d) / (FogMax - FogMin), 3.0);
}
vec4 color(vec4 graphicsColor, sampler2D image, vec2 uv) {
vec4 c = graphicsColor * lovrDiffuseColor * vertexColor * texture(image, uv);
// apply caustics
float t = time * timeScale;
vec2 texUV = texCoordHack;
c += min(
texture(causticsTexture, texUV / texCoordHackScale * causticsScale + vec2(t, 2.0 + t)),
texture(causticsTexture, texUV / texCoordHackScale * causticsScale + vec2(-t / 2.0, -t))
) * 2.0 * causticsAmount;
// apply fog
float d = distance(CameraEye, sVertex);
float alpha = getFogFactor(d);
c = mix(c, FogColor, alpha);
return c;
}
Event Timeline
Log In to Comment