Skip to content

Instantly share code, notes, and snippets.

@xycaleth
Created June 14, 2018 21:07
Show Gist options
  • Save xycaleth/42b21744d634d176b8431032ed229d31 to your computer and use it in GitHub Desktop.
Save xycaleth/42b21744d634d176b8431032ed229d31 to your computer and use it in GitHub Desktop.
Weather
/*[Vertex]*/
uniform float u_Gravity;
uniform float u_DeltaTime;
uniform vec3 u_MapExtents[2];
uniform sampler2D u_OverheadDepthMap;
in vec3 attr_Position;
in vec3 attr_Color;
out vec3 var_Position;
out vec3 var_Velocity;
vec3 NewParticlePosition(in float zmin, in float zmax)
{
vec3 position = var_Position;
position.z += (zmax - zmin);
return position;
}
void main()
{
var_Velocity = attr_Color;
var_Position = attr_Position;
var_Position.z -= 600.0 * 0.16;
vec3 normalizedWorldPosition =
(var_Position - u_MapExtents[0]) / (u_MapExtents[1] - u_MapExtents[0]);
float overheadZ = 1.0 - texture(
u_OverheadDepthMap, normalizedWorldPosition.xy).r;
if (normalizedWorldPosition.z < overheadZ)
var_Position = NewParticlePosition(
u_MapExtents[0].z, u_MapExtents[1].z);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment