Jump to content

Moving points based on displacement


hampuseh

Recommended Posts

Hello and greetings!

I am currently scattering some grass on a terrain surface. 
The issue I am having is that the terrain geometry is using displacement and tesselation in the shader. The displacement values are high enough to either cover my grass or leave them floating above ground. 
I know how to move points based of a black and white texture, however that wont get me too far when the displacement is being used in a shader and the values getting altered. 
So a more detailed question is; Is it possible to export data/texture image from within a shader? The data I want would be the displacement data and later add that to my points and move them.

Link to comment
Share on other sites

I think you can solve this in various ways, one of it being scattering the points using the displacement info prior to rendering.

For that, I would scatter the points on the non-displaced surfaced (which is what you do), then with a point wrangle I would transfer the UV of the "ground" to these points as well as the normals (or using scatter node to inherit these at first, more efficient :-), and then in point vop, use a Texture VOP to move these points using the same displacement information (same texture map as the one used for your ground), along the their normals.

Then your points will be displaced prior to rendering, and when you instance grass blades on them, they will stick to your displaced "ground".

Hope I understood the problem correctly :-)

Edited by StepbyStepVFX
Link to comment
Share on other sites

Thanks for the reply!

Your method is one way to do it, however it doesn't really work when you have altered the displacement texture in the shader.  It would be better if I could export the displacement data from the shader-material itself. Otherwise the only way would be to copy all the data changes done in the shader and apply it to the texture in the pointvop, but that isn't a very nice workflow :P

Link to comment
Share on other sites

If you use point instancing, the only other way I see to move your instances at render time, prior to the geometry generation, is to use a CVEX SHOP that output a xform matrix.

To build it, you need to sample your displacement inside this CVEX shader... which lead to the previous answer : you need to recreate your displacement inside, because the disp data is created on the fly, once the shader is given a shading point.

So either your disp data is baked in the geo prior to rendering, either it is calculated on the fly at rendering (see file attached), but you need to calculate it at some point, and it implies duplicating your network, because it is part of the terrain shader, not other shader.

A third option, maybe, is to bake render your displacement, import in COPS, and use this image to sample the disp to apply on the instancing points.

dispInstancesRenderTime.hip

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...