Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F112257720
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, May 9, 09:55
Size
1 KB
Mime Type
text/x-c
Expires
Sun, May 11, 09:55 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
26056521
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