Other posts of the serie
- Light Maps with 3DSMax and VRay — III (October 28, 2010)
- Light Maps with 3DSMax and VRay — II (October 28, 2010)
- Light Maps with 3DSMax and VRay — I (October 28, 2010)
In the first part of this tutorial, I focused on modeling, lighting and VRay setup in 3DS Max. In this part we will create the mapping coordinates for the light maps. Download the sample movie:
Lightmaps Demo (7565 downloads )and save it in “C:\lightMapsTutorial\”.
Open Director and load “lightmapsDemo.dir”. Import “geometry.w3d” in slot 1 of castlib “Internal”. Import “lights.w3d” in slot 2 of castlib “Internal”.
Import all previously rendered images (light maps) from “C:\lightMapsTutorial\”. Check Stage(24 bits), uncheck Trim White Space and check Same Settings for Remaining Images.
Open the message window and type in it :
generateLightMap( member(1), member(2) )
Wait until the “Scene Setup” script* completes the processing – when finished, it will output in the message window
–"LightMapText Created"
The processing may take a few moments, depending of the machine.
Place the “geometry” castmember in the score channel 1, frame 2 . Select the sprite, set its width to 535 and set its height to 276.
Create a behavior script, name it “Scene Setup” and paste the following code in it:
[code lang=”lingo” gutter=”true” toolbar=”true” collapse=”false”]
— Scene Setup behaviour script
property _cnt
property _rad
property _init
property _scene, _camera
on beginSprite( me )
_movie.puppetTempo( 60 )
_cnt = 0
_rad = 200
_init = FALSE
setupWorld()
t = timeout().new( "setup", 10, #setup, me )
t = VOID
end beginSprite
on exitFrame( 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 setup( me, atimer )
_scene = sprite( me.spritenum ).member
_camera = _scene.camera[ 1 ]
_camera.fieldOfView = 30
_camera.colorBuffer.clearValue = rgb( "#AEBAC7" )
_camera.fog.decayMode = #linear
_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 contains "sphere" ) then
shd.specular = rgb( "FFFFFF" )
shd.shininess = 80
end if
end repeat
flshader = _scene.shader( "floor" )
flshader.textureList[1] = _scene.texture( "DefaultTexture" )
flshader.textureTransformList[1].scale = vector( 0.025, 0.025, 1 )
_init = TRUE
atimer.forget()
end setup
on moveCamera( me )
if( not _init ) then return
_cnt = _cnt + 1
x = sin( me.degreesToRadians( _cnt )) * _rad
y = cos( me.degreesToRadians( _cnt )) * _rad
_camera.transform.position = vector( x, y, 100 )
_camera.pointAt( _scene.model("box1"), vector(0,0,1) )
end moveCamera
on degreesToRadians ( me, degreeValue )
return degreeValue * PI/180
end degreesToRadians
[/code]
Attach “Scene Setup” behaviour to the sprite on channel 1, frame 2.
Run the movie – you should see the camera orbiting around the scene ( like in the demo below ).
Below are the complete files:
Lightmaps - complete (2533 downloads )*Note: The original version of this script can be found on http://www.dubane.com/cons/max2004/helpers/lightmapping.html
Very clear/helpful