-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REQUEST: view cage in real time when changing extrusion #60
Comments
EZ Baker implements real-time cage preview by making a linked copy of a low-poly object.
Another method is to draw object outline (shadow-ghost shader) with blender's GPU and OpenGL graphics modules. Resource for drawing tips (but not a solution). |
…me cage preview explanation and notes are at the #60 issue thread
OverviewCommit 9abe635 introduces a core cage shader already close to the initial idea. As pointed out in #60 (comment) (previous comment above), the cost of creating a low-poly copy (even linked, not considering modifiers) is higher than the cost of drawing a GLSL shader right into the 3D viewport, which is what 9abe635 is about. Added The shader structure and working logic (apart from what could be read at this page) are the following:
in vec3 position; // input vertex position (x, y, z)
uniform mat4 viewProjectionMatrix;
uniform float extrusion;
uniform vec4 color;
out vec4 color;
void main() {
float x2 = position[0] * position[0];
float y2 = position[1] * position[1];
float z2 = position[2] * position[2];
float k = extrusion * pow((x2 + y2 + z2), -0.5f) + 1;
// The gl_Position in the viewport is calculated using the mat4 viewProjectionMatrix
// and the vertex position multiplied by k - scale factor determined using
// vertex coordinates and extrusion value.
gl_Position = viewProjectionMatrix * vec4(position * k, 1.0f);
// fragment_source receives fcolor
// (constant uniform, the whole cage shader uses one color)
fcolor = color;
} Examples:
The next steps:
|
A halfway solution to solving 1st bullet point in the next steps above could be something like this (took it from this forum post, which is to move the vertex alongside its normal: vec4 v = vec4(gl_Vertex.xyz + gl_Normal * moveamount, 1);
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * v; The edit to suit our needs ( gl_Position = viewProjectionMatrix * vec4(position + normal * extrusion, 1.0f); |
The k multiplier was not calculated correctly (the vertex coordinates were just scaled but not moved outwards from the mesh)
fixing cage shader not considering object transforms (e.g. location, rotation, scale, parenting transforms)
I will reference this useful post on stackexchange about getting object data (like vertices) with modifiers and shape keys taken into account (evaluated object data). |
Integration todo:
|
take max ray distance into account as well
added cancel() method to the Shader_Cage class to call draw_cancel() on OT cancel event
… value That is probably it for the cage preview)
This feature request is:
Describe what you'd like to be implemented
@BusterCharlie wrote on Discord (rephrased):
Additional context
EZ Baker probably has that viz impl (update: EZ Baker's cage preview is dogwater).
The text was updated successfully, but these errors were encountered: