(Open)Subdiv and Displacement shapes

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

(Open)Subdiv and Displacement shapes

Post by Dade »

Shapes

LuxCore uses shapes to build a pipeline of mesh geometry transformations (the concept is similar to the image pipelines). The output of a shape is always a triangle mesh. Multiple shapes can be concatenated to build custom transformations. For instance, some of currently available shapes:

- mesh => load a .ply file
- pointiness => add curvature information to the alpha value of each mesh vertex
- strands => load a .hair file and tassellate the strands
- etc.

New "subdiv" Shapes

I integrated Pixar's OpenSubdiv and it is now available as a shape (i.e. a geometry transformation):

Code: Select all

scene.shapes.sphereply.type = mesh
scene.shapes.sphereply.ply = sphere.ply
##
scene.shapes.spheresubdiv.type = subdiv
scene.shapes.spheresubdiv.source = sphereply
scene.shapes.spheresubdiv.maxlevel = 5

"maxlevel" defines the max. level of surface subdivisions. Each level increases the amount of triangles by 4. At the moment only uniform subdivision is used.
This shape can be used before other shapes to improve their work: for instance before pointiness or displacement. It can also be used to fix some shadow terminator problem, for instance, without:

no-subdiv.jpg

and with:

subdiv.jpg

".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 per "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
New "displacement" Shapes

I added the support for "displacement" Shapes. It applies a texture displacement to mesh vertices:

Code: Select all

## From: https://3dtextures.me/2019/09/30/fabric-padded-004/
scene.textures.fabric_disp.type = imagemap
scene.textures.fabric_disp.file = Fabric_Padded_004_height.png
scene.textures.fabric_disp.gamma = 1.0
scene.textures.fabric_disp.mapping.type = uvmapping2d
scene.textures.fabric_disp.mapping.uvscale = 2.0 1.0
##
scene.shapes.sphereply.type = mesh
scene.shapes.sphereply.ply = sphere.ply
##
scene.shapes.spheresubdiv.type = subdiv
scene.shapes.spheresubdiv.source = sphereply
scene.shapes.spheresubdiv.maxlevel = 5
##
scene.shapes.sphere.type = displacement
scene.shapes.sphere.source = spheresubdiv
scene.shapes.sphere.map = fabric_disp
scene.shapes.sphere.scale = 0.15
scene.shapes.sphere.offset = 0.0
scene.shapes.sphere.normalsmooth = 1
The parameters are:

- "map" => the name of the displacement texture;
- "scale" => scales the displacement texture values;
- "offset" => added to the displacement texture values;
- "normalsmooth" => if to smooth the vertex normals after having applied the displacement.

Usually, you want to use a "subdiv" shape before a "displacement" shape to increase the mesh resolution.

And some test result:
check.jpg
fbm1.jpg
fbm2.jpg

From https://3dtextures.me/2019/09/30/fabric-padded-004:

fabric.jpg

Note: In LuxCore, displacement is a geometry transformation while (I think) it is a material attribute in Cycles. However LuxCore use one single material with each mesh so it is really only a formal difference.

New "displacement" Shapes: Vector Displacement

The new shape supports also vector displacement: the vertices can be displaced in an arbitrary XYZ direction instead of along normal as in usual displacement maps. This is the syntax for enabling vector displacement:

Code: Select all

scene.shapes.sphere.type = displacement
scene.shapes.sphere.source = spheresubdiv
scene.shapes.sphere.offset = 0.0
scene.shapes.sphere.normalsmooth = 1
scene.shapes.sphere.map = vect_disp
scene.shapes.sphere.map.type = vector
# Mudbox channels order:
scene.shapes.sphere.map.channels = 0 2 1
# Blender channels order:
#scene.shapes.sphere.map.channels = 2 0 1
scene.shapes.sphere.scale = 2.0
The "map.type" property is used to enable vector displacement with "vector" (the default is "height"). Note the "map.channels" property used to remap the RGB channels of the texture. This is required because, unfortunately, there isn't a standard and the channel order differs between ZBrush, Mudbox, etc.

