[2D] Sparkling star effect

。Opening

It is a sparkling star effect.

一個閃爍旋轉星星

 

。Description

Variable introduce|變數介紹:

 

source_color => The color of a sparkling star|星星的顏色 

alpha => Initial opacity, but not “Intial”..|初始透明度(但不”初始”)

shney_disperse => Light dispersing extent|光的”分散”程度

shney_speed => sparkling effect speed|閃爍速度

twist_speed => twist speed, and also meaning twist level|扭曲速度與程度

rota_speed => rotation speed|旋轉速度(負數為反方向旋轉)

curve_ci => thin(be a star) to fat(be a circle)|瘦(星星) 到 胖(圓圓)的係數

Shader code
shader_type canvas_item;

uniform vec4 color: source_color = vec4(1.0,1.0,1.0,1.0);
uniform float alpha: hint_range(-2.0,2.0) = -.5;
uniform float shney_disperse: hint_range(0.01,10.0) = 1.;
uniform float shney_speed: hint_range(0.0,1000.0) = .5;
uniform float twist_speed: hint_range(-2.0,2.0) = 1.;
uniform float rota_speed: hint_range(-10.0,10.0) = 1.;
uniform float curve_ci: hint_range(0.0,2.0) = .3;

void fragment() {

	vec2 uv = (UV - 0.5)*2.0;

	vec2 a = vec2(cos(TIME*rota_speed),-sin(TIME*rota_speed));
	vec2 b = vec2(sin(TIME*rota_speed),cos(TIME*rota_speed)*twist_speed);

	uv = vec2(uv.x*a.x + uv.y*a.y, uv.x*b.x + uv.y*b.y);

    float sig2 = sin(mod(TIME*shney_speed,PI))*(1.);
    float L = (1./(2.*PI*sig2))*exp(-((pow(uv.x,2.)+pow(uv.y,2.))/(2.*sig2*shney_disperse))) + alpha;

	if (uv.x > 0.0 && uv.y > 0.0) {

		if (uv.y <= pow(-(pow(uv.x,curve_ci) - 1.0),1.0/curve_ci)) {

			COLOR = color;
			COLOR.a = L;
		} else {

			COLOR.a = 0.0;
		}
	} else if (uv.x > 0.0 && uv.y < 0.0) {

		if (uv.y >= -pow(-(pow(uv.x,curve_ci) - 1.0),1.0/curve_ci) ) {

			COLOR = color;
			COLOR.a = L;
		} else {

			COLOR.a = 0.0;
		}
	} else if (uv.x < 0.0 && uv.y > 0.0) {

		if (uv.y <= pow(-(pow(-uv.x,curve_ci) - 1.0),1.0/curve_ci) ) {

			COLOR = color;
			COLOR.a = L;
		} else {

			COLOR.a = 0.0;
		}
	} else if (uv.x < 0.0 && uv.y < 0.0) {

		if (uv.y >= -pow(-(pow(-uv.x,curve_ci) - 1.0),1.0/curve_ci) ) {

			COLOR = color;
			COLOR.a = L;
		} else {

			COLOR.a = 0.0;
		}
	}
}
Live Preview
Tags
2d, spark, star
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from xcv145336

Related shaders

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments