(Open)Subdiv and Displacement shapes
Posted: Sun Oct 13, 2019 12:42 pm
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):
"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:
and with:
".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:
New "displacement" Shapes
I added the support for "displacement" Shapes. It applies a texture displacement to mesh vertices:
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:
From https://3dtextures.me/2019/09/30/fabric-padded-004:
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:
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):
The result can be quite sick ! Look at this test scene from Arnold/MudBox (https://docs.arnoldrenderer.com/display ... splacement):
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
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:
and with:
".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
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
- "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:
From https://3dtextures.me/2019/09/30/fabric-padded-004:
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
This is a rendering of pretty much the only test scene for Blender I have found (at https://www.youtube.com/watch?v=iNAdi1nzOvE):
The result can be quite sick ! Look at this test scene from Arnold/MudBox (https://docs.arnoldrenderer.com/display ... splacement):