boberfly / GafferCycles

Cycles for Gaffer
BSD 3-Clause "New" or "Revised" License
85 stars 10 forks source link

Subdivision/Displacement not working #44

Open kubo-von opened 4 years ago

kubo-von commented 4 years ago

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.

boberfly commented 4 years ago

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.

kubo-von commented 4 years ago

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

boberfly commented 4 years ago

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.

kubo-von commented 4 years ago

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.

boberfly commented 4 years ago

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

kubo-von commented 4 years ago

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

boberfly commented 4 years ago

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

kubo-von commented 4 years ago

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

boberfly commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

kubo-von commented 4 years ago

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 ?

boberfly commented 4 years ago

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!

kubo-von commented 4 years ago

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 :)