Blender 2.8 - 4.5 Support
This commit is contained in:
@ -169,58 +169,57 @@ def write(vert, particle_info=None, shadowmap=False):
|
||||
vert.write('float s = sin(p_angle);')
|
||||
vert.write('vec3 center = spos.xyz - p_location;')
|
||||
|
||||
match rotation_mode:
|
||||
case 'OB_X':
|
||||
vert.write('vec3 rz = vec3(center.y, -center.x, center.z);')
|
||||
vert.write('vec2 rotation = vec2(rz.y * c - rz.z * s, rz.y * s + rz.z * c);')
|
||||
vert.write('spos.xyz = vec3(rz.x, rotation.x, rotation.y) + p_location;')
|
||||
if rotation_mode == 'OB_X':
|
||||
vert.write('vec3 rz = vec3(center.y, -center.x, center.z);')
|
||||
vert.write('vec2 rotation = vec2(rz.y * c - rz.z * s, rz.y * s + rz.z * c);')
|
||||
vert.write('spos.xyz = vec3(rz.x, rotation.x, rotation.y) + p_location;')
|
||||
|
||||
if (not shadowmap):
|
||||
vert.write('wnormal = vec3(wnormal.y, -wnormal.x, wnormal.z);')
|
||||
vert.write('vec2 n_rot = vec2(wnormal.y * c - wnormal.z * s, wnormal.y * s + wnormal.z * c);')
|
||||
vert.write('wnormal = normalize(vec3(wnormal.x, n_rot.x, n_rot.y));')
|
||||
case 'OB_Y':
|
||||
vert.write('vec2 rotation = vec2(center.x * c + center.z * s, -center.x * s + center.z * c);')
|
||||
vert.write('spos.xyz = vec3(rotation.x, center.y, rotation.y) + p_location;')
|
||||
if (not shadowmap):
|
||||
vert.write('wnormal = vec3(wnormal.y, -wnormal.x, wnormal.z);')
|
||||
vert.write('vec2 n_rot = vec2(wnormal.y * c - wnormal.z * s, wnormal.y * s + wnormal.z * c);')
|
||||
vert.write('wnormal = normalize(vec3(wnormal.x, n_rot.x, n_rot.y));')
|
||||
elif rotation_mode == 'OB_Y':
|
||||
vert.write('vec2 rotation = vec2(center.x * c + center.z * s, -center.x * s + center.z * c);')
|
||||
vert.write('spos.xyz = vec3(rotation.x, center.y, rotation.y) + p_location;')
|
||||
|
||||
if (not shadowmap):
|
||||
vert.write('wnormal = normalize(vec3(wnormal.x * c + wnormal.z * s, wnormal.y, -wnormal.x * s + wnormal.z * c));')
|
||||
case 'OB_Z':
|
||||
vert.write('vec3 rz = vec3(center.y, -center.x, center.z);')
|
||||
vert.write('vec3 ry = vec3(-rz.z, rz.y, rz.x);')
|
||||
vert.write('vec2 rotation = vec2(ry.x * c - ry.y * s, ry.x * s + ry.y * c);')
|
||||
vert.write('spos.xyz = vec3(rotation.x, rotation.y, ry.z) + p_location;')
|
||||
if (not shadowmap):
|
||||
vert.write('wnormal = normalize(vec3(wnormal.x * c + wnormal.z * s, wnormal.y, -wnormal.x * s + wnormal.z * c));')
|
||||
elif rotation_mode == 'OB_Z':
|
||||
vert.write('vec3 rz = vec3(center.y, -center.x, center.z);')
|
||||
vert.write('vec3 ry = vec3(-rz.z, rz.y, rz.x);')
|
||||
vert.write('vec2 rotation = vec2(ry.x * c - ry.y * s, ry.x * s + ry.y * c);')
|
||||
vert.write('spos.xyz = vec3(rotation.x, rotation.y, ry.z) + p_location;')
|
||||
|
||||
if (not shadowmap):
|
||||
vert.write('wnormal = vec3(wnormal.y, -wnormal.x, wnormal.z);')
|
||||
vert.write('wnormal = vec3(-wnormal.z, wnormal.y, wnormal.x);')
|
||||
vert.write('vec2 n_rot = vec2(wnormal.x * c - wnormal.y * s, wnormal.x * s + wnormal.y * c);')
|
||||
vert.write('wnormal = normalize(vec3(n_rot.x, n_rot.y, wnormal.z));')
|
||||
case 'VEL':
|
||||
vert.write('vec3 forward = -normalize(p_velocity);')
|
||||
vert.write('if (length(forward) > 1e-5) {')
|
||||
vert.write('vec3 world_up = vec3(0.0, 0.0, 1.0);')
|
||||
if (not shadowmap):
|
||||
vert.write('wnormal = vec3(wnormal.y, -wnormal.x, wnormal.z);')
|
||||
vert.write('wnormal = vec3(-wnormal.z, wnormal.y, wnormal.x);')
|
||||
vert.write('vec2 n_rot = vec2(wnormal.x * c - wnormal.y * s, wnormal.x * s + wnormal.y * c);')
|
||||
vert.write('wnormal = normalize(vec3(n_rot.x, n_rot.y, wnormal.z));')
|
||||
elif rotation_mode == 'VEL':
|
||||
vert.write('vec3 forward = -normalize(p_velocity);')
|
||||
vert.write('if (length(forward) > 1e-5) {')
|
||||
vert.write('vec3 world_up = vec3(0.0, 0.0, 1.0);')
|
||||
|
||||
vert.write('if (abs(dot(forward, world_up)) > 0.999) {')
|
||||
vert.write('world_up = vec3(-1.0, 0.0, 0.0);')
|
||||
vert.write('}')
|
||||
vert.write('if (abs(dot(forward, world_up)) > 0.999) {')
|
||||
vert.write('world_up = vec3(-1.0, 0.0, 0.0);')
|
||||
vert.write('}')
|
||||
|
||||
vert.write('vec3 right = cross(world_up, forward);')
|
||||
vert.write('if (length(right) < 1e-5) {')
|
||||
vert.write('forward = -forward;')
|
||||
vert.write('right = cross(world_up, forward);')
|
||||
vert.write('}')
|
||||
vert.write('right = normalize(right);')
|
||||
vert.write('vec3 up = normalize(cross(forward, right));')
|
||||
vert.write('vec3 right = cross(world_up, forward);')
|
||||
vert.write('if (length(right) < 1e-5) {')
|
||||
vert.write('forward = -forward;')
|
||||
vert.write('right = cross(world_up, forward);')
|
||||
vert.write('}')
|
||||
vert.write('right = normalize(right);')
|
||||
vert.write('vec3 up = normalize(cross(forward, right));')
|
||||
|
||||
vert.write('mat3 rot = mat3(right, -forward, up);')
|
||||
vert.write('mat3 phase = mat3(vec3(c, 0.0, -s), vec3(0.0, 1.0, 0.0), vec3(s, 0.0, c));')
|
||||
vert.write('mat3 final_rot = rot * phase;')
|
||||
vert.write('spos.xyz = final_rot * center + p_location;')
|
||||
vert.write('mat3 rot = mat3(right, -forward, up);')
|
||||
vert.write('mat3 phase = mat3(vec3(c, 0.0, -s), vec3(0.0, 1.0, 0.0), vec3(s, 0.0, c));')
|
||||
vert.write('mat3 final_rot = rot * phase;')
|
||||
vert.write('spos.xyz = final_rot * center + p_location;')
|
||||
|
||||
if (not shadowmap):
|
||||
vert.write('wnormal = normalize(final_rot * wnormal);')
|
||||
vert.write('}')
|
||||
if (not shadowmap):
|
||||
vert.write('wnormal = normalize(final_rot * wnormal);')
|
||||
vert.write('}')
|
||||
|
||||
if rotation_factor_random != 0:
|
||||
str_rotate_around = '''vec3 rotate_around(vec3 v, vec3 angle) {
|
||||
|
Reference in New Issue
Block a user