Monday, December 21, 2015

Maya converting nCloth to polly mesh workflow

Excuse my language but this took me fucking ages to figure out.

Create a Cloth.
run the sim.
cache the sim.
then under nCache menu choose "Transfer cache to input mesh"

that sets the Ncloth input mesh to the deformed ncloth shape.

then all you need to do is nCloth > remove nCloth

and that automaticaly turns your ncloth into a polly mesh.

if you need to check that the input mesh has been updated you can view it prior to removing your nCloth sim by choosing  nCloth > display input mesh

phew..

Monday, July 28, 2014

free scrips NUKE

http://www.davidemeny.com/nuke.php

Python script to create a NUKE Camera from V-Ray EXR Images

I took this from http://pastebin.com/4vmAmARU, it didnt work for me so i fiddles with the code and got it working.

## INSTALL ##

##add into menu.py

# added by JGH Vray EXR Camera

import createExrCamVray
nuke.menu("Nodes").addMenu("3D").addCommand("Create Camera from Vray EXR", "createExrCamVray.createExrCamVray(nuke.selectedNode())")

m = menubar.addMenu("&VRay")
m.addCommand("Create Camera from EXR", "createExrCamVray.createExrCamVray(nuke.selectedNode())")

toolbar = nuke.toolbar("Nodes")
toolbar.addCommand("Create Camera from EXR", "createExrCamVray.createExrCamVray(nuke.selectedNode())", icon="/Users/YourUsername/.nuke/exr2cam.png")



## CODE ###

# save in ~/.nuke folder

import math
import nuke

def createExrCamVray( node ):
    '''
    Create a camera node based on VRay metadata.
    This works specifically on VRay data coming from maya.
    '''
   
    #Big thanks to Ivan Busquets who helped me put this together!
    #(ok, ok, he really helped me a lot)
    #Also thanks to Nathan Dunsworth for giving me solid ideas and some code to get me started.
   
    ### TODO : add progress bar (even though it's really not needed here) that works
   
    mDat = node.metadata()
    reqFields = ['exr/camera%s' % i for i in ('FocalLength', 'Aperture', 'Transform')]
    if not set( reqFields ).issubset( mDat ):
        print 'no metdata for camera found'
        return
   
    first = node.firstFrame()
    last = node.lastFrame()
    ret = nuke.getFramesAndViews( 'Create Camera from Metadata', '%s-%s' %( first, last )  )
    fRange = nuke.FrameRange( ret[0] )
   
    cam = nuke.createNode( 'Camera2' )
    cam['useMatrix'].setValue( False )
   
    for k in ( 'focal', 'haperture', 'translate', 'rotate'):
        cam[k].setAnimated()
   
    #task = nuke.ProgressTask( 'Baking camera from meta data in %s' % node.name() )
   
    for curTask, frame in enumerate( fRange ):
        #if task.isCancelled():
            #nuke.executeInMainThread( nuke.message, args=( "Phew!" ) )
            #break;
        #task.setMessage( 'processing frame %s' % frame )
       
   
        # IB. If you get both focal and aperture as they are in the metadata, there's no guarantee
        # your Nuke camera will have the same FOV as the one that rendered the scene (because the render could have been fit to horizontal, to vertical, etc)
        # Nuke always fits to the horizontal aperture. If you set the horizontal aperture as it is in the metadata,
        # then you should use the FOV in the metadata to figure out the correct focal length for Nuke's camera
        # Or, you could keep the focal as is in the metadata, and change the horizontal_aperture instead.
        # I'll go with the former here. Set the haperture knob as per the metadata, and derive the focal length from the FOV

        val = node.metadata( 'exr/cameraAperture', frame) # get horizontal aperture
        fov = node.metadata( 'exr/cameraFov', frame) # get camera FOV
   
        focal = val / (2 * math.tan(math.radians(fov)/2.0)) # convert the fov and aperture into focal length

        cam['focal'].setValueAt(float(focal),frame)
        cam['haperture'].setValueAt(float(val),frame)

        matrixCamera = node.metadata( 'exr/cameraTransform', frame) # get camera transform data

        #Create a matrix to shove the original data into
        matrixCreated = nuke.math.Matrix4()
       
        for k,v in enumerate(matrixCamera):
            matrixCreated[k] = v
       
        matrixCreated.rotateX(math.radians(-90)) # this is needed for VRay.  It's a counter clockwise rotation
        translate = matrixCreated.transform(nuke.math.Vector3(0,0,0))  # Get a vector that represents the camera translation  
        rotate = matrixCreated.rotationsZXY() # give us xyz rotations from cam matrix (must be converted to degrees)

        cam['translate'].setValueAt(float(translate.x),frame,0)
        cam['translate'].setValueAt(float(translate.y),frame,1)
        cam['translate'].setValueAt(float(translate.z),frame,2)
        cam['rotate'].setValueAt(float(math.degrees(rotate[0])),frame,0)
        cam['rotate'].setValueAt(float(math.degrees(rotate[1])),frame,1)
        cam['rotate'].setValueAt(float(math.degrees(rotate[2])),frame,2)

        # task.setProgress( int( float(curTask) / fRange.frames() *100) )

Thursday, July 24, 2014

Houdini 13 to Maya 2015 pipeline

I would say using the Houdini Engine would be a great approach but i can't  get it to work at the moment, keeps crashing Maya.

http://www.sidefx.com/index.php?option=com_content&task=view&id=2738&Itemid=381

so

Alembic is the way to go. from the file menu, export an Alembic .abc file from Houdini and import into Maya, easy peasy.

http://www.sidefx.com/docs/houdini13.0/io/alembic

V-Ray Render Optimization


V-Ray Render Optimization

An in-depth tutorial on optimizing V-Ray to deliver the
highest quality renders with the fastest render times.


v1.2

- February 2014

Render scene courtesy of Chaos Group

Intro

This tutorial attempts to cover and clarify the process of optimizing your V-Ray render settings to get the best possible render quality and fastest render time for a given scene.

There's often a lot of confusion surrounding the topic of V-Ray's sampling and what 'ideal' settings are. Many times you'll see artists adopt the 'Universal V-Ray Settings' of having the Image Sampler (Anti-Aliasing, or AA) Max Subdivs value set very high (like 50 or 100), and then simply lowering the noise threshold value until the render becomes clean enough - thinking that it's the best / fastest that V-Ray can do. But with a bit of understanding of how V-Ray works under the hood, you can achieve a higher quality result WITH faster render times - in some extreme cases ranging between 3x faster to 13x faster than the universal settings.

We'll first cover some of the underlying concepts behind how rendering and V-Ray's sampling works. Then we'll go over an example scene to demonstrate exactly how a render can be optimized to be faster and cleaner. Then we'll learn how to identify the different sources of noise a scene can have. And finally I'll provide a step-by-step procedure to optimize any scene to render with an ideal balance of quality and speed.

If you already know the underlying concepts and just want the technical step-by-step procedure, click here to skip right to it.

Raytracing 101

When a render begins, rays are first sent out from our camera into the scene to gather information about the geometry that will be visible in the final image. These rays originating from the camera are called Primary Rays (sometimes also called Camera Rays or Eye Rays) and are controlled by V-Ray's Image Sampler (Also known as Anti-Aliasing or AA).

Whenever a Primary Ray intersects with geometry in the scene, additional rays get sent out from that point of intersection into the rest of the scene to gather information about things like Lighting, Shadows, Global Illumination (GI), Reflection, Refraction, Sub-surface Scattering (SSS), etc. These additional rays are called Secondary Rays and are controlled by V-Ray's DMC Sampler.

Figure 01
A simplified diagram of raytracing:
Primary Rays are sent out from the camera into the scene, intersect with geometry, and send out various Secondary Rays to sample the scene.
From this point forward, we'll simply refer to 'Rays' as 'Samples' - because that's what the purpose of a Ray is - to take a Sample of a scene to gather information about what's going on in it. Rays = Samples.

In order to accurately figure out what's going on in a scene, many Primary and Secondary Samples are needed to be taken. The more a scene gets sampled, the more information V-Ray is able to gather about the scene, and the higher quality the render will be - which means less Noise in the render. You see, Noise is caused by a lack of information. Noise present in a render means that V-Ray wasn't able to gather enough information about what's going on in a scene. So in order to reduce noise, you need to provide V-Ray with more information - and to provide V-Ray with more information, you need to take more samples.

The amount of Primary Samples sent out into the scene is mainly controlled by the Min Subdivs, Max Subdivs, and Color Threshold settings of the Image Sampler. The amount of Secondary Samples sent out into the scene is mainly controlled by the Subdivs settings from individual Lights / Global Illumination / Materials in the scene, and the Noise Threshold setting of the DMC Sampler. (Noise Threshold is named Adaptive Threshold in V-Ray for Maya)

So to recap the important terms:

Ray = Sample
Primary Samples = The samples controlled by V-Ray's Image Sampler (also known as Anti-Aliasing or AA), which is specialized in figuring out a scene's geometry - as well as textures, depth of field, and motion blur.
Secondary Samples = The samples controlled by V-Ray's DMC Sampler, which is specialized in figuring out a scene's Lighting, Global Illumination (GI), Shadows, Material Reflection & Refraction, and Sub-Surface Scattering (SSS).
Noise = A lack of information.
Subdivs = The square root of the actual number of Samples. So Subdivs2 = Samples.
For example: 8 Subdivs = 64 Samples. (82 = 64)

In this tutorial we'll learn how to best utilize these Primary and Secondary Samples to get the highest quality render (lowest amounts of Noise) in the fastest amount of time.

Understanding The SampleRate Render Element

The SampleRate render element is one of the most important tools we'll be using to help us optimize our renders. It's V-Ray way of showing us exactly what the Image Sampler (AA) is doing at any given pixel. It does this by assigning a certain color for each pixel in the render according to how many Primary Samples (AA) are being taken at that pixel (which can be seen by viewing the SampleRate render element).

  • A Blue-ish color means a low amount of the available Primary Samples (AA) was taken at the pixel.
  • A Green-ish color means a medium amount of the available Primary Samples (AA) was taken at the pixel.
  • A Red-ish color means a high amount of the available Primary Samples (AA) was taken at the pixel.

Figure 02
The SampleRate render element (right), showing how many of the available Primary Samples are being taken at any pixel of the render (left).
So for a scene with the Image Sampler (AA) set to 1min and 10max Subdivs (meaning 1min and 100max Primary Samples):
  • A Blue pixel means that 1 Primary Sample was taken
  • A Green pixel means that 50 Primary Samples were taken
  • A Red pixel means that 100 Primary Samples were taken.

And for a scene with the Image Sampler (AA) set to 1min and 100max Subdivs (meaning 1min and 10000max Primary Samples):
  • A Blue pixel means that 1 Primary Sample was taken
  • A Green pixel means that 5000 Primary Samples were taken
  • A Red pixel means that 10000 Primary Samples were taken.

Example Scene - Understanding How V-Ray Works

For this tutorial, we'll be working with a simple test scene consisting of: A plane with a few spheres on top, various simple materials (including diffuse, glossy reflection, glossy refraction, and SSS), 2 areas lights, and a domelight with an HDRI. Global Illumination is enabled and set to Brute Force + Light Cache. This scene file can be downloaded HERE.

We'll begin with a baseline render with the following render settings:

  • Image Sampler (AA) set to 1min & 8max Subdivs.
  • Lights, GI, and Materials all set to the default of 8 Subdivs.
  • Noise Threshold set to the default of 0.01.
  • All other render settings are left at their defaults.

Figure 03
Baseline Render
1min & 8max Subdivs = Image Sampler (AA)
8 Subdivs = Lights, GI, and Materials each.
Now lets go over exactly what's happening in this baseline render. Through the render settings, you're telling V-Ray:
"I'm allowing you to use up to 64 (8 Subdivs) Primary Samples (AA) per pixel to figure out what's going on in this scene and reduce the noise as close as you can to my specified noise threshold... BUT for each of those Primary Samples you take, you're only allowed to take 1 additional Secondary Sample to figure out what's going on for each Light, GI, and Material."
At this point you may be asking:
"Wait, only 1 Secondary Sample for the Lights, GI, and Materials each? Shouldn't it be 64 Samples (8 Subdivs) as we've set them?"
Well it's important to note that even though the Lights, GI, and Materials are set to 64 Samples (8 Subdivs) each - V-Ray internally divides this value by the AA Max Samples value of your scene. So instead of the 64 Samples for the light and material each as you might expect, this gets divided by the AA Max of 64 Samples (8 Subdivs), which results in only 1 Secondary Sample being taken for the Lights, GI, and Materials each. (64 Secondary Samples / 64 Primary Samples = 1 Secondary Sample).

The reason V-Ray does this is because it's internal formulas are set up in a way that attempts to automatically balance it's two samplers. The thinking behind this is that with more Primary Samples being taken of your scene, a proportionally smaller amount of Secondary Samples are needed to figure out exactly what's happening in the scene (which we'll soon learn, this isn't always desirable). This balancing of the Image Sampler and the DMC Sampler can be a bit confusing at first, but the important thing to take away is this: Whenever you increase your Image Sampler (AA) settings, V-Ray tries to compensate by internally decreasing your DMC Sampler settings. Later on if you're interested in learning more about how V-Rays internal formulas work - you can check out the DMC Calculator I've coded - but for right now it's not necessary.


So lets get back to the rendering:
V-Ray finishes the render as best as it can manage, but warns you (by the many RED pixels in the SampleRate render element):
"I was NOT able to figure out what's going on in all of this scene according to the level of quality (noise threshold) you want it to be at! - A lot of the time I had to use up all of the 64 Primary Samples with 1 Secondary Sample per Light, GI, and Material you allowed me to use for each pixel, but it still didn't provide me with enough information in those areas."
If we take a look at the render - we'll notice that while the geometric detail (edges of objects) seem fairly clean and defined, there are indeed noisy areas of the image - specifically noticeable in the reflections and shadows. So we've got this noisy baseline render, and we have two options to reduce the noise to meet our desired level of quality (noise threshold):

Option #1 = Increase AA Max Subdivs - Let V-Ray take more Primary Samples to figure out the scene - but again only 1 additional Secondary Sample for the Lights / GI / Materials each per Primary Sample.
Option #2 = Increase Lights / GI / Materials Subdivs - Tell V-Ray to stay at the same amount of Primary Samples - but instead allow it take more Secondary Samples with each Primary Sample to better figure out the scene.

Example Scene - Option #1 - Increased AA Max Subdivs

So lets first try what most people usually do to get a high quality (low noise) render - adopt the so-called 'Universal V-Ray Settings' and let V-Ray take as many Primary Samples (AA) as needed to eliminate the noise.

  • We'll increase the Image Sampler (AA) to 1min & 100max Subdivs.
  • We'll leave the Lights, GI, and Materials set to 8 Subdivs each.
  • We'll reduce the Noise Threshold to 0.005 to tell V-Ray we really want a noise-free render.

