Relight renders using a Nuke Light.
Relight
Updated: 24 October 2010
Author: michael
Compatible Nuke versions: 6.1 or later
Compatibility: Linux, Mac, Windows
This gizmo recognises Nuke lights and renders surfaces with a Phong material. It takes the following inputs:
- A Nuke Light (Light2 class) which is switchable between point, spot and directional light types.
- A Nuke camera, or metadata from an OpenEXR file rendered from PRMan, 3Delight, RenderMan for Maya etc (used to calculate specular).
- Rendered images of point positions and normal vectors.
Additional features:
- Diffuse wrap to give the look of fill light in shadow areas.
- Optional "energy conserving" normalized specular, meaning that the specular intensity increases and decreases proportional to shininess.
Generally it matches the output of lights in Nuke's scanline renderer or using the native unsupported ReLight node, but there are some issues to be aware of:
- It doesn't read the spotlight cone falloff knob (if anyone knows how it works let me know).
- It doesn't have an illuminance loop, meaning it only reads one light per node.
- Annoyingly, a Dot node will kill the expression connections between the Light and this node, so don't use one!
- The spotlight cone is similar to the native rendering but not an exact match.
- Currently there are error messages thrown up in the shell when the gizmo has no inputs, hopefully there is a fix for this later.
IMPORTANT: please add the following python function to your plugin path (for example init.py). This code is used by the Relight, EnvRelight and ReProject3D gizmos to read metadata from OpenEXR files.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
def exrCam(): def getMetadataMatrix(meta_list): m = nuke.math.Matrix4() try: for i in range(0,16): m[i] = meta_list[i] except: m.makeIdentity() return m n=nuke.thisNode() hold=int(n['frameHold'].value()) camMatrix = getMetadataMatrix(n.metadata('exr/worldToCamera',hold)) flipZ=nuke.math.Matrix4() flipZ.makeIdentity() flipZ.scale(1,1,-1) transposedMatrix = nuke.math.Matrix4(camMatrix) transposedMatrix.transpose() transposedMatrix=transposedMatrix*flipZ invMatrix=transposedMatrix.inverse() n['matrix'].setValue(invMatrix[0],0) n['matrix'].setValue(invMatrix[1],1) n['matrix'].setValue(invMatrix[2],2) n['matrix'].setValue(invMatrix[3],3) n['matrix'].setValue(invMatrix[4],4) n['matrix'].setValue(invMatrix[5],5) n['matrix'].setValue(invMatrix[6],6) n['matrix'].setValue(invMatrix[7],7) n['matrix'].setValue(invMatrix[8],8) n['matrix'].setValue(invMatrix[9],9) n['matrix'].setValue(invMatrix[10],10) n['matrix'].setValue(invMatrix[11],11) n['matrix'].setValue(invMatrix[12],12) n['matrix'].setValue(invMatrix[13],13) n['matrix'].setValue(invMatrix[14],14) n['matrix'].setValue(invMatrix[15],15) return |
v1.2 - Added the option to grab the camera position from metadata if the input image is an OpenEXR rendered from a RenderMan renderer such as PRMan or 3Delight. Big thanks to Ivan Busquets for sharing the knowledge about nuke.math!!
v1.3 - Fixed a bug which caused the node to interrupt the execution of something over a frame range (rendering, using the CurveTool etc). To fix this, the Python function to read the EXR metadata has now been migrated to init.py.
v1.4 - Fixed the issue where the Python matrix calculation was still occurring if the metadata option was not selected.