EnvRelight v1.5


 
This location is for Registered Users Only.
Perhaps you need to login or register.
Contributor: Michael Garrett
Diffuse and specular image based relighting.
Requirements:
6.1 or later
Linux, Mac, Windows
23 Oct 2010
3521

envlight_comp01  This gizmo allows an input latlong or angular (lightprobe) environment map to be remapped to create image based diffuse and specular relighting.  To do this requires renders of point positions and normal vectors of a 3D scene, and a Nuke camera or RenderMan OpenEXR metadata to derive the camera position.  Note that Nuke's own ScanlineRender shader outputs are suitable for relighting using this gizmo.

envlightPanel1-3

To use, select a surface type (diffuse or specular).  This will determine whether to remap the image using the normal (diffuse) or the reflection vector (specular).  Try it out with the EnvConvolve gizmo to pre-convolve a latlong environment (as shown in the images) prior to input.  This will allow fully diffuse as well as glossy and specular effects.  For a more naturalistic result, the diffuse lighting works well with a bent normal render.

 

 

 

 

 

 

 

 

 

 

 

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 a fix for proxy mode.

v1.3 - 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.4 - Fixed a bug which caused anything being executed (like a render or a CurveTool) to be interrupted.  As a result, the EXR metadata Python function has been moved to the init.py.  The default orientation of a lightprobe (angular map) environment has also been changed to match the latlong orientation.

v1.5 - Fixed the issue where the Python matrix calculation was still occurring if the metadata option was not selected.  Also, knobs are now enabled/disabled depending on the usage context although this isn't working all of the time for some reason.

Please login in order to download these files.

Comments   

 
0 # Jason Huang 2010-09-11 10:03
Thank you, Michael. Going to try it with the EnvConvolve gizmo.

cheers,
Jason
 
 
0 # luc julien 2010-10-23 11:58
Really work like a charm,

Thank for the share !

cheers,

Luc
 
 
0 # Michael Garrett 2010-10-24 12:49
Thanks, great to hear it's been useful!
 
 
0 # Scott Chambers 2010-10-31 15:31
Hi Michael!

Looks great, would you be able to post the source material that you are using? The teapot normals + point and the latlong?
Be very useful, cheers!

Scott.
 
 
0 # Michael Garrett 2010-10-31 20:03
Hi Scott,

Frank has uploaded the teapot AOV render (with camera metadata) in the footage download area, and the environment map can be downloaded from the ICT graphics lab webpage http://gl.ict.usc.edu/Data/HighResProbes/

Michael
 
 
0 # Scott Chambers 2010-11-01 00:43
Thanks Michael, thanks fantastic!

Scott.
 
 
0 # Roman Yu 2012-01-31 00:21
How about examles or screenshots how it works
 
 
0 # Michael Garrett 2012-01-31 17:18
Hi Roman,

There are a few things that could do with fixing/updating , which I hope to do soon. At which point, I can look at uploading example files.

Thanks,
Michael
 
 
0 # Ting-Jung Hsu 2014-12-07 00:43
Thanks for sharing this amazing gizmo. :-)
 

You have no rights to post comments

We have 3413 guests and 110 members online