New plugin: Phong tessellation and displacement

Philemo_CarraraPhilemo_Carrara Posts: 1,175
edited October 2018 in Carrara Discussion

I would like to thank @Magaremoto for the starting point of this idea. He suggested to look into Renderman to pick good ideas.

I discovered that Renderman subdivides meshes so that each facet fits in a Pixel. The first idea I had reading this was that would be great for displacement.

That done, I needed a subdivision (or tessellation) method that respected the existing render and was fast enough. Carrara using Phong shading, I decided to use Phong tessellation. This algorithm, created by Tamy Boubekeur and Marc Alexa (see https://perso.telecom-paristech.fr/boubek/papers/PhongTessellation/). This method is widely used in games to give nice contours to low poly models. As the author says, “Our technique is a geometric version of Phong normal interpolation, not applied on normals but on the vertex positions. We call this strategy Phong Tessellation. “.

Carrara and displacement

Carrara usually does a fine job to simulate displacement with bump mapping when the surface is facing the camera and the light. This is not so good when the camera and/or the light are grazing the surface. Also, contours do not reflect the impression given by facing facets.

Carrara has displacement. It works great on geometric primitives (like sphere, plane,..). For meshes, it's a little more … touchy. Displacing the vertices at the facet size is usually not enough. So, there is subdivision. The problem here is that the complete mesh is subdivided, regardless of it actually on the screen and visible from the camera. Heavy subdivision usually takes a lot of time.

Micro-dispalcement

The idea of this Plug-in is to subdivide heavily (up to 4 vertices per pixel), but only what is necessary. So, off-screen facets or facing away from the camera are not subdivided. Contours are perfect due to subdivision and micro displacement is now possible.

Micro displacement is using displacement in place of bump mapping. It allows to have consistency in quality between facing and grazing angles, both from the Camera and the lights, as it uses real geometry and is not trying to simulate it.

As Carrara is already very good at simulating displacement by bump mapping, for realistic values of displacement, the improvement is very subtle and should be considered before using.

For instance, for a grazing angle (upper jaw), the first image is rendered using bump mapping and the second one using micro displacement. There are differences, although you may have to look for them and I think the overall quality is better.

   

On this example on a facing fragment, (the forehead), the difference is not obvious at all:


 

On this example, micro displacement slows the render by a factor of 2.5 (120 seconds instead of 40). I can deduce this simple rule: No grazing angle, no micro displacement :-)

Macro Displacement

Macro displacement is used to simulate geometry at run time. It usually has both displacement (or height) map and bump/normal map.

This is where the plugin takes its full power:

 

Usage

Plugin

Phong tessellation is a modifier that applies to meshes.

Select the modifier from the list:



 

There are 3 parameters in this plugin:

  •  Enabled: Activate the plugin. Otherwise do nothing. Use it to re-generate the tessellation is camera, object or displacement has changed.

  • Shape factor: Strength of the Phong effect. 0 will give you flat shading, 0,5 is normal, 1 is overdone (stuffed fabric effect).

  • Vertex per half pixel: number of vertices generated by half screen pixel horizontally and vertically. 1 is 4 vertices per pixel, 2 is 1 per pixel, 4 is 2 per square of 2x2 pixels and so on. Use value 1 for micro displacement or macro displacement with sharp contrast, 2 or less is the displacement map is blurred. Starting from value 1, each successive value divides the number of vertices generated by value squared (2 is 4 times less, 3 is 9 times, 4 16 times and so on).

Displacement

 To set displacement, use the standard displacement shader in the shader room.

Before doing so, untick if necessary the “enabled” value in the modifier (otherwise it may take a very long time).

First make sure the “enable displacement” is disabled.

Then set amplitude and offset and displacement shader as usual.

Performances

On my 5 years old laptop, tessellation generates about 1 million facets per second. Displacement is about 3 times faster.

Afterwards, Carrara needs at least as much time to digest all those facets.

Rendering is usually 2,5 times slower at maximum precision.

Download

Windows version is available at Sourceforge.

I'll publish the OSX version this week.

CloseNodisp.png
98 x 179 - 24K
CloseWithDisp.png
97 x 188 - 27K
ForeHead noDisp.png
194 x 96 - 37K
ForeHead withDisp.png
194 x 96 - 37K
Macro.jpg
1280 x 960 - 117K
ModifierList.png
153 x 399 - 30K
Modifier.png
241 x 267 - 8K
Disabled.png
174 x 117 - 8K
displacementShader.png
750 x 285 - 34K
Post edited by Philemo_Carrara on
«134

Comments

  • Philemo, how is your micro displacement different from Eric's Anything Grooves?

    This plugin is definiteley dedicated to render. Vertices and facets are created according to their view in the rendered image (up to 4 vertices per pixel). Facets that are offscreen, behind the camera, facing away from the camera are not tessallated. So it creates an awful lot of vertices, but just enough to have maximum rendering quality.

  • WendyLuvsCatzWendyLuvsCatz Posts: 38,220

    heartlooking forward to trying this when I can, great job yes

  • magaremotomagaremoto Posts: 1,227
    edited October 2018

    looks great Philip, as usual (hey, wheres the Donate button? wink)

    thanks for all your efforts to keep carrara alive

    ps a bridge to RM would be one of the best well-paid plugins ever -endless possibilities with that blush- but I guess very demanding too

    Post edited by magaremoto on
  • It's on my todo list. Exporting meshes, cameras and lights seems easy enough, the devil is in the shaders (and I'm afraid users would want that ;-)).
  • UnifiedBrainUnifiedBrain Posts: 3,588
    Philemo said:

    Philemo, how is your micro displacement different from Eric's Anything Grooves?

    This plugin is definiteley dedicated to render. Vertices and facets are created according to their view in the rendered image (up to 4 vertices per pixel). Facets that are offscreen, behind the camera, facing away from the camera are not tessallated. So it creates an awful lot of vertices, but just enough to have maximum rendering quality.

    Thanks!  Even when I don't fully understand what you say, I really appreciate your efforts.  I guess that it will take experimenting with it to see how Macro Displacement is different from regular displacement, beyond saving resources.

  • magaremotomagaremoto Posts: 1,227
    Philemo said:
    It's on my todo list. Exporting meshes, cameras and lights seems easy enough, the devil is in the shaders (and I'm afraid users would want that ;-)).

    maybe it could be useful make an OSL hypershade node or environment functions to run OSL shaders within carrara

  • Philemo said:

    Philemo, how is your micro displacement different from Eric's Anything Grooves?

    This plugin is definiteley dedicated to render. Vertices and facets are created according to their view in the rendered image (up to 4 vertices per pixel). Facets that are offscreen, behind the camera, facing away from the camera are not tessallated. So it creates an awful lot of vertices, but just enough to have maximum rendering quality.

    Thanks!  Even when I don't fully understand what you say, I really appreciate your efforts.  I guess that it will take experimenting with it to see how Macro Displacement is different from regular displacement, beyond saving resources.

    It should not be different. But, if you subdivide enough to have that kind of precision, regular displacement will take a long time and may even clog Carrara. 

  • MistaraMistara Posts: 38,675

    does this mean i could use M4's displacement maps in carrara and it will lift skin to be seen in silhouette ?? heartheartheartheart

    https://www.daz3d.com/m4-displacement-maps

  • WendyLuvsCatzWendyLuvsCatz Posts: 38,220
    Mistara said:

    does this mean i could use M4's displacement maps in carrara and it will lift skin to be seen in silhouette ?? heartheartheartheart

    https://www.daz3d.com/m4-displacement-maps

     

    I would imagine so yes

  • HeadwaxHeadwax Posts: 9,987

    thank you thank you thank you thank you once again Philemo for your kindness and intelligence

  • MistaraMistara Posts: 38,675
    th3Digit said:
    Mistara said:

    does this mean i could use M4's displacement maps in carrara and it will lift skin to be seen in silhouette ?? heartheartheartheart

    https://www.daz3d.com/m4-displacement-maps

     

    I would imagine so yes

    wheee skreeches  for joy

  • MistaraMistara Posts: 38,675
    head wax said:

    thank you thank you thank you thank you once again Philemo for your kindness and intelligence

    ++++++++1

  • StezzaStezza Posts: 8,064

    fee fi fo phong!

     

    thankyou Philemo ++++++++++++++++++++++2

  • CelluloCellulo Posts: 60

    Thanks Philemo for this cool new plugin.

  • DiomedeDiomede Posts: 15,169

    Thank you, Philemo.  Looks amazing. Can't wait to try it ot.   Your efforts are appreciated.  You are a treasure.

  • Philemo_CarraraPhilemo_Carrara Posts: 1,175
    edited October 2018
    Mistara said:

    does this mean i could use M4's displacement maps in carrara and it will lift skin to be seen in silhouette ?? heartheartheartheart

    https://www.daz3d.com/m4-displacement-maps

    I don't have this product, but I'm 99% sure of it.

    As an example, I've built up a vein displacement map. Below is a quick render of M4 at 3 levels of zoom.

    There is a visible seam visible in my displacement map on the left arm, sorry for that.

    @UnifiedBrain That's an illustration of my previous answer. You can zoom in or out, the plugin adapt the displacement to the current view.

    Doc19.jpg
    960 x 1280 - 41K
    Doc20.jpg
    960 x 1280 - 60K
    Doc21.jpg
    960 x 1280 - 86K
    Post edited by Philemo_Carrara on
  • @th3Digit @head wax @Stezza @Cellulo @Diomede

    Thank you for your Thank you wink

  • Philemo said:
    It's on my todo list. Exporting meshes, cameras and lights seems easy enough, the devil is in the shaders (and I'm afraid users would want that ;-)).

    maybe it could be useful make an OSL hypershade node or environment functions to run OSL shaders within carrara

    It would wink. It would allow side by side comparison when translating shaders. It would also be a nice addition to Carrara.

    I wonder if I would have to build a new renderer or if I could get by with a new top level shader.

    I'm also terrified with the OSX version. Not sure my feeble knowledge of OSX would allow me to compile that frown

  • magaremotomagaremoto Posts: 1,227
    edited October 2018
    Philemo said:
    Philemo said:
    It's on my todo list. Exporting meshes, cameras and lights seems easy enough, the devil is in the shaders (and I'm afraid users would want that ;-)).

    maybe it could be useful make an OSL hypershade node or environment functions to run OSL shaders within carrara

    It would wink. It would allow side by side comparison when translating shaders. It would also be a nice addition to Carrara.

    I wonder if I would have to build a new renderer or if I could get by with a new top level shader.

    I'm also terrified with the OSX version. Not sure my feeble knowledge of OSX would allow me to compile that frown

    what a beautiful days you must have coming soon, truly envious of you yes

    Post edited by magaremoto on
  • WendyLuvsCatzWendyLuvsCatz Posts: 38,220
    edited October 2018

    Carrara native and Octane

    M4 on the right has the phong modifier

     

    native000.png
    1920 x 1080 - 454K
    phong0000.jpg
    1920 x 1080 - 142K
    Post edited by WendyLuvsCatz on
  • WendyLuvsCatzWendyLuvsCatz Posts: 38,220
    edited October 2018

    it indeed has some displacement without but the second guy more ripped heart

    one needs to add a displacement of value 1-100  set to 50 (or grey colour) to all the other surfaces Phong or no phong

    his nipples a bit wrinkly though 

    adding more angles as my animation renders for Misty heart

    underwear a problem, had to enlarge and does not fit well

    I wonder if VWD would see the displacement in 3D view or more to the point cope with it!

    phong0125.jpg
    1920 x 1080 - 146K
    phong0210.jpg
    1920 x 1080 - 162K
    Post edited by WendyLuvsCatz on
  • WendyLuvsCatzWendyLuvsCatz Posts: 38,220

    a video

  • StezzaStezza Posts: 8,064

    everybody was phong phu phighting..... laugh

  • MistaraMistara Posts: 38,675

    is a dream come troooooheartheartheartheartheart  OMG HAZ TO RERENDER EVERYTHING  LOL

    VEIN MAaaaaPS precioussesss

  • MistaraMistara Posts: 38,675
    th3Digit said:

    a video

    TYoooheart

  • MistaraMistara Posts: 38,675
    Philemo said:
    Mistara said:

    does this mean i could use M4's displacement maps in carrara and it will lift skin to be seen in silhouette ?? heartheartheartheart

    https://www.daz3d.com/m4-displacement-maps

    I don't have this product, but I'm 99% sure of it.

    As an example, I've built up a vein displacement map. Below is a quick render of M4 at 3 levels of zoom.

    There is a visible seam visible in my displacement map on the left arm, sorry for that.

    @UnifiedBrain That's an illustration of my previous answer. You can zoom in or out, the plugin adapt the displacement to the current view.

     

    TYoooheartheartheart

  • HeadwaxHeadwax Posts: 9,987

    oh wow what terrific examples !

     

  • GreymomGreymom Posts: 1,113

    WOW - many thanks for this!  Awesome!

     

  • WendyLuvsCatzWendyLuvsCatz Posts: 38,220

    clicky click vid

  • HeadwaxHeadwax Posts: 9,987

    nice :)

Sign In or Register to comment.