Figure 04
Option #1 Render - Increased AA Max Subdivs
1min & 100max Subdivs = Image Sampler (AA)
8 Subdivs = Lights, GI, and Materials each.
0.005 = Noise Threshold.
Now lets go over exactly what's happening in this Option #1 render. Through the render settings, you're telling V-Ray:
"I'm allowing you to use up to 10000 (100 subdivs) Primary Samples (AA) per pixel to figure out what's going on in this scene and reduce the noise as close as you can to my specified noise threshold... BUT for each of those Primary Samples you take, you're only allowed to take 1 additional Secondary Sample to figure out what's going on with the Lights, GI, and Materials each."
Again, remember that even though the Lights, GI, and Materials are set to 64 Samples (8 Subdivs) each - V-Ray internally divides these values by the AA Max Samples value of your scene. So instead of 64 Samples, this gets divided by the AA Max of 10000 Samples (100 Subdivs), which results in the minimum of only 1 Secondary Sample being taken for the Lights, GI, and Materials each. (64 Secondary Samples / 10000 Primary Samples = 1 Secondary Sample).

V-Ray finishes the render as best as it can manage, and tells you (by the now mostly BLUE SampleRate render element):
"I was able to figure out all of what's going on in this scene to the level of quality (noise threshold) you want it to be at! - In fact, I was able to figure it out well before I had to use all 10000 Primary Samples with 1 Secondary Samples per Lights, GI, and Materials you allowed me for each pixel."
We take a look at the Option #1 render and see the noise has definitely been improved compared to the baseline render. The render time has increased by 11min 44s (9.8x longer) compared to the Baseline Render, but that's to be expected with a higher quality render, right? At this point, most people would think this is as good as it gets, and call the render FINISHED!

...But what happens if we were to try that Option #2 we discussed earlier? Instead of increasing the AA Max Subdivs, what happens if we instead opted to only increase the Lights / GI / Materials Subdivs? Well lets find out...

Example Scene - Option #2 - Increased Light / GI / Materials Subdivs

This time we'll try something a little different - we'll tell V-Ray to take same amount of Primary Samples that we originally did in the baseline render - but instead allow V-Ray to take more Secondary Samples with each Primary Sample to better figure out the scene.

  • We'll leave the Image Sampler (AA) set to the original baseline render's settings of 1min & 8max Subdivs.
  • We'll increase the Lights, GI, and Materials to 80 Subdivs each.
  • We'll leave the Noise Threshold set to the original baseline render's default of 0.01

Figure 05
Option #2 Render - Increased Lights, GI, and Materials Subdivs
1min & 8max Subdivs = Image Sampler (AA)
80 Subdivs = Lights, GI, and Materials each.
0.01 = Noise Threshold.
Once more, lets go over exactly what's happening in this Option #2 render. Through the render settings, you're telling V-Ray:
"I'm allowing you to use up to 64 (8 subdivs) Primary Samples (AA) per pixel to figure out what's going on in this scene and reduce the noise as close as you can to my specified noise threshold... AND for each of those Primary Samples you take, you're allowed to take up to 100 additional Secondary Samples to figure out what's going on with the Lights, GI, and Materials each."
Again, remember that even though the Lights, GI, and Materials are set to 6400 Samples (80 Subdivs) each - V-Ray automatically divides these values by the AA Max Samples value of your scene. So instead of 6400 Samples, this gets divided by the AA Max of 64 Samples (8 Subdivs), which results in only 100 Secondary Samples being taken for the Lights, GI, and Materials each. (6400 Secondary Samples / 64 Primary Samples = 100 Secondary Sample).

V-Ray finishes the render as best as it can manage, and tells you (through the SampleRate render element):
"I was able to figure out almost all of what's going on in this scene to the level of quality (noise threshold) you want it to be at! - In fact, most of the time I was able to figure it out well before I had to use all 64 Primary Samples per pixel! All those extra 100 Secondary Samples per Light, GI, and Material provided each Primary Sample with so much more information this time!"
We take a look at the Option #2 render and see the noise has definitely been improved compared to the baseline render. The render time has increased by 4m 38s (4.5x Longer) compared to the Baseline Render, but that's to be expected with a higher quality render.

But here's where things start to get interesting...
When we compare Option #2's render against Option #1's render, we can see that Option #2 gave us a cleaner render!

And look at that! - Option #2 finished 2.2x faster than Option #1! - 5m 58s for Option #2 versus 13m 04s for Option #1!

Figure 06
Option #1 Render on the left, and Option #2 Render on the right.
At the bottom, the renders zoomed 400% to better show noise levels.
Why is this? Why did increasing the DMC Sampler settings (Lights / GI / Materials Subdivs) rather than increasing the Image Sampler (AA) settings result in a cleaner AND faster render for this scene? We even set Option #1 to have a lower noise threshold, yet it still turned out noisier than option #2! Well the answer lies in what we originally noticed about the Baseline render...

How Optimization Works

