calling CVEX from VEX

   9567   10   3
User Avatar
Member
277 posts
Joined: July 2006
Offline
Hi!
I've written an CVEX shader that changes the density parameter. I want to make the pipeline like that:
1) user has got a base volume and wants to add detail to it, so he apply volume vop with this cvex.
2) User wants to render this volume , so he renders the UNchanged volume with volume shop, that uses this cvex previously setupped.

And my question is to the second point - is it possible to make vex surface shader, that will make use from a cvex compiled shader, which parameters are set in houdini?

We can assume that this question equals - is it possible to call cvex from vex code? but I want to have surface shader with input that allows me to point which cvex node I want to use.

Thank you
User Avatar
Member
31 posts
Joined: Nov. 2006
Offline
Hey brother!
Check what I did in the hip file, maybe it will be helpful,
cheers,
Piotr

Attachments:
cvexpipeline.hip (363.9 KB)

User Avatar
Member
277 posts
Joined: July 2006
Offline
Hello brother! ;]

Thank you for this example, but unfortunally it does not resolve my problem.

The tricky part in my problem is that I've got a volume on the stage (it is made by user and it's normal volume primitive). I want to use this volume as a base and add for example noise to it with CVEX, but this noise should be applied during rendering.

Of course we can simply save this ‘user volume’ to a file and write CVEX Volume shader, that will sample it from file, add noise and apply it to volume Procedural, but I want to ommit the step with saving the file. (I dont wantto force user to save files to temp directories for test renders)

I dont want to use volume vop (pointing to cvex shader), because it could need large number of divisions to achivwe good results. So I wanted to write a surface shader (f.e. smoke shader) that will call this cvex during rendering - and it will solve this problem.

I hope that now it is described more crearly than before
User Avatar
Member
31 posts
Joined: Nov. 2006
Offline
why don't you write your own VEX function and execute it in two different contexts ? you can build VOP for that, use #include statement in Outer Code. I haven't tried it but maybe it will work ?
User Avatar
Member
31 posts
Joined: Nov. 2006
Offline
ok i will test! because it's interesting!
User Avatar
Member
277 posts
Joined: July 2006
Offline
Of course I can make this function and use it in several contexts, but then I need to make a lot of small ‘ch’ scripts, that will connect surface shader and cvex shader together.

Cvex is used to drive volume vop sop and to see in the viewprot what is happening (for preview only, while rendering, we're using unchanged volume) (right now it has about 200 parameters). Surface shader has to have the same amount of parameters, that will be linked to this cvex shop. It is doable and straightfoward with python but this solution is ugly.

It will be a lot more pure and confortable to call this cvex (with all parameters set up properly) from surface shop.
User Avatar
Member
277 posts
Joined: July 2006
Offline
Is there any solution for tis problem, or should I send RFE about it?
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
CVEX is the wrong tool imho. You need to use a displacement shader to sculpt your volume and add more detail.

CVEX is not the right tool in this case because:
- you need to sample volumes on disk
- Sampling volumes on disk with CVEX are un-filtered look-ups! Great for demonstrating how extensible CVEX can be but not the right way to go about it. This is not a bug. Displacements do what you want to do. Sometimes unfiltered look-ups are what you need but not in this general case. Best to pass in volumes from Objects with the nice volume sample filtering to help you out as the micro-voxels are generated.

CVEX is good when you want to manufacture fields on-the-fly from functions, point clouds and other data. Sampling Volumes in a CVEX context that creates the same volume with a bit more detail is not very efficient.

Move your algorithms to a Displacement shader. See this OdForce link for a discussion on adding finer detail with displacements:
http://forums.odforce.net/index.php?/topic/12050-displace-volumes/ [forums.odforce.net]

The displacement shader will cause the volume to construct more micro-voxels just as what happens with a displacement shader. The Shading Quality (facing size of the micro-voxel to the camera) and the Volume Step Size (depth of micro-voxel in Camera Z-space) determine the resolution of your volume primitive. The volume primitive passed in to the displacement context is converted to micro-voxels using the nice filtering controls on the object making this the way to go.
There's at least one school like the old school!
User Avatar
Member
277 posts
Joined: July 2006
Offline
Thank you Jeff for your answer!

I found out some time ago that volumes sampled within cvex are looking different than loaded to sops.

I've got 2 little additional questions:

1) I'll check the displacement shader! But using it, I've got no preview in my viewport
(using CVEX I can use Volume Vop Sop to visualize its egffects on low-res volume version). Is there any method to do the same with displacement shaders?
(of course making cvex and displacement with almost the same code and linking all parameters is something really exhausting …)

(My CVEX functions do not only add finer detail, but are changing the apperance of volume too (for example by multiplying it by a low frequenty noise))

2) Is it possible to implement this filtering in CVEX? Is there anywhere in houdinis manual description how this filtering is done?
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
1. You can most definitely get a preview in the viewport.
Use a Volume VOP SOP using the same algorithms that you are using in the displacement shader. You have to build this in yourself using a Volume Sample From File to do the actual volume displacement but it is entirely possible.

The idea is to build your volume displacement vector then sample the volume using the P position minus the displacement_vector you calculate and feed that in to the Volume Sample From File P position input that then references a local volume with the:

opobj/my_volume_object/my_volume_sop_to_sample

which has to be a full Houdini path reference to a local SOP containing the volume you wish to displace. You can increase the resolution of the volume with the Volume Resample SOP between the volume you are displacing in SOPs to that of the SOP with the volume(s) you are referencing.

For multiple levels of displacement, you can wrap this up in a ForEach SOP to apply multiple levels of displacement in SOPs. It's up to you. The Volume * SOPs are there for you to use in any way you see fit.

—-

2. The CVEX context referenced by the Mantra Volume Procedural is quite limited and no, there is no filtering. CVEX has only one real global input: P or position of the current evaluated point in space. This point in space is defined by the bounding box you supply and the current shading quality and volume step size determining the size of the micro-voxels which is the granularity of the sampling in to the box.

Using the global input P, you query whatever you wish to construct the density value (and any other export parameter field you wish) using a mathematical function (like perlin noise), point cloud look-up, texture map uv position from P, whatever you like. It is a raw look-up which means no filtering across an area or spot size with no derivative information. You do get all of this in a displacement shader (and in H12 derivatives on volumes is so much better and this will ultimately tip your hand in favour of displacements on volumes. ).

To increase the fidelity of the volume generated in the cvex context (and for displacement of volumes as well), you have to increase the shading quality and/or the volume step size for that object. You can place volume step size on the object containing the volume in stead of it's default location on the Mantra ROP Output Driver.
There's at least one school like the old school!
User Avatar
Member
252 posts
Joined:
Offline
Apologies for reviving an old thread. I was following through volume displacements and figured posting a file by Macha from the odforums link above.
I just added the part where Jeff mentioned the possibility to preview the displacement on the viewport. Hope it helps other users stumbling by the gem of an explanation above.

Edit: trouble attaching file..
Edited by galagast - July 11, 2016 11:44:58

Attachments:
voldisp2.hiplc (333.6 KB)

  • Quick Links