custom shader for building gradian

This commit is contained in:
2020-09-11 11:40:39 +02:00
parent 2c673bef63
commit f73d3cceb7
5 changed files with 248 additions and 76 deletions
+33
View File
@@ -0,0 +1,33 @@
// https://gamedevelopment.tutsplus.com/tutorials/a-beginners-guide-to-coding-graphics-shaders--cms-23313
uniform vec3 topColor;
uniform vec3 groundColor;
uniform vec3 bottomColor;
varying vec3 vWorldPosition;
void main() {
float h = vWorldPosition.y;
if(h > 0.0)
{
gl_FragColor = vec4(topColor,1.0);
}
else
{
// gl_FragColor = vec4(bottomColor,1.0);
// h = h * -1.0;
// float hh = abs(normalize( vWorldPosition ).y);
gl_FragColor = vec4(
mix(
groundColor,
bottomColor,
min(abs(h)/100.0,1.0)
// min(h/150.0 , 2.0)
// max(
// pow(
// max( hh , 0.0),
// exponent
// ),
// 0.0
// )
), 1.0
);
}
}