Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<script id="vertexShader" type="x-shader/x-vertex">
uniform float sunVectorDelta;
uniform float sunFragmentDelta;
varying vec2 vUv;
varying float randomNum;
float rand(vec2 co){
return fract(sin(dot(-co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
void main()
{
vUv = uv + vec2(sunVectorDelta, sunVectorDelta);
if(vUv.x > 1.0 || vUv.x < -1.0){
vUv.x = rand(uv);
}
if(vUv.y > 1.0 || vUv.y < -1.0){
vUv.y = rand(uv);
}
randomNum = rand(uv) + sunFragmentDelta;
gl_Position = projectionMatrix *
modelViewMatrix *
vec4(position,1.0);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment