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

simplified diffray example #398

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Changes from all commits
Commits
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
16 changes: 2 additions & 14 deletions warp/examples/optim/example_diffray.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,12 @@ def draw_kernel(
j = mesh.indices[query.face * 3 + 1]
k = mesh.indices[query.face * 3 + 2]

a = mesh.vertices[i]
b = mesh.vertices[j]
c = mesh.vertices[k]

p = wp.mesh_eval_position(mesh.id, query.face, query.u, query.v)

# barycentric coordinates
tri_area = wp.length(wp.cross(b - a, c - a))
w = wp.length(wp.cross(b - a, p - a)) / tri_area
v = wp.length(wp.cross(p - a, c - a)) / tri_area
u = 1.0 - w - v

a_n = mesh.vertex_normals[i]
b_n = mesh.vertex_normals[j]
c_n = mesh.vertex_normals[k]

# vertex normal interpolation
normal = u * a_n + v * b_n + w * c_n
normal = query.u * a_n + query.v * b_n + (1.0 - query.u - query.v) * c_n

if mode == 0 or mode == 1:
if mode == 0: # grayscale
Expand All @@ -194,7 +182,7 @@ def draw_kernel(
tex_b = mesh.tex_coords[mesh.tex_indices[query.face * 3 + 1]]
tex_c = mesh.tex_coords[mesh.tex_indices[query.face * 3 + 2]]

tex = u * tex_a + v * tex_b + w * tex_c
tex = query.u * tex_a + query.v * tex_b + (1.0 - query.u - query.v) * tex_c

color = texture_interpolation(tex, texture)

Expand Down
Loading