Created
May 23, 2016 17:53
-
-
Save meeech/ff93f766baa3bec551f280b39c24a695 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local kernel = { | |
category = "generator", | |
name = "stars", | |
isTimeDependent = false | |
} | |
kernel.vertexData = { | |
{ | |
name = 'resolutionX', | |
default = display.pixelWidth, | |
index = 0 | |
}, | |
{ | |
name = 'resolutionY', | |
default = display.pixelHeight, | |
index = 1 | |
}, | |
{ | |
name = 'seed', | |
default = 234203212011.0, | |
index = 2 | |
} | |
} | |
kernel.fragment = | |
[[ | |
#ifdef GL_ES | |
precision P_NORMAL float; | |
#endif | |
// based off http://glslsandbox.com/e#32816.0 | |
float rand(vec2 co) | |
{ | |
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 437.585453); | |
} | |
vec4 FragmentKernel( P_UV vec2 texCoord ){ | |
vec2 resolution = vec2(15); | |
//if you want 'twinkle' effect, turn on isTimeDependent for kernel, and set | |
//seed to be CoronaTotalTime | |
float seed = CoronaVertexUserData.z; | |
float prob = 0.998; | |
float color = 0.0; | |
if (rand(texCoord.xy / resolution.xy) > prob) | |
{ | |
float r = rand(texCoord.xy); | |
color = r * (0.85 * sin(seed * (r * 5.0) + 720.0 * r) + 0.95); | |
} | |
P_COLOR vec4 ret = vec4(vec3(color), 1.0); | |
return CoronaColorScale(ret); | |
} | |
]] | |
graphics.defineEffect(kernel) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment