Community
Arnold for Houdini Forum
Rendering with Arnold in Houdini and Solaris using the HtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Implicit Surface - OSL Geo Shader

11 REPLIES 11
Reply
Message 1 of 12
spinor.momentum
657 Views, 11 Replies

Implicit Surface - OSL Geo Shader

Hi there, does somebody know how to use the field shader channel in the implicit surface geo? Is it possible to create an implicit geo from an osl shader similar to the vectron workflow in octane? It should be working somehow but there is no documentation to be found how to use it. I would be really grateful if somebody could help me there. Thanks!

Tags (1)
Labels (1)
  • OSL
11 REPLIES 11
Message 2 of 12
madsd
in reply to: spinor.momentum

Im not a htoA person.

But Arnold renders OSL SDF implicit cases perfect.
I have done a million ( I havent, but have done a lot )
You need to exit the shader on a conformed Position, like an external funtion that defines the SDF shape and route the P in the main body through that function.

I can show some examples of known working OSL SDF constructs arnold can render as implicit surfaces if you want.
But on same time not entirely sure if that is needed, and if your issue is related to houdini exclusively.

Message 3 of 12
spinor.momentum
in reply to: madsd

Thank you very much for the swift answer. 🙂

Yes this would be exactly what I need! If you would show me an example I would be very grateful. What I want to try first is to realize the mandelbrot example that is listed in the arnold docs but with a sdf instead of a fog volume. It would be awesome if you have an example for that, but a hint how to do OSL SDF would be great as well. Just to know how to start because there is no Information on the web on how to proceed. It is not necessary that the example is houdini specific. I might be able to conform it to houdini.

Message 4 of 12
madsd
in reply to: spinor.momentum

OSL Mandlebrot SDF traced against the Arnold Sky dome.

5241-qwe.jpg


You would want to get a contact between this node and the implicit construct in houdini.
Now, I am not aware if such a thing already exsists or wether you need to fabricate a reciver node that translates the shader into an arnold implicit structure at render time.
Here is the actual Mandlebrot and a correctly formated output.

You see we source P to the map, we setup some rules for P so P conforms to the expression we parse P through ( the mandlebrot )

It could be anything in

vector map ( vector p )
{
// insert your favorite shape here
// boxes, chamfered boxes
// spheres, or spheres with lots of holes
// you can also smoothstep to get nice perfect morphing curvature surface ( that are animated and new topology needed for every frame ) that will never flicker or return flipped normals.....bonus
}

 void ry( output vector p, float a){  
     float c,s;
     vector q=p;  
      c = cos(a); s = sin(a);  
      p[0] = c * q[0] + s * q[2];  
      p[2] = -s * q[0] + c * q[2]; 
 }  

vector map(output vector p) {
    p = vector(p[0],p[2],p[1]);
    vector z = p;
    vector dz=vector(0.0);
    float power = 8.0;
    float r, theta, phi;
    float dr = 1.0;
    
    float t0 = 1.0;
    for(int i = 0; i < 7; ++i) {
        r = length(z);
        if(r > 2.0) continue;
        theta = atan(z[1] / z[0]);
        #ifdef phase_shift_on
        phi = asin(z[2] / r) + Time*0.1;
        #else
        phi = asin(z[2] / r);
        #endif
        
        dr = pow(r, power - 1.0) * dr * power + 1.0;
    
        r = pow(r, power);
        theta = theta * power;
        phi = phi * power;
        
        z = r * vector(cos(theta)*cos(phi), sin(theta)*cos(phi), sin(phi)) + p;
        
        t0 = min(t0, r);
    }
    return vector(0.5 * log(r) * r / dr, t0, 0.0);
}
   shader implicit(output vector field = 0) {
         field  = map(P);
      }      


Message 5 of 12
madsd
in reply to: madsd

And here is some pseudo code how we access and execute the SDF.
It may help if you need to fabricate a destination node Arnold can handle.