In our Baseline Render, we saw that while the edges of objects looked clean and defined, the noise seemed to reside primarily in the reflections and shadows. Well, if you remember what we learned earlier: Primary Samples (AA) specialize in figuring out the geometry, textures, depth of field, and motion blur in a scene. While Secondary Samples specialize in figuring out lighting, GI, shadows, materials, etc.

So in the case of fixing the noise in the Baseline render, the choice between Option #1 and Option #2 is actually a no-brainer! Why use a screwdriver to do a hammer's job? The Image Sampler (AA) had already done what it was designed to do - make the geometric detail (edges of objects) clean and defined. So instead of firing a bunch of additional Primary Samples (AA) at the scene to clean up noise - it's better to allocate those additional samples to the DMC Sampler (Lights / GI / Materials Subdivs) so it can properly do what it was designed to do - clean up the noise in the lighting, shadows, GI, reflections, and refractions. There's our answer!


And now can we begin to understand why the 'Universal V-Ray Settings' of 1min and 100max AA is generally not going to be the most efficient method to render a scene - in fact it never was meant to be the most efficient method! The Universal V-Ray Settings were designed to make V-Ray accessible and easy for users who don't care about render optimization or learning how V-Ray works under the hood. It's simply a method to put V-Ray on auto-pilot. It allows a user to control all render quality by adjusting only one setting - the noise threshold. If there's too much noise in a render, just lower the noise threshold, and V-Ray will keep firing Primary Samples (AA) at the scene until it eventually reaches the noise threshold - guaranteeing a nice looking render with minimal understanding of how V-Ray works. But that render is generally not going to be as clean or render as fast as if you take the time to understand how V-Ray works and balance the Image Sampler and DMC Sampler according to a scene's demands!

And just to really drive the point home - the Option #2 Render can still be optimized even further! Using some additional tricks listed in the procedures at the end of this tutorial, we can reduce it's render time from 5m 58s to 4m 53s with only a slight hit in noise amounts! For a final render speed increase of 2.7 times faster than the Option #1 Render!

Figure 07
Option #1 Render on the left, and Option #2 Render optimized even further on the right. For a total render speed increase of 2.7x!
Here's another example of optimization, this time with a more production oriented scene...
The optimized render (right) renders nearly 35% faster than the universal settings render (left) while reducing noise and improving render quality. Also note how the reflections have become more accurate - noticeable on the floor towards the end of the hallway.

Figure 08
'Universal V-Ray Settings' on the left, and the Optimized render on the right.
Render scene courtesy of Peter Guthrie

Identifying Sources Of Noise

The key to properly optimizing a render is to correctly identify which aspects of a scene are causing noise, and assigning the right sampler with enough samples to attack that noise at it's source. Some scenes will require more samples for the Image Sampler, while others (like the ones shown in the examples above) will require more samples for the DMC Sampler. As a general guideline:

Circumstances where the Image Sampler (AA) will require larger amounts of Primary Samples to eliminate noise:
  • Fine geometric detail like Hair, Grass, Foliage, etc.
  • Very fine texture detail like weaves, tiny bump map details, etc.
  • Scenes with shallow Depth of Field or heavy Motion Blur.

Circumstances where the DMC Sampler will require larger amounts of Secondary Samples to eliminate noise:
  • Large light sources that cast soft shadows.
  • Materials with strong glossy Reflection or Refraction.
  • Scenes with prominent Global Illumination - particularly indoor scenes.

Noise caused by the Image Sampler (AA) is luckily very easy to spot to the naked eye. It manifests itself in jagged or unclear object edges, undefined texture detail or effects like Moiré patterns, and grainy depth of field or motion blur.

Noise caused by the DMC Sampler can be a bit trickier to see exactly what's causing it. Luckily we have some handy tools at our disposal to help us figure it out - V-Ray's Render Elements: Lighting, Global Illumination, Specular, Reflection, and Refraction. By looking through these various render elements, you can quickly isolate and check the levels of noise caused by any of these individual aspects of your scene.

Figure 09
By looking at the Reflection render element, we can see the amount of noise caused by material reflections alone.

Optimization Procedure

So now that we have a solid understanding of what can be gained by properly utilizing V-Ray's samplers, and how to identify the sources of noise in our scene, we can follow a step-by-step procedure to help optimize whatever scene you may be dealing with.

