-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nemrav
committed
Dec 17, 2024
1 parent
8e911c8
commit af0ba44
Showing
6 changed files
with
356 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
shader_type spatial; | ||
render_mode unshaded; | ||
|
||
uniform sampler2D projections[3] : source_color; | ||
uniform float sizes[3]; | ||
uniform float spin[3]; | ||
uniform float expanding[3]; | ||
uniform float duration[3]; | ||
uniform bool additative[3]; //if true, black becomes a transparency colour | ||
uniform float time = 0.0; | ||
|
||
void vertex() { | ||
COLOR = INSTANCE_CUSTOM; | ||
uint type = uint(COLOR.x + 0.5); | ||
float start_time = COLOR.y; | ||
|
||
float rot = time*spin[type]; | ||
mat3 rotation_matrix = mat3( | ||
vec3(cos(-rot), 0.0, sin(-rot)), | ||
vec3(0.0, 1.0, 0.0), | ||
vec3(-sin(-rot), 0.0, cos(-rot)) | ||
); | ||
VERTEX.xyz *= rotation_matrix * | ||
clamp( | ||
expanding[type] * mod(time-start_time,3600.0), | ||
0.0, | ||
sizes[type] | ||
); | ||
} | ||
|
||
void fragment() { | ||
// Called for every pixel the material is visible on. | ||
uint type = uint(COLOR.x + 0.5); | ||
vec4 sample = texture(projections[type],UV); | ||
ALBEDO.rgb = sample.rgb; | ||
|
||
float start_time = COLOR.y; | ||
//if time exceeded: 0.0, else 1.0 | ||
//This produces a nicer effect than vic2, shame we can't use it | ||
//float is_finished = clamp(duration[type] - mod(time-start_time,3600.0),0.0,1.0); | ||
float is_finished = ceil(clamp(duration[type] - mod(time-start_time,3600.0),0.0,1.0)); | ||
if(duration[type] == 0.0){ | ||
is_finished = 1.0; | ||
} | ||
//if additative, then black = transparent, otherwise use alpha | ||
float add_tr = float(additative[type]); | ||
float not_add_tr = float(!additative[type]); | ||
//is_finished* | ||
ALPHA = is_finished*(not_add_tr*sample.a + add_tr*(sample.r+sample.g+sample.b)); | ||
} |
Oops, something went wrong.