https://paste.ofcode.org/QAw3hcWTd7PUCjY4T3qeSY

Message 6 of 12

Thank you very much! Unfortunately I did not get it to work yet. Here is a screenshot of the implicit surface tab set to custom: 5228-implicit-1.jpg

or field shader:

5229-2.jpg

If I plug in a standard volume shader with a displaced field ( like the OSL volume fractal ) nothing happens. This is how the shader network looks with a fog volume fractal: 5230-mandel-julia.png

In houdini shader network there are only these options for OUT_Material node. Did somebody who uses houdini with arnold got it actually to work? In the arnold answers post history there are 2 instances there they asked the same question, but they never got an answer... Thank you very much thought I really appreciated your effort.*Are you using 3ds max? Maya?

Message 7 of 12
madsd
in reply to: spinor.momentum

using MAX.
I can see your last image is a volume where you wrap the fractal to the volume shape, you would need to do the same and send out implicit surface instead of volume.

I can wire a shader to a map slot on anything that has a map slot in max, not just shaders. So you need to link the actual osl code nodes output directly to a map slot, I would say and the map slot should be linked up into Arnolds "implicit" construct, so you need to initialize it.

Message 8 of 12
madsd
in reply to: madsd

Like a sort of scriping language, where you can write houdini UI.
Then make a map slot, one you can drag a map or assign a map to.
Like a checker map could be assigned to all kinds of constucts in houdini I imagine, peoples size black means 1 meter tall person white means 2 meter tall person.
You need to construct and initialize Arnold so Arnold knows we are dealing with an implicit construct, derived from this OSL map.

Message 9 of 12
madsd
in reply to: madsd

Try:


kick.exe -nodes

It will print a list of installed arnold nodes.
And you need to initialize the highlighted implicit node.


5243-ee.png

Message 10 of 12
spinor.momentum
in reply to: madsd

Thank you very much, unfortunately, I am not sure how to reference the implicit surface because the out_material node has no way to add additional parameters.. Does anybody with deep coding skills an idea how to add the functionality to the out context?

Message 11 of 12
madsd
in reply to: spinor.momentum

5247-qwe.png


I had another look at your case.
Exported a known working OSL SDF construct to .ass
This is what the implicit construct in there returns.


implicit
{
 name /Arnold_Implicit001
 matrix
 1 0 0 0
 0 1 0 0
 0 0 1 0
 1020.7002 -0.308002472 0.579124928 1
 shader "/Material__266503"
 opaque on
 id 1485494943
 field "/Map__147"
 threshold 0
 samples 1
 solver "levelset"
 min -3.91188407 -2.97024989 0
 max 3.91188407 2.97024989 5
 step_size 3.4000001
 declare nodeRenderID constant INT
 nodeRenderID 65535
 declare gBufID constant INT
 gBufID 0
 declare nodeHandle constant INT
 nodeHandle 2
 declare wireColor constant RGB
 wireColor 0.603921592 0.603921592 0.898039222
 declare nodeName constant STRING
 nodeName "Arnold_Implicit001"
}

Also attached the procedural, you should be able to load it in houdini and see an implicit cage somewhere around scene center and to the side.

If you can, we just confirmed you can load and render implicit OSL structures.

So your mission is to conform to this.

---

So line 1
- Initialize "implicit"

line 9, in the implicit construct you attach the
- shader "/material__266503"

and more importantly line 12
- field "/map__147"



Message 12 of 12
spinor.momentum
in reply to: madsd

Thank you very much! Yes the ass file is working fine. So it should be working somehow, but I still have no idea how to conform to the field shader channel. Frustratingly there is not a single example found on the internet of somebody using it. And most of the time when I load a costum shader houdini instantly crashes... Anybody here is using it? Your file reveals that you have the privilege to use the beta 🙂 Is there also a beta for houdini 18? Maybe they have been improving the API for Implicit Surfaces. I am patiently waiting for the hydra delegate anyway or a working version for 18.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report