The general idea behind this procedure is to begin by setting the Image Sampler (AA) Max just high enough to clearly define the Geometry, Textures, Depth of Field, and Motion Blur detail in your scene, and then tune each of the DMC Sampler's aspects (Lights/Specular/Shadows, GI, Material Reflection/Refraction) one at a time to eliminate noise. So we'll start with default V-Ray settings, and bring our render to a very basic state to start the optimization process:

  1. In V-Ray's Global Settings rollout - uncheck 'Lights' to disable them, and set 'Default Lights' to ON.
  2. Then uncheck 'Reflection/Refraction' and 'Glossy Effects' to disabled them.
  3. In V-Ray's GI (Indirect Illumination) tab - disable Global Illumination.
  4. In V-Ray's Render Elements tab - add: SampleRate, Lighting, Global Illumination, Specular, Reflection, Refraction.
  5. Optional: Reduce your render frame size for faster feedback during the optimization process.
    At this point, your render should be nothing but a very plainly lit diffuse render of your scene. [Example]

  6. Tuning the Image Sampler (AA):
  7. Gradually raise the Image Sampler (AA) Max Subdivs value until all geometry edges, texture detail, depth of field, and motion blur in your scene appears crisp and clear. Check the SampleRate Render Element for red areas and reduce them as needed by increasing your Image Sampler (AA) Subdivs Max value until they only reside along the very edges of your object and texture details. Once these details appear nice and crisp, leave your Image Sampler (AA) settings alone.

  8. Tuning the scene's Lighting / Shadows / Speculars:
  9. In V-Ray's Global Settings rollout - Check 'Lights' to re-enable them, and set 'Default Lights' back to OFF.
    At this point your render should have normal lighting and shadows, but still diffuse materials. [Example]
    Notice that noise (along with more red pixels in the SamplerRate render element) has been re-introduced to the render from enabling your scene's Lighting.
  10. Raise the Subdivs value in your Lights until the noise in the shadows and lighting become acceptably smooth and clear. It's easiest to see the effect of raising these Subdivs values by checking your Lighting render element. As you raise these Subdiv values, the red pixels in your SampleRate render element should again be receding back to the very edges of your objects and textures while most other areas gradually become more blue or green - indicating that less Image Samples (AA) are being needed.

    A note about Speculars: The quality of specular highlights in your scene are also controlled by your Lights Subdivs value. As a general rule of thumb, once the shadows of a light are free of noise, the specular highlight for that light should also be free of noise. But for now we wont be able to tell since we currently have Reflections/Refractions (which Specular Highlights are a part of) globally disabled for this stage of the optimization process. So later on when wrapping up the optimization process if you notice any noisy specular highlights in the Specular render element, increasing the light's Subdivs value is how to fix it.

  11. Tuning the scene's Global Illumination (GI):
  12. In V-Ray's GI (Indirect Illumination) tab - re-enable Global Illumination.
    I recommend using Brute Force for the primary engine, and Light Cache for the secondary engine unless dealing with specific cases (like a camera fly-through) where using a cached GI method like Irradience Map is more appropriate.
    At this point your render should have normal lighting, shadows, and now GI, but still diffuse materials. [Example]
    Again notice that noise (along with more red pixels in the SamplerRate render element) has been re-introduced to the render from enabling your scene's GI.
  13. Raise the Subdivs value of your Brute Force GI until any noise in the Global Illumination becomes acceptably smooth and clear - this time using the Global Illumination render element pass to check the noise levels. Again, as you raise the Subdivs value, the red pixels in your SampleRate render element should be receding back to the very edges of your objects and textures while most other areas gradually become more blue or green - indicating that less Image Samples (AA) are being needed.

    A note about Hair: If using the VRayHairMtl in your scene, the quality of your hair's reflection and refraction is in fact controlled by your scene's Global Illumination Subdivs value. You can verify this by noticing how hair's reflection and refraction doesn't appear at all in the Reflection or Refraction render elements until GI is turned on. This is because the VRayHairMtl's reflection and refraction components are entirely dependent on GI, and this is also why the VRayHairMtl has no separate Subdivs values for it's reflection and refraction. So now is also the time to be tuning your hair reflection and refraction quality.

  14. Tuning the scene's Reflections and Refractions:
  15. In V-Ray's Global Settings rollout - Check 'Reflection/Refraction' and 'Glossy Effects' to re-enabled them.
    At this point your scene should render as normal, with lighting, GI, and material reflection & refraction. [Example]
    But again, notice that noise (along with more red pixels in the SamplerRate render element) have been re-introduced to the render from enabling your scene's Reflections & Refractions.
  16. Raise the Subdivs values in your materials' Reflections until any noise in them becomes acceptably smooth and clear. It's easiest to see the effect of raising these Subdivs values by checking your Reflection render element pass. Again, as you raise these Subdiv values, the red pixels in your SampleRate render element should again be receding to the very edges of your objects and textures while other pixels gradually become more blue or green - indicating that less Image Samples (AA) are being needed.
  17. Repeat the previous step, this time with your scene materials' Refractions.

Your render should now be optimized for an ideal render time according to the level of quality (noise threshold) you have it set at!
If you desire less noise, lower the Image Sampler's 'Color Threshold' value, and raise Lights / GI / Materials Subdivs as needed.

Figure 10
An animated GIF illustrating how allocating more samples to the DMC Sampler reduces the stress on the Image Sampler. The Image Sampler's Min & Max Subdivs stay the same, while the scene's Lights / GI / Materials Subdivs rise - resulting in less Primary Samples (AA) being needed while quality improves.

