|
|||||||||
Rendered Channel InformationMAX renders various channels besides the colors you see on the screen. It renders the Object IDs, Material IDs, UVW Map, Normals, Z Depth, and more. This information is useful for post-processing in MAX or in any other external program. These channels are enabled when you render RLA or RPF files. MAXScript has full access to these channels, allowing us to directly read their information or to read them as grayscale images. Then, you can output these images and use them as masks inside or outside MAX. You can access these channels by rendering an image and asking the renderer to calculate these channels, or by loading an RLA or RPF file. To render the channels, you need to add channels:#(channel array), where channel array is an array of the channels you want to render. The channels you can list in this array are: #zdepth, #matid, #objectid, #uvcoords, #normal, #unclamped, #coverage, #node, #shadercolor, #shadertransparency, #velocity, and #weight. To read channel information, use GETCHANNEL, which returns the channel parameters for the specified pixel. This information is extremely technical and differs for each channel. If the bitmap does not have that channel, it will return undefined. To read the channel information as a grayscale bitmap, you can use GETCHANNELASMASK. The grayscale is similar to the images you see in the VFB when you select these channels. This bitmap can be saved and used anywhere in MAX, or in external post-processing software. Lets create a script that will render an image or load a rendered bitmap and will save the channels in separate bitmaps. Open the file render_channel.ms from your CD, or start a new script and type the commands in LISTING 16.5.
LISTING 16.5:The Render Channel script (render_channel.ms) rollout render_channel Parameters ( button sel_bmp Select a Bitmap File width:150 button rend_it Render Image width:150 dropdownlist channel Select Channel enabled:false width:150 \ align:#center button save_it Select Bitmap to Save enabled:false width:150 fn enable_list bmp = ( if bmp != undefined then ( list_items = #(RGBA_Channel) if getchannel bmp [0,0] #zdepth != undefined do append list_items Zdepth if getchannel bmp [0,0] #matid != undefined do append list_items MatID if getchannel bmp [0,0] #objectid != undefined do append list_items ObjectID if getchannel bmp [0,0] #uvcoords != undefined do append list_items UVCoords if getchannel bmp [0,0] #normal != undefined do append list_items Normal if getchannel bmp [0,0] #unclamped != undefined do append list_items Unclamped if getchannel bmp [0,0] #coverage != undefined do append list_items Coverage if getchannel bmp [0,0] #node != undefined do append list_items Node if getchannel bmp [0,0] #shadercolor != undefined do append list_items ShaderColor if getchannel bmp [0,0] #shadertransparency != undefined do append list_items ShaderTransparency if getchannel bmp [0,0] #velocity != undefined do append list_items Velocity if getchannel bmp [0,0] #weight != undefined do append list_items Weight channel.items = list_items channel.enabled = true ) else ( channel.items = #() channel.enabled = false ) ) on sel_bmp pressed do ( img = undefined img = selectbitmap() enable_list img ) on rend_it pressed do ( img = render vfb:off channels:#(#zdepth, #matid, #objectid, \ #uvcoords, #normal, #unclamped, #coverage, #node, #shadercolor, \ #shadertransparency, #velocity, #weight) enable_list img ) on channel selected i do ( execute (bmp_channel = # + channel.selected) save_it.enabled = true ) on save_it pressed do ( if img2 != undefined then (close img2) if bmp_channel == #RGBA_Channel then img2 = copy img else img2 = getchannelasmask img bmp_channel img2.filename = selectsavebitmap() save img2 display img2 ) ) try (closerolloutfloater channel_floater) catch() channel_floater = newrolloutfloater Render Channel 200 195 addrollout render_channel channel_floater
This script uses a new UI item, the listbox. It allows the user to pick one option among several options in a list. This script allows the user to select or render an image. Then it checks to see which channels exist in this bitmap, and builds a list to be displayed. The user will select the channel they want to save, and can select a bitmap to save it to.
© 2000, Frol (selection, edition, publication) |
|||||||||
|
|||||||||