Skip to content
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

[pull] master from 3b1b:master #21

Merged
merged 39 commits into from
Jan 19, 2023
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7050c7e
Change type for Surface.shader_dtype
3b1b Jan 16, 2023
f15ac81
Pull out helper functions from shader_wrapper.py
3b1b Jan 16, 2023
20222bc
Update imports
3b1b Jan 16, 2023
6e6a30c
Be sure joint_angles are updated immediately before being read into a…
3b1b Jan 16, 2023
c3cd64f
Package reflectiveness, gloss and shadow into a single uniform "shading"
3b1b Jan 17, 2023
1f61395
Don't pre-rotate light source
3b1b Jan 17, 2023
8ac0aa4
Slight tweak to get_unit_normal
3b1b Jan 17, 2023
8d277af
Go back the convention of positioning stroke vertices in space before…
3b1b Jan 17, 2023
ed2dbfd
Remove unused imports
3b1b Jan 17, 2023
4de0d09
Allow cross to take an 'out' array
3b1b Jan 17, 2023
abbe131
Track full cross product and dot product of tangent vectors at joints
3b1b Jan 17, 2023
b16f098
No need to set flat stroke defaults in Polygon/Polyline
3b1b Jan 17, 2023
1b3bc7a
For linearity, check cosine of angle instead of angle
3b1b Jan 17, 2023
7fe84d9
Don't recompute cross(v01, v12)
3b1b Jan 17, 2023
870e88f
First attempt at finding uv coords from 3d space instead of 2d
3b1b Jan 17, 2023
c563ec2
Simplifications
3b1b Jan 18, 2023
c2587de
Apply xyz_to_uv to pre-positioned points
3b1b Jan 18, 2023
b7831ef
Go back to computing xyz-to-uv before repositioning
3b1b Jan 18, 2023
9ed8dd5
Clean up
3b1b Jan 18, 2023
5e1a02d
Use xyz-to-uv matrix for fill
3b1b Jan 18, 2023
c7e32e8
Delete no-longer used functions
3b1b Jan 18, 2023
0b72bc5
Fix joint normal issue
3b1b Jan 18, 2023
874906b
Replace 'light_source_position' with 'light_position'
3b1b Jan 18, 2023
1a66394
Simpler xyz-to-uv map for linear case
3b1b Jan 18, 2023
72e5bde
Rename xy-to-uv -> xyz-to-uv
3b1b Jan 18, 2023
44e5f15
Default to non-flat stroke for meshes
3b1b Jan 18, 2023
40436d6
Slightly cleaner xs_on_clean_parabola
3b1b Jan 18, 2023
96b0ec9
Use fontTools.cu2qu.cu2qu import curve_to_quadratic
3b1b Jan 18, 2023
d39fea0
A few small fixes
3b1b Jan 18, 2023
8b3aa8f
Account for edge cases on curve_to_quadratic
3b1b Jan 18, 2023
e20efda
Revert away from using curve_to_quadratic
3b1b Jan 18, 2023
13c41be
Small clean up
3b1b Jan 18, 2023
fa525b4
Increase threshold for bevel tweaking
3b1b Jan 18, 2023
b667d89
Simplify get_gl_Position
3b1b Jan 18, 2023
6c25440
Store pixel_size instead of pixel_shape
3b1b Jan 18, 2023
cd3c503
Fix get_perspective_transform to shift before rotation
3b1b Jan 18, 2023
8e2cf04
Simplify true_dot shaders
3b1b Jan 18, 2023
3820e09
Tweak to type hints
3b1b Jan 19, 2023
781e0a9
Merge pull request #1966 from 3b1b/video-work
3b1b Jan 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Small clean up
  • Loading branch information
3b1b committed Jan 18, 2023
commit 13c41be17f97539ed029f91a8b89477119de0ffe
16 changes: 9 additions & 7 deletions manimlib/shaders/quadratic_bezier_stroke/frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ out vec4 frag_color;

const float QUICK_DIST_WIDTH = 0.2;

// Distance from (x0, y0) to the curve y = x^2
float dist_to_curve(float x0, float y0){
float dist_to_curve(){
// Returns distance from uv_coords to the curve v = u^2
float x0 = uv_coords.x;
float y0 = uv_coords.y;

// In the linear case, the curve will have
// been set to equal the x axis
if(bool(is_linear)) return y0;
if(bool(is_linear)) return abs(y0);

if(uv_stroke_width < QUICK_DIST_WIDTH){
// This is a quick approximation for computing
// the distance to the curve.
// Evaluate F(x, y) = y - x^2
// divide by its gradient's magnitude
return (y0 - x0 * x0) / sqrt(1 + 4 * x0 * x0);
return abs((y0 - x0 * x0) / sqrt(1 + 4 * x0 * x0));
}
// Otherwise, solve for the minimal distance.
// The distance squared between (x0, y0) and a point (x, x^2) looks like
Expand All @@ -50,9 +53,8 @@ float dist_to_curve(float x0, float y0){
void main() {
if (uv_stroke_width == 0) discard;

// Compute sdf for the region around the curve we wish to color.
float dist = dist_to_curve(uv_coords.x, uv_coords.y);
float signed_dist = abs(dist) - 0.5 * uv_stroke_width;
// sdf for the region around the curve we wish to color.
float signed_dist = dist_to_curve() - 0.5 * uv_stroke_width;

frag_color = color;
frag_color.a *= smoothstep(0.5, -0.5, signed_dist / uv_anti_alias_width);
Expand Down