Light Maps with 3DSMax and VRay — III

Other posts of the serie

  1. Light Maps with 3DSMax and VRay — III (Octo­ber 28, 2010)
  2. Light Maps with 3DSMax and VRay  —  II (Octo­ber 28, 2010)
  3. Light Maps with 3DSMax and VRay — I (Octo­ber 28, 2010)

In the first part of this tuto­r­i­al, I focused on mod­el­ing, light­ing and VRay set­up in 3DS Max. In this part we will cre­ate the map­ping coor­di­nates for the light maps. Down­load the sam­ple movie:

Lightmaps Demo (7096 downloads) 

and save it in “C:\lightMapsTutorial\”.
Open Direc­tor and load “lightmapsDemo.dir”. Import “geometry.w3d” in slot 1 of castlib “Inter­nal”. Import “lights.w3d” in slot 2 of castlib “Inter­nal”.
Import all pre­vi­ous­ly ren­dered images (light maps) from “C:\lightMapsTutorial\”. Check Stage(24 bits), uncheck Trim White Space and check Same Set­tings for Remain­ing Images.
Open the mes­sage win­dow and type in it :

gen­er­ate­LightMap( member(1), member(2) )

Wait until the “Scene Set­up” script* com­pletes the pro­cess­ing — when fin­ished, it will out­put in the mes­sage window

–“LightMap­Text Created”

The pro­cess­ing may take a few moments, depend­ing of the machine.
Place the “geom­e­try” cast­mem­ber in the score chan­nel 1, frame 2 . Select the sprite, set its width to 535 and set its height to 276.
Cre­ate a behav­ior script, name it “Scene Set­up” and paste the fol­low­ing code in it:

show code

– Scene Set­up behav­iour script
prop­er­ty _cnt
prop­er­ty _rad
prop­er­ty _init
prop­er­ty _scene, _camera

on begin­Sprite( me )
_movie.puppetTempo( 60 )
_cnt = 0
_rad = 200
_init = FALSE
setupWorld()
t = timeout().new( “set­up”, 10, #set­up, me )
t = VOID
end beginSprite

on exit­Frame( me )
b = _camera.overlay[1].blend
if( b > 0 ) then
b = b — 1
_camera.overlay[1].blend = b
end if
me.moveCamera()
_movie.go( _movie.frame )
end exitFrame

on set­up( me, atimer )
_scene = sprite( me.spritenum ).mem­ber

_camera = _scene.camera[ 1 ]
_camera.fieldOfView = 30
_camera.colorBuffer.clearValue = rgb( “#AEBAC7” )
_camera.fog.decayMode = #lin­ear
_camera.fog.color = rgb( “#AEBAC7” )
_camera.fog.enabled = true
_camera.fog.near = 300
_camera.fog.far = 400

repeat with s = 1 to _scene.texture.count
tx = _scene.texture[ s ]
tx.renderFormat = #rgba8880
end repeat

repeat with s = 1 to _scene.shader.count
shd = _scene.shader[ s ]
shd.useDiffuseWithTexture = true
shd.emissive = shd.diffuse
if( shd.name con­tains “sphere” ) then
shd.specular = rgb( “FFFFFF” )
shd.shininess = 80
end if
end repeat
flshad­er = _scene.shader( “floor” )
flshader.textureList[1] = _scene.texture( “Default­Tex­ture” )
flshader.textureTransformList[1].scale = vec­tor( 0.025, 0.025, 1 )
_init = TRUE
atimer.forget()
end setup

on move­Cam­era( me )
if( not _init ) then return
_cnt = _cnt + 1
x = sin( me.degreesToRadians( _cnt )) * _rad
y = cos( me.degreesToRadians( _cnt )) * _rad
_camera.transform.position = vec­tor( x, y, 100 )
_camera.pointAt( _scene.model(“box1”), vector(0,0,1) )
end moveCamera

on degreesToRa­di­ans ( me, degreeValue )
return degree­Val­ue * PI/180
end degreesToRadians


Attach “Scene Set­up” behav­iour to the sprite on chan­nel 1, frame 2.
Run the movie — you should see the cam­era orbit­ing around the scene ( like in the demo below ).
Light Maps demo

Below are the com­plete files:

Lightmaps — com­plete (2202 downloads) 

*Note: The orig­i­nal ver­sion of this script can be found on http://www.dubane.com/cons/max2004/helpers/lightmapping.html

 
Comments

Very clear/helpful