ANueUtsuho wrote: ↑Sat Mar 21, 2020 9:42 pm

How would you change the color of the beam?

The colour is generated based on distance on the ring using the shader (ringburner.frag).

Little breakdown: Here's the line that's important:

c.rgba = mix(vec4((0.9 + 0.1 * grad) * alpha,(0.7 + 0.3 * grad) * alpha,(0.3 + 0.4 * grad) * alpha,alpha), vec4(0,0,0,0), 1- and(gt(dist, radius-8), lt(dist, radius)));

Lot to unpack here. So first let's break up the "mix":

mix(a, b, c)

Mix selects between a and b based on where c is between 0 and 1.

So here this selects between a complicated vec4 (color) input, and the color "transparent" (0,0,0,0) based on the formula that comes after (comparing distance). The mix is basically what makes it look like a ring. The "a" argument is the important bit for us:

vec4((0.9 + 0.1 * grad) * alpha,(0.7 + 0.3 * grad) * alpha,(0.3 + 0.4 * grad) * alpha,alpha)

This is a vec4 (a color consisting of red, green, blue and alpha values). Lemme break down the variables:

"grad" is introduced in the line before and is the gradient you can see going outward from the center (from red to orange).

"alpha" is the fadeout over time and set from the lua file as a uniform.

So let's look at the individual components of the vec4 (r, g, b, a)

r: (0.9 + 0.1 * grad) * alpha - almost completely red starting out, gradually increasing to COMPLETELY red

g: (0.7 + 0.3 * grad) * alpha - a bit of green at the start, leading to a matched red and green at grad=1 (outer ring). So with red and green both that's yellow-ish

b: (0.3 + 0.4 * grad) * alpha - a lot less blue (going from 30% to 70%), adding some lightness and whiteness to it

a: alpha (just the input alpha)

By changing the numeric values you can get different colour results and different gradients. Think of grad=0 as the inner edge and grad=1 as the outer edge. So for black you would do rgb 0,0,0 for the inner edge, and then if you do rgb 0,0,1 for the multiplier for the outer edge you end up with blue.

You can also remove the righthandside of the + sign for each of these to remove the gradient entirely, since you will only have a flat numeric color value.

Hope this helps.