Additional Tips & Tricks

  • In the examples in this tutorial, I kept the Lights / GI / Materials all at the same Subdivs values for the sake of simplicity and to make the concepts easy to understand. But it's important to remember that a properly optimized scene will have varying Subdiv values specifically tailored to the needs of each of these secondary aspects of the scene.
    For example: A material that's only 5% reflective probably wont need too many reflection samples to prevent noise from being visible in the final image, since it's final RGB value will be 95% dependent on the material's diffuse or refraction components. But if that same material was instead 95% reflective, it will need more reflection samples to prevent noise being visible in the final render, since the reflection will now be the main contributing factor of the material's final RGB values. The same goes for material glossiness - the more glossy a material's reflection or refraction is, the more samples it'll need to eliminate noise. The same applies for lights - the larger the light, the softer the shadows, and the more samples it'll need eliminate noise.
  • Keep the DMC Sampler's Adaptive Amount setting below 1.0. There are many instances where setting this value at or near the maximum value of 1.0 can give really unpredictable results. The default value of 0.85 is a good place to leave it set.
  • Experiment with unlinking the Image Sampler's Color Threshold value from the DMC Sampler's Noise Threshold by unchecking the 'Use DMC Sampler Threshold' checkbox under V-Ray's Image Sampler rollout. Then increase the Color Threshold value in small increments to help the Image Sampler not confuse noise caused by Lights / Shadows / GI / Materials for geometric or textural detail. Raising this value can potentially re-introduce noise in your image, so you can either raise your secondary Subdivs values higher to compensate, or just accept the slightly noiser but faster render times. It takes a bit of experimentation to see if it's worth it for your particular scene.
  • Experiment with disabling the Image Filter of the Image Sampler if you don't have very small repeating detail patterns in your scene. V-Ray's Image Sampler (AA) already does a good job resolving and smoothing detail - so additional filtering sometimes isn't needed.
  • Experiment with disabling the Filter Maps checkbox in V-Ray's Global Settings rollout, or lowering the filter/blur values of individual bitmaps used in your scene's materials to values like 0.1 or 0.2. Especially consider disabling the filtering of opacity maps for materials like leaves in trees. Disabling or reducing the filter/blur values of maps will have a definite render speed increase while making your maps appear sharper, but can also have the side effects of increased RAM usage, and possible flickering or scintillation of maps in animations.
  • If using Light Cache for your GI's secondary bounces - enable 'Use for Glossy Rays' and 'Retrace Threshold' to help speed up the calculation of glossy materials.
  • If using V-Ray 3.0 - try enabling the Embree raycaster via the 'Use Embree' checkbox in the V-Ray's System rollout. In many scenes the Embree raycaster can yield a great reduction in render time with no visible difference in quality.
  • Reduce V-Ray's Bucket Size to something like 32x32 or 24x24 to avoid larger individual buckets getting stuck on a particularly difficult part of the render while other the buckets finish rendering and leave the image - causing your CPU to only use a fraction of it's available power to finish the last bit of the render. V-Ray 3.0 dynamically reduces Bucket Size towards the end of a render to help avoid this for you.

Conclusion & Acknowledgements

On a closing note - it's important to keep in mind that every scene is different, and therefore has different needs from V-Ray's two samplers. Settings that optimize one scene can potentially grind another scene to a halt - so please remember: Your settings and ability to optimize a render can vary greatly from one scene to the next. With a bit of trial & error, practice, and patience, you can gain the experience to intuitively know what settings a scene calls for.

So hopefully that helps to clear up the often confusing topic of V-Ray Render Optimization for you. If you run into any issues, have trouble understanding something, or have any tips on improving this tutorial, please feel free to get in contact with me.

Special thanks to:
Toni Bratinevic and John O'Connell for the information they've generously shared with the community on the subject.
John Rouse and Nicolas Nandi for their help proofreading and testing the procedures in this article.
Peter Guthrie for lending his gallery scene for use in the examples.

I wish you the best of luck with your future projects!

VRay Flicker Free Animation Rendering - with Moving Objects

This post is is the process of being tested and will the content will reduced and condensed to have a full explanation once i have had a chance to test it all out.


- in case your animation has moving objects, you first have to calculate the IrrMap for all frames using the Animation (pre-pass) method, and only then you can render it using the Animation (Rendering) method. GI won't be any faster, but you can rest assured there won't be any flickering.

- but, if nothing moves in your animation but the camera (fly-through), you should set LC to Fly-through mode and the IrrMap to Multiframe Incremental. That will calculate GI a lot faster. Maybe not rocket fast, but helps.


-----


http://predmondvfx.wordpress.com/2012/04/17/vray-production-settings/


-----


I have rendered a lot of sometimes very complex lighting scenarios in Vray without any flickering at all, and it is extremely simple.

Use brute force as primary GI and light cache as secondary one. Make sure you do not use light cache for glossy reflections and that sudbdivs amount is around 2000 for fullHD resolution. Everything else at defaults, and AO disabled. Works perfectly every time.

I did stuff like an animated camera chasing a car moving through a dense CG forest, and it worked very well. I tried even intentionally complex lighting scenarios, but BF+LC just does not flicker, as long as you keep "Use LC for glossy reflections" off and your subdivs amount is high enough.


----


