Page 1 of 2

Curvature using hitpoint info

Posted: Wed Oct 09, 2019 8:18 am
by Egert_Kanep
Would it be possible to calculate curvature using world position and normal data?

I've been trying to make something, but couldn't get the math working :D. My idea was to use world position to calculate height difference between points with given offset.

Any ideas or is it possible at all?

Re: Curvature using hitpoint info

Posted: Wed Oct 09, 2019 8:40 am
by Dade
Egert_Kanep wrote: Wed Oct 09, 2019 8:18 am Would it be possible to calculate curvature using world position and normal data?

I've been trying to make something, but couldn't get the math working :D. My idea was to use world position to calculate height difference between points with given offset.

Any ideas or is it possible at all?
But do you mean inside LuxCore code (i.e. LuxCore has a structure named "HitPoint") or in some other context like inside Blender with a textures ?

Internally, LuxCore has this kind of information, they are the differential DnDu and DnDv: how change the normal at the change of UV texture coordinates. A new texture node could use this information.

Re: Curvature using hitpoint info

Posted: Wed Oct 09, 2019 8:47 am
by Egert_Kanep
Yes, I was thinking if it's possible to have/do it in blender with nodes. Just an exploration if this kind of thing is doable. I'm not entirely sure how it should work and my math is what it is :D. But the end goal is to have a better behaving curvature, perhaps something like arnold. Altough they seems to use some kind of raytraced solution I guess
https://docs.arnoldrenderer.com/display ... /Curvature

Another example -http://cmiss.bioeng.auckland.ac.nz/deve ... curvature/

Re: Curvature using hitpoint info

Posted: Wed Oct 09, 2019 9:40 am
by Dade
BTW, have you tried the Pointiness support ? From your links, it may be what you are looking for: https://wiki.luxcorerender.org/Shape:_Pointiness

I don't think it is possible to do anything with current texture nodes but it may be easy to add a new one that just export the "curvature" information. I will try to put something together.

P.S. all this gives me some idea on how to do "Bevel" support. My problem is I can't and don't want to tracing additional rays.

Re: Curvature using hitpoint info

Posted: Wed Oct 09, 2019 9:57 am
by Egert_Kanep
Yes, I am aware of the pointiness node, but output isn't too great. But it would be great to have more math and technical stuff available in Blender as well.

Re: Curvature using hitpoint info

Posted: Wed Oct 09, 2019 10:09 am
by Dade
Egert_Kanep wrote: Wed Oct 09, 2019 9:57 am Yes, I am aware of the pointiness node, but output isn't too great. But it would be great to have more math and technical stuff available in Blender as well.
it doesn't look right, can you post that test scene ?

Re: Curvature using hitpoint info

Posted: Wed Oct 09, 2019 11:25 am
by Egert_Kanep
Here's the monkey with pointiness attached.

Edit: noticed that file didn't upload, now its should be ok

Re: Curvature using hitpoint info

Posted: Wed Oct 09, 2019 2:52 pm
by Dade
Not sure if this is what you are looking for but I usually use a "band" node, not a "remap" node for pointiness:

point.jpg
I noticed that if the pointiness multiplier is too high, there may be artifacts starting to appear like in your rendering, going to check if there is something wrong or it is just the 32bit floating point precision.

Re: Curvature using hitpoint info

Posted: Wed Oct 09, 2019 3:39 pm
by Dade
I may have found the problem: this suzanne model has apparently a LOT of duplicate vertices.

I was checking the Cycles code for pointiness and I noticed it has some specific code for handling coincident vertices like if they were a single vertex (so the curvature is not cracked).

Re: Curvature using hitpoint info

Posted: Wed Oct 09, 2019 3:57 pm
by Dade
Dade wrote: Wed Oct 09, 2019 3:39 pm I may have found the problem: this suzanne model has apparently a LOT of duplicate vertices.
@B.Y.O.B. I receive a mesh with 6531 duplicated vertices out of 36494 but if I do a "mesh => clena up => merge vertices by distance", Blender tells me there are no duplicates. What is going on ? Is it the result of some applied modifier :?: