Fix T43755: Wireframe attribute doesn't work with displace

This attribute missed derivatives calculation.

Not totally sure what's the proper approach for algebraic derivative
calculation, so calculating them by definition. This isn't fastest
way to do it in this case and could be replaced with some smarter magic
in the wireframe calculation loop.

At least currently implemented approach is better than nothing.
This commit is contained in:
Sergey Sharybin
2015-02-21 14:49:55 +05:00
parent 3445ff0f93
commit a97bc1bedf
5 changed files with 80 additions and 18 deletions

View File

@@ -18,10 +18,21 @@
#include "oslutil.h"
shader node_wireframe(
string bump_offset = "center",
int use_pixel_size = 0,
float Size = 0.01,
output float Fac = 0.0)
{
Fac = wireframe("triangles", Size, use_pixel_size);
if (bump_offset == "dx") {
point dx = Dx(P);
P -= dx;
Fac += (Fac - wireframe("triangles", Size, use_pixel_size)) / length(dx);
}
else if (bump_offset == "dy") {
point dy = Dy(P);
P -= dy;
Fac += (Fac - wireframe("triangles", Size, use_pixel_size)) / length(dy);
}
}