GafferCycles icon indicating copy to clipboard operation
GafferCycles copied to clipboard

Subdivision/Displacement not working

Open kubo-von opened this issue 5 years ago • 14 comments

Hey @boberfly, I could not get displacement and subdivision to work. Maybe I'm doing something wrong? I didn't find any more settings than these: Screenshot from 2020-01-29 12-31-25

Screenshot from 2020-01-29 12-31-59

Scene here: https://drive.google.com/drive/folders/1YLcuK4VM7Xc_9AobgGI0lbRMbBy2eg4m?usp=sharing

EDIT: Adding meshType node set to Subdivision Surface seems to do something, even though the cycles attributes have no effect and still no Displacement happening.

kubo-von avatar Jan 29 '20 11:01 kubo-von

Somewhat duplicate of this: https://github.com/boberfly/GafferCycles/issues/36

Blender devs decided to do uniform subdiv from Blender so there's no way of doing it outside of adaptive, need to write that one myself. As for displacement you are doing the right thing from what I see.

boberfly avatar Jan 29 '20 18:01 boberfly

I've been looking at #36, but that means adaptive should be working? Some subdivision is happening but changing the dicing rate and max subd don't change anything

kubo-von avatar Jan 29 '20 18:01 kubo-von

Cycles might not support changing those settings while it is in IPR mode. Also make sure experimental is set in CyclesOptions. I'll take a look soon.

boberfly avatar Jan 29 '20 19:01 boberfly

Ah alright! subdivision works, my apologies! Yeah I had to restart IPR render every time. also I was't putting meaningful values into dicing scale, either to small to see the change or to big that the mesh never generated (seems the subdivision process is single-threaded ? )

No luck with Displacement though.

kubo-von avatar Jan 29 '20 21:01 kubo-von

Yeah I noticed it was single-threaded too, is Blender? Might just need opensubdiv to be compiled with TBB/OpenMP.

boberfly avatar Jan 30 '20 01:01 boberfly

Yeah seems to be the same in Blender, I've just tried it.

kubo-von avatar Jan 30 '20 15:01 kubo-von

Fixed displacement in this commit: https://github.com/boberfly/GafferCycles/commit/464e1390ca1c3eb3f1ed9390be54a3b6eb3300d8

Turns out all the settings of the output node wasn't being set to the right node (I somewhat merged the "outputNode" with the actual "shader node" to simplify things, but in the converter forgetting to set the values to the proper respective nodes under the hood).

boberfly avatar Jan 31 '20 08:01 boberfly

Awesome! Yeah, merging those two makes sense, less nodes to put down.

kubo-von avatar Jan 31 '20 19:01 kubo-von

One thing which is a big ooof, in interactive rendering when swapping shaders around, it is making Cycles really unstable or it's applying the displacement in an additive way each edit, so it's not fully solved yet. Need to study what Blender is doing to prevent that...

boberfly avatar Jan 31 '20 19:01 boberfly

Just an update it is partially working: https://github.com/boberfly/GafferCycles/commit/c7630621dbea23ce12b92963723fc7fdf9116f9a

But John on the forums has given me a better idea, return false on attribute assignment which can't be applied and the renderer interface will send down a new geo, which is exactly what I need to re-generate displacement, especially for adaptive/subdivided geo where my workaround doesn't work.

boberfly avatar Feb 03 '20 18:02 boberfly

Fixed, seems to work well and also fixes issues with shader hashing. https://github.com/boberfly/GafferCycles/commit/2554ca813dbf6e3fd26d9cbe95b3fdc4ddcd72a1

boberfly avatar Feb 04 '20 07:02 boberfly

Can confirm it works great in 0.16.0 ! Subdiv still needs render restart when changing the tessellation settings, but so does in Blender.. Do you want me to close these once working in current release ?

kubo-von avatar Feb 05 '20 10:02 kubo-von

Hmm I wonder if it's a Cycles limitation. Could you try changing the subdiv settings and then after, do a very small change to displacement and see if the subdiv changes to what it should be? That'll tell me straight away if it's just a hashing issue or that Cycles is not running tessellate during interactive rendering.

Cheers!

boberfly avatar Feb 05 '20 20:02 boberfly

I've did what you suggested and after many tries I've failed to find a consistent behavior :/ Sometimes it does update sometimes it doesn't, sometimes it takes a while. I will have more time to play with gaffer and cycles in following weeks so I will do more tests and get back to you if I find any clues.

To be honest I'm not a big fan of Cycles's adaptive tessellation, it's very unpredictable. I have my fingers crossed for #36 :)

kubo-von avatar Feb 06 '20 11:02 kubo-von