Jump to content

Displacement with UV offset


Recommended Posts

Hi, there.

I`m trying to create displacement shader with uvs offset, so when displacement is applied, the uvs are preserved and did not change in space.

What I did so far is to construct prototype using vop sop and it works fine:

WEK7Fl.jpg

So I converted it to the shader, but the result is not the same. As you can see there is a small error between displacement and uv offset:

ibAzOl.jpg

And The shader itself

The problem is that distortion is not consistent - there is a regions with large displacement, but very small or no errors, and also places with small displacement and large distortions.

I really have no idea what is the problem here, so I hope anyone can help.

Thanks.

disp_uv_test2.hipnc

Edited by rayman
Link to comment
Share on other sites

  • 1 month later...

Excuse me Pavel,

I'm glad that you could figure it out that quickly, but would you mind sharing how you did it?

I am very interested on learning what you did. I have used the rest position in other occasions but couldn't figure out how to fix these one.

Also could you clarify me some (probably basic) questions.

I was checking out your VOPs prototype and I couldn't figure out why you have to use a multiplier parameter (I saw in your shader that you use a value of -0.1)

An also why do you flip the y and z values when applying the displace to the UV?

Thanks in advance! :D

Link to comment
Share on other sites

Well, multiplier and reversed y and z values depends entirely on corelation between uv space and object space.

So If 1 uv unit is equal to 10 global units, you have to multiply them to match exactly. Also in this scene I wanted to displace on x and z directions, thats why u is connected to x and v to z.

For the shader I ended with completley different solution. At first this approach was not bad, but in simulation global space displace is not a good idea (you have to displace each piece in its own space). So I created 3(2 are also ok) vectors per each point and stored them during simulation. Then in shader it was easy to construct matrix for each point and displace them in every direction I want. Maybe this is not the best solution but in my case it was good enough.

The tricky part was to guess which parameter(point or vector) is in what space. Some of them are in shader/camera space, others in global, so you have to create convertions to be sure everything works ok.

I can share some example scenes if you want to :)

Edited by rayman
Link to comment
Share on other sites

Hi Pavel!

Thanks a LOT for that explanation,

I really appreciate it. I guess I have to re-study more in depth all the space concepts and transformations between them if I want to someday be able to write shaders successfully. :D

So in the approach you finally used you are kind of defining a different space for each point to be displaced in? Is it right?

But doing that wouldn't you require to have a high-poly count to really get a lot of details? (just like your VOP approach) Am I wrong?

I think I kind of get the idea, I'm gonna see if I can figure it out but if its not too much of a problem I would love to see an example whenever you have time.

Thanks again

Link to comment
Share on other sites

Thats right. I have one transformation matrix per each point, so when objects are driven by simulation/dop displacement stays in right space. Think of it as matrix per simulated piece, where each point of that piece has the same matrix.

I know that dops have this kind of data per piece, but I`m not expierenced enough to use it.

Hi-poly model is not required, because renderman renderers have this step called dicing, where geometry is subdivided into polys with size smaller than 1 pixel.

Creating displacement in shader means that attributes are transfered from points to micropolys, and shader is executed per micorpoly, so you have this extra hi-poly detail for free.

Edited by rayman
  • Like 1
Link to comment
Share on other sites

Hey Pavel!

thanks a lot for that last explanation,

I haven't been able to try implementing the matrix per point approach cause I got caught in another project and this was for a personal project so no time now, but just wanted to pass by and thank you for your kind help :D

When I have a bit of time I'll be trying it again.

Thanks!

Link to comment
Share on other sites

  • 4 years later...
  • 5 months later...

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...