GPUShader: Remove unused envelope shaders.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
|
||||
uniform mat4 ViewMatrixInverse;
|
||||
uniform mat4 ViewProjectionMatrix;
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
|
||||
/* ---- Instanciated Attribs ---- */
|
||||
in vec4 pos; /* w encodes head (== 0.0f), tail (== 1.0f). */
|
||||
@@ -28,7 +26,7 @@ float sdf_bone(vec3 p, Bone b)
|
||||
h = clamp(h, 0.0, 1.0);
|
||||
return length(pa - b.vec * h) - (b.r1 + b.rdif * h);
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
/* Raytracing against cone need a parametric definition of the cone
|
||||
|
||||
@@ -181,8 +181,6 @@ data_to_c_simple(shaders/gpu_shader_instance_camera_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_instance_distance_line_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_instance_edges_variying_color_geom.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_instance_edges_variying_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_instance_bone_envelope_solid_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_instance_bone_envelope_wire_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_instance_mball_handles_vert.glsl SRC)
|
||||
|
||||
data_to_c_simple(shaders/gpu_shader_3D_groundline_geom.glsl SRC)
|
||||
|
||||
@@ -185,9 +185,6 @@ typedef enum GPUBuiltinShader {
|
||||
GPU_SHADER_2D_NODELINK,
|
||||
GPU_SHADER_2D_NODELINK_INST,
|
||||
|
||||
GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID,
|
||||
GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE,
|
||||
|
||||
GPU_SHADER_3D_INSTANCE_MBALL_HANDLES,
|
||||
|
||||
GPU_NUM_BUILTIN_SHADERS /* (not an actual shader) */
|
||||
|
||||
@@ -111,8 +111,6 @@ extern char datatoc_gpu_shader_instance_camera_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_instance_distance_line_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_instance_edges_variying_color_geom_glsl[];
|
||||
extern char datatoc_gpu_shader_instance_edges_variying_color_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_instance_bone_envelope_solid_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_instance_bone_envelope_wire_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_instance_mball_handles_vert_glsl[];
|
||||
|
||||
extern char datatoc_gpu_shader_3D_groundpoint_vert_glsl[];
|
||||
@@ -822,11 +820,6 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
|
||||
[GPU_SHADER_2D_NODELINK_INST] = { datatoc_gpu_shader_2D_nodelink_vert_glsl,
|
||||
datatoc_gpu_shader_2D_nodelink_frag_glsl },
|
||||
|
||||
[GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID] = { datatoc_gpu_shader_instance_bone_envelope_solid_vert_glsl,
|
||||
datatoc_gpu_shader_simple_lighting_frag_glsl },
|
||||
[GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE] = { datatoc_gpu_shader_instance_bone_envelope_wire_vert_glsl,
|
||||
datatoc_gpu_shader_flat_color_frag_glsl },
|
||||
|
||||
[GPU_SHADER_3D_INSTANCE_MBALL_HANDLES] = { datatoc_gpu_shader_instance_mball_handles_vert_glsl,
|
||||
datatoc_gpu_shader_flat_color_frag_glsl },
|
||||
};
|
||||
@@ -862,7 +855,6 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
|
||||
defines = "#define AXIS_NAME\n";
|
||||
break;
|
||||
case GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR:
|
||||
case GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID:
|
||||
defines = "#define USE_INSTANCE_COLOR\n";
|
||||
break;
|
||||
case GPU_SHADER_3D_FLAT_COLOR_U32:
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
|
||||
|
||||
/* This shader essentially operates in Object space, where it aligns given geometry with bone, scales it accordingly
|
||||
* to given radii, and then does usual basic solid operations.
|
||||
* Note that if one of head/tail radius is negative, it assumes it only works on the other end of the bone
|
||||
* (used to draw head/tail spheres). */
|
||||
|
||||
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ViewProjectionMatrix;
|
||||
|
||||
|
||||
/* ---- Instanciated Attribs ---- */
|
||||
in vec4 pos; /* w encodes head (== 0.0f), tail (== 1.0f) or in-between. */
|
||||
|
||||
/* ---- Per instance Attribs ---- */
|
||||
in mat4 InstanceModelMatrix;
|
||||
in vec4 color;
|
||||
|
||||
in float radius_head;
|
||||
in float radius_tail;
|
||||
|
||||
|
||||
out vec3 normal;
|
||||
flat out vec4 finalColor;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
/* We get head/tail in object space. */
|
||||
vec4 head = InstanceModelMatrix * vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
vec4 tail = InstanceModelMatrix * vec4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
|
||||
/* We need rotation from bone mat, but not scaling. */
|
||||
mat3 bone_mat = mat3(InstanceModelMatrix);
|
||||
bone_mat[0] = normalize(bone_mat[0]);
|
||||
bone_mat[1] = normalize(bone_mat[1]);
|
||||
bone_mat[2] = normalize(bone_mat[2]);
|
||||
|
||||
mat3 nor_mat = transpose(inverse(mat3(ViewMatrix) * bone_mat));
|
||||
|
||||
/* Where does this comes from???? Don't know why, but is mandatory anyway... :/ */
|
||||
const float size = 2.0f;
|
||||
|
||||
head.xyz *= size;
|
||||
tail.xyz *= size;
|
||||
|
||||
bool head_only = (radius_tail < 0.0f);
|
||||
bool tail_only = (radius_head < 0.0f);
|
||||
/* == 0: head; == 1: tail; in-between: along bone. */
|
||||
float head_fac = head_only ? 0.0f : (tail_only ? 1.0f : pos.w);
|
||||
|
||||
vec4 ob_pos;
|
||||
vec4 ob_bone_origin;
|
||||
float radius;
|
||||
|
||||
/* head */
|
||||
if (head_fac <= 0.0f) {
|
||||
if (!head_only) {
|
||||
/* We are drawing the body itself, need to adjust start/end positions and radius! */
|
||||
vec3 bone_vec = tail.xyz - head.xyz;
|
||||
float len = length(bone_vec);
|
||||
|
||||
if (len > (radius_head + radius_tail)) {
|
||||
float fac = (len - radius_head) / len;
|
||||
radius = fac * radius_head + (1.0f - fac) * radius_tail;
|
||||
bone_vec /= len;
|
||||
ob_bone_origin = vec4(head.xyz + bone_vec * radius_head * size, 1.0f);
|
||||
}
|
||||
else {
|
||||
radius = (radius_head + radius_tail) / 2.0f;
|
||||
ob_bone_origin = (head + tail) / 2.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
radius = radius_head;
|
||||
ob_bone_origin = head;
|
||||
}
|
||||
}
|
||||
/* tail */
|
||||
else if (head_fac >= 1.0f) {
|
||||
if (!tail_only) {
|
||||
/* We are drawing the body itself, need to adjust start/end positions and radius! */
|
||||
vec3 bone_vec = tail.xyz - head.xyz;
|
||||
float len = length(bone_vec);
|
||||
|
||||
if (len > (radius_head + radius_tail)) {
|
||||
float fac = (len - radius_tail) / len;
|
||||
radius = fac * radius_tail + (1.0f - fac) * radius_head;
|
||||
bone_vec /= len;
|
||||
ob_bone_origin = vec4(tail.xyz - bone_vec * radius_tail * size, 1.0f);
|
||||
}
|
||||
else {
|
||||
radius = (radius_head + radius_tail) / 2.0f;
|
||||
ob_bone_origin = (head + tail) / 2.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
radius = radius_tail;
|
||||
ob_bone_origin = tail;
|
||||
}
|
||||
}
|
||||
/* Body of the bone */
|
||||
#if 0 /* Note: not used currently! */
|
||||
else {
|
||||
float tail_fac = 1.0f - head_fac;
|
||||
radius = radius_head * head_fac + radius_tail * tail_fac;
|
||||
ob_bone_origin = head * head_fac + tail * tail_fac;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Yep, since input pos is unit sphere coordinates, it's also our normal. */
|
||||
vec3 nor = pos.xyz;
|
||||
ob_pos = pos * radius * size;
|
||||
ob_pos.xyz = bone_mat * ob_pos.xyz;
|
||||
ob_pos.w = 1.0f;
|
||||
|
||||
gl_Position = ViewProjectionMatrix * (ob_pos + ob_bone_origin);
|
||||
normal = normalize(nor_mat * nor);
|
||||
finalColor = color;
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
|
||||
|
||||
/* This shader takes a 2D shape, puts it in 3D Object space such that is stays aligned with view and bone,
|
||||
* and scales head/tail/distance according to per-instance attributes
|
||||
* (and 'role' of current vertex, encoded in zw input, head or tail, and inner or outer for distance outline).
|
||||
* It is used for both the distance outline drawing, and the wire version of envelope bone.
|
||||
* Note that if one of head/tail radius is negative, it assumes it only works on the other end of the bone
|
||||
* (used to draw head/tail spheres). */
|
||||
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
|
||||
/* ---- Instanciated Attribs ---- */
|
||||
in vec4 pos; /* z encodes head (== 0.0f), tail (== 1.0f) or in-between; w encodes inner (0.0f) or outer border. */
|
||||
|
||||
/* ---- Per instance Attribs ---- */
|
||||
in mat4 InstanceModelMatrix;
|
||||
in vec4 color;
|
||||
|
||||
in float radius_head;
|
||||
in float radius_tail;
|
||||
in float distance;
|
||||
|
||||
|
||||
flat out vec4 finalColor;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
/* We get head/tail in object space. */
|
||||
mat4 bone_mat = InstanceModelMatrix;
|
||||
vec4 head = bone_mat * vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
vec4 tail = bone_mat * vec4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
|
||||
/* We generate our XY axes in object space, Y axis being aligned with bone in view space. */
|
||||
mat4 obview_mat = ViewMatrix;
|
||||
mat4 iobview_mat = inverse(obview_mat);
|
||||
|
||||
vec4 view_bone_vec = obview_mat * normalize(tail - head);
|
||||
view_bone_vec.z = 0.0f;
|
||||
if (length(view_bone_vec.xy) <= 1e-5f) {
|
||||
/* A bit weak, but will do the job for now.
|
||||
* Ideally we could compute head/tail radius in view space, and take larger one... */
|
||||
if (view_bone_vec.x > view_bone_vec.y) {
|
||||
view_bone_vec.x = 1e-5f;
|
||||
}
|
||||
else {
|
||||
view_bone_vec.y = 1e-5f;
|
||||
}
|
||||
}
|
||||
vec3 bone_axis_y = normalize((iobview_mat * view_bone_vec).xyz);
|
||||
vec3 bone_axis_x = normalize(cross(bone_axis_y, iobview_mat[2].xyz));
|
||||
|
||||
/* Where does this comes from???? Don't know why, but is mandatory anyway... :/ */
|
||||
float size = 2.0f;
|
||||
|
||||
head.xyz *= size;
|
||||
tail.xyz *= size;
|
||||
|
||||
bool head_only = (radius_tail < 0.0f);
|
||||
bool tail_only = (radius_head < 0.0f);
|
||||
/* == 0: head; == 1: tail; in-between: along bone. */
|
||||
float head_fac = head_only ? 0.0f : (tail_only ? 1.0f : pos.z);
|
||||
bool do_distance_offset = (pos.w != 0.0f) && (distance >= 0.0f);
|
||||
|
||||
vec2 xy_pos = pos.xy;
|
||||
vec4 ob_pos;
|
||||
|
||||
vec4 ob_bone_origin;
|
||||
float radius;
|
||||
|
||||
/* head */
|
||||
if (head_fac <= 0.0f) {
|
||||
radius = radius_head;
|
||||
ob_bone_origin = head;
|
||||
}
|
||||
/* tail */
|
||||
else if (head_fac >= 1.0f) {
|
||||
radius = radius_tail;
|
||||
ob_bone_origin = tail;
|
||||
}
|
||||
/* Body of the bone */
|
||||
#if 0 /* Note: not used currently! */
|
||||
else {
|
||||
float tail_fac = 1.0f - head_fac;
|
||||
radius = radius_head * head_fac + radius_tail * tail_fac;
|
||||
ob_bone_origin = head * head_fac + tail * tail_fac;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (do_distance_offset) {
|
||||
radius += distance;
|
||||
}
|
||||
|
||||
xy_pos = xy_pos * radius * size;
|
||||
|
||||
ob_pos = ob_bone_origin + vec4(bone_axis_x * xy_pos.x + bone_axis_y * xy_pos.y, 1.0f);
|
||||
gl_Position = ProjectionMatrix * obview_mat * ob_pos;
|
||||
finalColor = color;
|
||||
}
|
||||
Reference in New Issue
Block a user