This is a rendering of pretty much the only test scene for Blender I have found (at https://www.youtube.com/watch?v=iNAdi1nzOvE):

vect0.jpg
vect1.jpg
vect2.jpg

The result can be quite sick ! Look at this test scene from Arnold/MudBox (https://docs.arnoldrenderer.com/display ... splacement):

ear.jpg
Support LuxCoreRender project with salts and bounties
User avatar
Egert_Kanep
Posts: 237
Joined: Tue Mar 13, 2018 10:34 am

Re: (Open)Subdiv and Displacement shapes

Post by Egert_Kanep »

Yes... looks neat. But can we use procedural textures also for displacement?

Oh man, this feature adds a next level to rendering
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: (Open)Subdiv and Displacement shapes

Post by B.Y.O.B. »

:D
Egert_Kanep wrote: Sun Oct 13, 2019 12:55 pm But can we use procedural textures also for displacement?
Yes.
Dade wrote: Sun Oct 13, 2019 12:42 pm Note: In LuxCore, displacement is a geometry transformation while (I think) it is a material attribute in Cycles. However LuxCore use one single material with each mesh so it is really only a formal difference.
I think in BlendLuxCore I'll expose it as a socket on the material output node, this should be the most intuitive solution for the users.
User avatar
Egert_Kanep
Posts: 237
Joined: Tue Mar 13, 2018 10:34 am

Re: (Open)Subdiv and Displacement shapes

Post by Egert_Kanep »

Yikes, I'm too excited now. This is one of my most wanted features.
User avatar
lacilaci
Donor
Donor
Posts: 1969
Joined: Fri May 04, 2018 5:16 am

Re: (Open)Subdiv and Displacement shapes

Post by lacilaci »

So I see maxlevel for opensubdiv but is this the only control?
How/when do you reach maxlevel?
Is this screenspace adaptive as in cycles (min edgelength by #pixels and maxlevel to clamp?)

Edit: ok sorry I just noticed the part about only uniform subdivs supported yet :)
User avatar
Sharlybg
Donor
Donor
Posts: 3101
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: (Open)Subdiv and Displacement shapes

Post by Sharlybg »

Impressing !
Is this have anything to do with vector displacement ?
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: (Open)Subdiv and Displacement shapes

Post by Dade »

lacilaci wrote: Sun Oct 13, 2019 1:25 pm So I see maxlevel for opensubdiv but is this the only control?
This is the options available with OpenSubdiv: http://graphics.pixar.com/opensubdiv/do ... nd-options
None of them looks required to me at the moment (i.e. the defaults should be ok).
lacilaci wrote: Sun Oct 13, 2019 1:25 pm How/when do you reach maxlevel?
Is this screenspace adaptive as in cycles (min edgelength by #pixels and maxlevel to clamp?)
It is stuff I want to explore but the subdivision is done before applying the displacement so adaptive subdivision is not particularly useful (you need the uniform vertices to evaluate there the displacement).
In a scene like this:

Image

You need first a fine uniform subdivision or the checks would be "jagged" and only after the displacement, you could apply a simplification on (nearly) flat surfaces.

The optimal solution is to adaptively tassellate the mesh+displacement surface but it is not a simply task at all.
Support LuxCoreRender project with salts and bounties
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: (Open)Subdiv and Displacement shapes

Post by Dade »

Sharlybg wrote: Sun Oct 13, 2019 3:01 pm Is this have anything to do with vector displacement ?
I can easily add Vector displacement but I was wondering if people have the tools to create the maps :?:
They are quite hard to encode.
Support LuxCoreRender project with salts and bounties
User avatar
Egert_Kanep
Posts: 237
Joined: Tue Mar 13, 2018 10:34 am

Re: (Open)Subdiv and Displacement shapes

Post by Egert_Kanep »

I think it is not used that often. It could be a nice to have feature, but haven't heard many people using/talking about it

Edit. Also about the adaptivness, the only case I would find it useful are huge assets like terrains. For smaller objects, products, I don't see any need for adaptivness, could produce bad edges etc.
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: (Open)Subdiv and Displacement shapes

Post by Dade »

Egert_Kanep wrote: Sun Oct 13, 2019 3:15 pm I think it is not used that often. It could be a nice to have feature, but haven't heard many people using/talking about it

Edit. Also about the adaptivness, the only case I would find it useful are huge assets like terrains. For smaller objects, products, I don't see any need for adaptivness, could produce bad edges etc.
I was looking around and it seems ZBrush supports vector displacement so people importing objects from there may find it useful.
Support LuxCoreRender project with salts and bounties
Post Reply