adds cone component
This commit is contained in:
parent
3f199ce4a6
commit
a39cf62b0b
4 changed files with 197 additions and 6 deletions
shaders
Binary file not shown.
|
@ -200,6 +200,19 @@ void main() {
|
|||
uint component_type = compounds[component_index];
|
||||
vec3 component_pos = vec3(uintBitsToFloat(compounds[component_index + 1]), uintBitsToFloat(compounds[component_index + 2]), uintBitsToFloat(compounds[component_index + 3]));
|
||||
vec3 component_rot = vec3(uintBitsToFloat(compounds[component_index + 4]), uintBitsToFloat(compounds[component_index + 5]), uintBitsToFloat(compounds[component_index + 6]));
|
||||
mat3 component_rot_mat = mat3(
|
||||
vec3(1.0, 0.0, 0.0),
|
||||
vec3(0.0, cos(component_rot.x), sin(component_rot.x)),
|
||||
vec3(0.0, -sin(component_rot.x), cos(component_rot.x))
|
||||
) * mat3(
|
||||
vec3(cos(component_rot.y), 0.0, sin(component_rot.y)),
|
||||
vec3(0.0, 1.0, 0.0),
|
||||
vec3(-sin(component_rot.y), 0.0, cos(component_rot.y))
|
||||
) * mat3(
|
||||
vec3(cos(component_rot.z), sin(component_rot.z), 0.0),
|
||||
vec3(-sin(component_rot.z), cos(component_rot.y), 0.0),
|
||||
vec3(0.0, 0.0, 1.0)
|
||||
);
|
||||
|
||||
uvec4 component_color = unpack_color(compounds[component_index + 7]);
|
||||
|
||||
|
@ -214,6 +227,27 @@ void main() {
|
|||
color = vec3(float(component_color.x) / 255.0, float(component_color.y) / 255.0, float(component_color.z) / 255.0);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (component_type == 1) {
|
||||
// handle cone
|
||||
float radius1 = uintBitsToFloat(compounds[component_index + 9]);
|
||||
float radius2 = uintBitsToFloat(compounds[component_index + 10]);
|
||||
vec3 direction = component_rot_mat * vec3(uintBitsToFloat(compounds[component_index + 11]), uintBitsToFloat(compounds[component_index + 12]), uintBitsToFloat(compounds[component_index + 13]));
|
||||
|
||||
vec3 diff = check_pos - component_pos;
|
||||
float factor = dot(direction, diff) / dot(direction, direction);
|
||||
|
||||
vec3 n = diff - factor * direction;
|
||||
float radius = radius1 * (1.0 - factor) + radius2 * factor;
|
||||
|
||||
render = length(n) <= radius && 0 <= factor && factor <= 1.0;
|
||||
if (render) {
|
||||
color = vec3(float(component_color.x) / 255.0, float(component_color.y) / 255.0, float(component_color.z) / 255.0);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,7 +258,19 @@ void main() {
|
|||
uint component_type = compounds[component_index];
|
||||
vec3 component_pos = vec3(uintBitsToFloat(compounds[component_index + 1]), uintBitsToFloat(compounds[component_index + 2]), uintBitsToFloat(compounds[component_index + 3]));
|
||||
vec3 component_rot = vec3(uintBitsToFloat(compounds[component_index + 4]), uintBitsToFloat(compounds[component_index + 5]), uintBitsToFloat(compounds[component_index + 6]));
|
||||
|
||||
mat3 component_rot_mat = mat3(
|
||||
vec3(1.0, 0.0, 0.0),
|
||||
vec3(0.0, cos(component_rot.x), sin(component_rot.x)),
|
||||
vec3(0.0, -sin(component_rot.x), cos(component_rot.x))
|
||||
) * mat3(
|
||||
vec3(cos(component_rot.y), 0.0, sin(component_rot.y)),
|
||||
vec3(0.0, 1.0, 0.0),
|
||||
vec3(-sin(component_rot.y), 0.0, cos(component_rot.y))
|
||||
) * mat3(
|
||||
vec3(cos(component_rot.z), sin(component_rot.z), 0.0),
|
||||
vec3(-sin(component_rot.z), cos(component_rot.y), 0.0),
|
||||
vec3(0.0, 0.0, 1.0)
|
||||
);
|
||||
uvec4 color = unpack_color(compounds[component_index + 7]);
|
||||
|
||||
uint transparent = compounds[component_index + 8];
|
||||
|
@ -237,6 +283,26 @@ void main() {
|
|||
if (!render) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (component_type == 1) {
|
||||
// handle cone
|
||||
float radius1 = uintBitsToFloat(compounds[component_index + 9]);
|
||||
float radius2 = uintBitsToFloat(compounds[component_index + 10]);
|
||||
vec3 direction = component_rot_mat * vec3(uintBitsToFloat(compounds[component_index + 11]), uintBitsToFloat(compounds[component_index + 12]), uintBitsToFloat(compounds[component_index + 13]));
|
||||
|
||||
vec3 diff = check_pos - component_pos;
|
||||
float factor = dot(direction, diff) / dot(direction, direction);
|
||||
|
||||
vec3 n = diff - factor * direction;
|
||||
float radius = radius1 * (1.0 - factor) + radius2 * factor;
|
||||
|
||||
render = render && !(length(n) <= radius && 0 <= factor && factor <= 1.0);
|
||||
if (!render) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue