Jump to content
Sign in to follow this  
hampuseh

Moving points based on displacement

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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×