mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added rotation to leaf particles.
This commit is contained in:
parent
237d33e9aa
commit
0a3f0db26d
@ -52,6 +52,7 @@ struct Attr {
|
||||
vec3 offs;
|
||||
float scale;
|
||||
vec4 col;
|
||||
mat3 rot;
|
||||
};
|
||||
|
||||
float lifetime = tick.x - inst_time;
|
||||
@ -72,6 +73,19 @@ float linear_scale(float factor) {
|
||||
return lifetime * factor;
|
||||
}
|
||||
|
||||
mat3 rotationMatrix(vec3 axis, float angle)
|
||||
{
|
||||
axis = normalize(axis);
|
||||
float s = sin(angle);
|
||||
float c = cos(angle);
|
||||
float oc = 1.0 - c;
|
||||
|
||||
return mat3(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s,
|
||||
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s,
|
||||
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c);
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
float rand0 = hash(vec4(inst_entropy + 0));
|
||||
float rand1 = hash(vec4(inst_entropy + 1));
|
||||
@ -81,6 +95,8 @@ void main() {
|
||||
float rand5 = hash(vec4(inst_entropy + 5));
|
||||
float rand6 = hash(vec4(inst_entropy + 6));
|
||||
float rand7 = hash(vec4(inst_entropy + 7));
|
||||
float rand8 = hash(vec4(inst_entropy + 8));
|
||||
float rand9 = hash(vec4(inst_entropy + 9));
|
||||
|
||||
Attr attr;
|
||||
|
||||
@ -91,7 +107,8 @@ void main() {
|
||||
vec3(rand2 * 0.1, rand3 * 0.1, 1.0 + rand4 * 0.1)// + vec3(sin(lifetime), sin(lifetime + 1.5), sin(lifetime * 4) * 0.25)
|
||||
),
|
||||
linear_scale(0.5),
|
||||
vec4(1, 1, 1, 0.3)
|
||||
vec4(1, 1, 1, 0.3),
|
||||
rotationMatrix(vec3(1,0,0),0)
|
||||
);
|
||||
} else if (inst_mode == FIRE) {
|
||||
attr = Attr(
|
||||
@ -100,7 +117,8 @@ void main() {
|
||||
vec3(rand2 * 0.1, rand3 * 0.1, 2.0 + rand4 * 1.0)
|
||||
),
|
||||
1.0,
|
||||
vec4(2, 0.8 + rand5 * 0.3, 0, 1)
|
||||
vec4(2, 0.8 + rand5 * 0.3, 0, 1),
|
||||
rotationMatrix(vec3(1,0,0),0)
|
||||
);
|
||||
} else if (inst_mode == GUN_POWDER_SPARK) {
|
||||
attr = Attr(
|
||||
@ -109,7 +127,8 @@ void main() {
|
||||
vec3(rand4, rand5, rand6) * 2.0 + grav_vel(earth_gravity)
|
||||
),
|
||||
1.0,
|
||||
vec4(3.5, 3 + rand7, 0, 1)
|
||||
vec4(3.5, 3 + rand7, 0, 1),
|
||||
rotationMatrix(vec3(1,0,0),0)
|
||||
);
|
||||
} else if (inst_mode == SHRAPNEL) {
|
||||
attr = Attr(
|
||||
@ -118,7 +137,8 @@ void main() {
|
||||
vec3(rand4, rand5, rand6) * 40.0 + grav_vel(earth_gravity)
|
||||
),
|
||||
3.0 + rand0,
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 1)
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 1),
|
||||
rotationMatrix(vec3(1,0,0),0)
|
||||
);
|
||||
} else if (inst_mode == FIREWORK_BLUE) {
|
||||
attr = Attr(
|
||||
@ -127,7 +147,8 @@ void main() {
|
||||
vec3(rand4, rand5, rand6) * 40.0 + grav_vel(earth_gravity)
|
||||
),
|
||||
3.0 + rand0,
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 0.3)
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 0.3),
|
||||
rotationMatrix(vec3(1,0,0),0)
|
||||
);
|
||||
} else if (inst_mode == FIREWORK_GREEN) {
|
||||
attr = Attr(
|
||||
@ -136,7 +157,8 @@ void main() {
|
||||
vec3(rand4, rand5, rand6) * 40.0 + grav_vel(earth_gravity)
|
||||
),
|
||||
3.0 + rand0,
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 0.3)
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 0.3),
|
||||
rotationMatrix(vec3(1,0,0),0)
|
||||
);
|
||||
} else if (inst_mode == FIREWORK_PURPLE) {
|
||||
attr = Attr(
|
||||
@ -145,7 +167,8 @@ void main() {
|
||||
vec3(rand4, rand5, rand6) * 40.0 + grav_vel(earth_gravity)
|
||||
),
|
||||
3.0 + rand0,
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 0.3)
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 0.3),
|
||||
rotationMatrix(vec3(1,0,0),0)
|
||||
);
|
||||
} else if (inst_mode == FIREWORK_RED) {
|
||||
attr = Attr(
|
||||
@ -154,7 +177,8 @@ void main() {
|
||||
vec3(rand4, rand5, rand6) * 40.0 + grav_vel(earth_gravity)
|
||||
),
|
||||
3.0 + rand0,
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 0.3)
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 0.3),
|
||||
rotationMatrix(vec3(1,0,0),0)
|
||||
);
|
||||
} else if (inst_mode == FIREWORK_YELLOW) {
|
||||
attr = Attr(
|
||||
@ -163,7 +187,8 @@ void main() {
|
||||
vec3(rand4, rand5, rand6) * 40.0 + grav_vel(earth_gravity)
|
||||
),
|
||||
3.0 + rand0,
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 0.3)
|
||||
vec4(vec3(0.6 + rand7 * 0.4), 0.3),
|
||||
rotationMatrix(vec3(1,0,0),0)
|
||||
);
|
||||
} else if (inst_mode == LEAF) {
|
||||
attr = Attr(
|
||||
@ -172,7 +197,8 @@ void main() {
|
||||
vec3(0, 0, -2.0)
|
||||
) + vec3(sin(lifetime), sin(lifetime + 0.7), sin(lifetime * 0.5)) * 2.0,
|
||||
4,
|
||||
vec4(vec3(0.2 + rand7 * 0.2, 0.2 + (0.5 + rand6 * 0.5) * 0.6, 0), 1)
|
||||
vec4(vec3(0.2 + rand7 * 0.2, 0.2 + (0.5 + rand6 * 0.5) * 0.6, 0), 1),
|
||||
rotationMatrix(vec3(rand6, rand7, rand8), rand9 * 3 + lifetime * 5)
|
||||
);
|
||||
} else {
|
||||
attr = Attr(
|
||||
@ -181,11 +207,12 @@ void main() {
|
||||
vec3(rand2 * 0.1, rand3 * 0.1, 1.0 + rand4 * 0.5)
|
||||
),
|
||||
exp_scale(-0.2),
|
||||
vec4(1)
|
||||
vec4(1),
|
||||
rotationMatrix(vec3(1,0,0),0)
|
||||
);
|
||||
}
|
||||
|
||||
f_pos = (inst_pos - focus_off.xyz) + (v_pos * attr.scale * SCALE + attr.offs);
|
||||
f_pos = (inst_pos - focus_off.xyz) + (v_pos * attr.scale * SCALE * attr.rot + attr.offs);
|
||||
|
||||
// First 3 normals are negative, next 3 are positive
|
||||
vec3 normals[6] = vec3[](vec3(-1,0,0), vec3(1,0,0), vec3(0,-1,0), vec3(0,1,0), vec3(0,0,-1), vec3(0,0,1));
|
||||
|
Loading…
Reference in New Issue
Block a user