I usually use following settings:
1, start with everything at defaults
2, primary GI brute force, subdivs 20, secondary light cache, subdivs amount same as larger side of rendered output - for example 1280 for 1280x720, or 1920 for 1920x1080
3, Adaptive DMC Min 1, Max 4,
4, Materials with glossiness 0.8-1 will have 8 glossy sudbdivs, materials with glossiness 0.6-0.8 will have 16 glossy subdivs, and materials with glossiness lower than 0.6 will have 24 glossy subdivs. Metal materials with low glossiness sometimes have 32, in cases where they get still noisy
5, subpixel mapping or clamp output is always off
6, always make sure you put your environment map into a full sphere VrayDome light... that light has usually 20-24 light subdivs. Other important lights in the scene usually have 16-20 subdivs, and smaller auxiliary lights have usually 4-8 subdivs.


------


Nacho Thomas
Nacho
DMP/Environment TD at MPC
It depends mainly on the type of flickering you are having, and the kind of movement you are rendering. This is just a quick overview of the general type of issues you might find, and an intro to the best solution.

FLICKERING BLOTCHES (Procuced by an incorrect or insufficent Irradiance map)

There are three sort of situations you must identify.
1. Nothing (except camera) is moving. This is the easiest solution. A multiframe incremental calculation of the irradiance is perfect, wont produce any flickering, and is really quick to calculate.

2. A single object, or a small area moves. The rest is still. (Example, render of a car moving in front of a building). This case is based on the previous one. You hide the moving objects, and do the same than in step 1. Then, you unhide the moving objects, and use the cool "vrayspherefade" feature to calculate a frame by frame area which includes the moving objects, and its reflections, shadows, gi and refractions.

3. GI changes completely frame to frame. (Example, skylight moves---> GI changes). This is the method which requires a longer calculation. We do an "animation>prepass" to calculate the GI frame by frame, and then an "animation>rendering", caring about the "interpolation frames", which says the number of frames around the one we are rendering, that the irradiance map will load and average. Slow and memory consuming, but sometimes it is the best solution.

FLICKERING NOISE

There are some situations than cause noise in vray:
1- Area shadows.
2. Direct light from a dome etc. (Which in fact means the same as area shadows).
3. Materials with Reflections/Refractions with glossiness different to "1"
4. Brute force as regathering method (primary bounces)
5. An antialiasing not good enough
6. Camera subdivisions (when motion blur or depth of field).

There are mainly two ways of repairing flickering noise:
1. Pull up subdivisions of the parameter which is causing the noise.
2. Use a good antialiasing. This is always better, but much longer to calculate, as it checks every pixel in the image, instead of working just in the area where you get the noise. (I usually use adaptative dmc, min 1 max 6, color threshold of 0.005 (reasonable) to 0.002 (good quality), with VrayLanczosfilter to avoid the few noise left. 



-----



http://help.chaosgroup.com/vray/help/200R1/tutorials_anim2.htm

----


http://www.workshop.mintviz.com/tutorials/flicker-free-animation-using-vray/

http://docs.chaosgroup.com/display/VRAY3/Rendering+an+Animation+with+Moving+Objects#RenderinganAnimationwithMovingObjects-Workflow

http://docs.chaosgroup.com/display/VRAY3/Rendering+an+Animation+with+Moving+Objects+II

http://www.workshop.mintviz.com/tutorials/flicker-free-animation-using-vray/

Wednesday, July 23, 2014

Displacement to Poly in Maya

Displacement Map Baking in Maya
This tutorial explains how to create image-based displacement maps for polygonal objects in Maya 3 and then bake the displacement to the objects geometry.
1. First, create an image to be used as the displacement map. The image below is a simple one created in Photoshop. The areas of the image that are lighter will cause Maya to raise raise the geometry more. Completely black areas do not affect the displacement. Save the image for use in Maya.
2. In Maya 3, select the options box for a new Polygon Plane.
3. Change the Polygon Plane Options to 10 subdivision for the Width and Height. The more subdivisions you create, the greater detail the displacement will have.
4. In the Hypershade editor, create a new Blinn material.
5. Now create a new 2D texture. Select File for the 2D texture type.
6. Double click the 2D texture you just created to open its attribute editor. Click on the folder next to the "Image Name" field and choose the image you created in step 1.
7. Using the middle mouse button, click on the middle of the 2D texture you created. While holding the middle mouse button down, drag the mouse over to the Blinn material you created. A selection menu will pop up. Choose "displacement map" from this menu.
8. After step 7, your Hypershade window should look like this:
9. Now assign the Blinn material to your polygon plane. This can accomplished by selecting the plane in one of the Maya viewports and then right clicking on the Blinn material and choosing "Assign Material To Selection."
10. A quick test render should show the plane displaced according to the image you chose for the displacement map! (Make sure you have a light in your scene or the render will appear black.)
11. To "bake" the displacement map to the plane's geometry, type "displacementToPoly;" in the command line at the bottom of the screen in Maya. Press enter after typing the command. This command permanently changes the goemetry of the object to add the displacement detail.
12. Now your plane should look something like this:
To achieve different looks, you can use other textures for the displacement map than a file. For example, you can use the procedural shaders to create different displacements.