(Open)Subdiv and Displacement shapes

Discussion related to the Engine functionality, implementations and API.
User avatar
Dade
Developer
Developer
Posts: 3270
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: (Open)Subdiv and Displacement shapes

Post by Dade » Tue Oct 15, 2019 6:13 pm

B.Y.O.B. wrote:
Tue Oct 15, 2019 4:07 pm
By the way, what happens to the intermediate shapes after the session is started?
When doing subdivision + displacement, we have:
- original mesh (no longer needed if not instanced)
- subdivided mesh (no longer needed)
- displaced mesh (needed during render)

Maybe more, due to e.g. pointiness.
Are the meshes that are no longer needed for the render deleted automatically by LuxCore, or does the caller (e.g. the Blender addon) have to delete them with scene.RemoveUnusedMeshes()?
In general, LuxCore never remove a binding (name => texture/material/shape/object/etc.) if not explicitly instructed so, even if it is not used in the scene at the time. You have to explicitly delete the item or just always call RemoveUnused*() before to start the rendering session.

Note: As you see, displacement is done at parsing/loading time so a Displacement Shape will not be updated if you edit the texture (for instance for real-time view port rendering) during the rendering. However if you redefine the Displacement shape (without having called RemoveUnusedMeshes()/RemoveUnusedTextures()), the mesh will be updated.
You probably want to call all RemoveUnused*() for final rendering while keep the intermediate steps alive for view-port rendering so you can edit the texture and update the Displacement shape.
Support LuxCoreRender project with salts and bounties

User avatar
B.Y.O.B.
Developer
Developer
Posts: 2997
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: (Open)Subdiv and Displacement shapes

Post by B.Y.O.B. » Tue Oct 15, 2019 8:58 pm

ok, thanks for the explanation.
Support LuxCoreRender project with salts and bounties

kintuX
Posts: 474
Joined: Wed Jan 10, 2018 2:37 am

Re: (Open)Subdiv and Displacement shapes

Post by kintuX » Fri Oct 18, 2019 3:02 pm

This looks so good, hopefully i can test it over the weekend.

Q: Is or will Volume Displacement be possible?

For example - Lee Griggs's Volume Mesh

Image

User avatar
Dade
Developer
Developer
Posts: 3270
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: (Open)Subdiv and Displacement shapes

Post by Dade » Fri Oct 18, 2019 3:45 pm

kintuX wrote:
Fri Oct 18, 2019 3:02 pm
Q: Is or will Volume Displacement be possible?

For example - Lee Griggs's Volume Mesh

Image
It looks more like something for an OpenVDB file to me: viewtopic.php?f=5&t=212 (yes, it you follow the link it has been done with volumes in Arnold too).
Support LuxCoreRender project with salts and bounties

User avatar
Dade
Developer
Developer
Posts: 3270
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: (Open)Subdiv and Displacement shapes

Post by Dade » Thu Oct 24, 2019 9:47 am

I have added the support for limiting the subdivision level based on triangle screen size.

".maxedgescreensize" can be used to stop the subdivision before having reached ".maxlevel". It is expressed in size on the film image plane (i.e. a value between 0.0 and 1.0). It is trivial to translate in pixels by multiplying by "max(film width, film height). This is an example:

Code: Select all

scene.shapes.obj_redply.type = mesh
scene.shapes.obj_redply.ply = scenes/bump/mat_red.ply
scene.shapes.obj_red.type = subdiv
##
scene.shapes.obj_red.source = obj_redply
scene.shapes.obj_red.maxlevel = 5
scene.shapes.obj_red.maxedgescreensize = 0.1
See how moving the camera away reduced the amount of scene triangles (i.e. stops after 3, 2 and 1 subdivisions):

subdiv3.jpg
subdiv2.jpg
subdiv1.jpg
Support LuxCoreRender project with salts and bounties

Racleborg
Posts: 471
Joined: Sat Apr 07, 2018 10:31 am
Location: UK

Re: (Open)Subdiv and Displacement shapes

Post by Racleborg » Thu Oct 24, 2019 10:30 am

This is great! Thank you. :D

User avatar
Sharlybg
Donor
Donor
Posts: 1528
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: (Open)Subdiv and Displacement shapes

Post by Sharlybg » Thu Oct 24, 2019 11:21 am

Is it equal to Blender cycles adaptive microdisplacement features ?

Image

Image
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA

User avatar
Dade
Developer
Developer
Posts: 3270
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: (Open)Subdiv and Displacement shapes

Post by Dade » Thu Oct 24, 2019 1:07 pm

Sharlybg wrote:
Thu Oct 24, 2019 11:21 am
Is it equal to Blender cycles adaptive microdisplacement features ?
It is about subdivision. The subdivision is still uniform (to be than usable with displacement) but the level is based on triangle edges screen size.
The one you posted was available in old Lux, it was so slow to make people cry.
Support LuxCoreRender project with salts and bounties

User avatar
B.Y.O.B.
Developer
Developer
Posts: 2997
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: (Open)Subdiv and Displacement shapes

Post by B.Y.O.B. » Thu Oct 24, 2019 1:54 pm

Sharlybg wrote:
Thu Oct 24, 2019 11:21 am
Is it equal to Blender cycles adaptive microdisplacement features ?
From what I know, Cycles can adaptively tessellate each face of a mesh depending on camera distance.
Dade's example shows something similar, but it currently works per whole mesh, not per face.
So for example, with Cycles you could use one huge plane for the pebbles image you posted, and the parts of the plane that are close are tessellated more than the parts of the plane in the background. Lux currently would tessellate the whole plane uniformly.
Dade wrote:
Thu Oct 24, 2019 1:07 pm
The one you posted was available in old Lux, it was so slow to make people cry.
Cycles does not have microdisplacement like old LuxRender had (tessellation done at render time for each ray, saving tons of RAM).
What they call "microdisplacement" in Cycles is just regular adaptive tessellation and displacement, it needs lots of RAM.
Support LuxCoreRender project with salts and bounties

User avatar
Sharlybg
Donor
Donor
Posts: 1528
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: (Open)Subdiv and Displacement shapes

Post by Sharlybg » Thu Oct 24, 2019 2:42 pm

Cycles is just regular adaptive tessellation and displacement
This is what i was asking. thanks for the explanation.
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA

Post Reply