Hi,
I tried cutout by object and mask by object, but its not what I am after.
I want to subtract sphere from HF. How do we do it in Terrain universe?
Thanks!
How do I Boolean Heightfield with Geo/Sdf ?
3486 6 2- tas3d
- Member
- 120 posts
- Joined: Jan. 2012
- Offline
- Librarian
- Member
- 142 posts
- Joined: Aug. 2009
- Offline
#include <volume.vfl> vector pos; vector uvw; intersect(1,@P,{0,1000,0},pos,uvw); @height = -pos.y;
#include <volume.vfl> vector pos = 0; vector2 uv ; float avg ; for(int i = 0 ;i< 25;i++){ uv = rand(i+0.2); sampledisk(pos.x,pos.y,uv.x,uv.y); pos *= vector(200); avg += (volumesample(0,0,@P+pos)-@height)/10; } @height += avg; @height += 20 *anoise(0.01*@P,2,0.5,0.5); float v_turb(vector sample_point; float roughness; float lacunarity; int octaves { float sum = 0; float weight = 1.0; vector samp_p = sample_point; for (int i=0;i<octaves +1;i++){ sum += (noise(samp_p)-{0.5,0.5,0.5})*weight; samp_p *= lacunarity; weight *= roughness; } return sum; } @height += 100*v_turb(@P*set(0.02,0,0.01),0.2,3,4); float mask = length (@P); mask = fit(mask,0,500,0,1); mask = chramp("rap",mask); @height*= mask;
- tas3d
- Member
- 120 posts
- Joined: Jan. 2012
- Offline
Thanks for the idea!
This worked for me
This worked for me
vector pos; vector uvw; int hit; hit = intersect(1,@P,{0,1000,0},pos,uvw); if (hit != -1) { if (@height > pos.y) { @height = pos.y; } } hit = intersect(1,@P,{0,-1000,0},pos,uvw); if (hit != -1) { if (@height > pos.y) { @height = pos.y; } }
Michal Tas Maciejewski @ www.vfxtricks.com
- Konstantin Magnus
- Member
- 686 posts
- Joined: Sept. 2013
- Online
There is a node for that: Height field project (set to Minimum method with "Hit farthest" disabled).
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
- radumitroi95
- Member
- 7 posts
- Joined: Dec. 2021
- Offline
Konstantin Magnus
There is a node for that: Height field project (set to Minimum method with "Hit farthest" disabled).
Thanks, that's exactly what I needed. I was trying that, I just didn't know I need to disable the "Hit Farthest" for it to work the way I want it.
I was looking around above and I was thinking "do I really need to run all that code to be able to do something so simple?"
- tas3d
- Member
- 120 posts
- Joined: Jan. 2012
- Offline
haha I had exactly the same feeling when I wrote this code. It just felt wrong.
Michal Tas Maciejewski @ www.vfxtricks.com
- Konstantin Magnus
- Member
- 686 posts
- Joined: Sept. 2013
- Online
radumitroi95Well yeah, it seems to be using the intersect()-function under the hood. That's why the terms used may be a bit uncommon.
I was trying that, I just didn't know I need to disable the "Hit Farthest" for it to work the way I want it.
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
-
- Quick Links