Python Doesnt Clear Rendermap / RGB Tint Map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have some issues with rendermap and python. For some reason it doesnt want to clear the bitmaps.
The issue is that it looks like the bitmap / rgbtint doesnt want to clear in python and it stores the image somehow even though it has been overwritten on disk. So when I use the rendermap it just rerenders the previous image.
Process (I would like to avoid PIL or any non native library if possible).
1. I save a multimatte from vray framebuffer using python.
2. I open the image as a rgbtint and convert the red channel to a black and white mask and the overide save as the multimatte.
3. When I run the script again it will use the first image that has been exported in the current max session and it drives me nuts because its not a problem in regular maxscript.
Python
mapbm = rt.bitmaptexture()
mapbm.bitmap = rt.openbitmap('C:/Multimatte.jpg', gamma=2.2)
# Create a RGB Tint to convert RGB to BW
rgbtintmap = rt.rgbtint()
rgbtintmap.red = rt.color(255, 255, 255)
rgbtintmap.green = rt.color(0, 0, 0)
rgbtintmap.blue = rt.color(0, 0, 0)
rgbtintmap.map1 = mapbm
# Create a new temporary bitmap
tmptexbitmap = rt.bitmap(mapbm.bitmap.width, mapbm.bitmap.height)
tmptexbitmap.filename = 'C:/Multimatte.jpg'
# Render the image into the temporary bitmap
rt.rendermap(rgbtintmap, into=tmptexbitmap, filter=True)
rt.save(tmptexbitmap, gamma=2.2)
# Close the temporary bitmap
rt.close(tmptexbitmap)
# Close the original bitmap
rt.close(mapbm.bitmap)Maxscript version which works as it should.
(
local mapbm = bitmaptexture()
mapbm.bitmap = openbitmap @"C:\Multimatte.jpg"
local rgbtintmap = rgbtint()
rgbtintmap.red = color 255 255 255
rgbtintmap.green = color 0 0 0
rgbtintmap.blue = color 0 0 0
rgbtintmap.map1 = mapbm
local tmptexbitmap = bitmap mapbm.bitmap.width mapbm.bitmap.height
tmptexbitmap.filename = @"C:\Multimatte.jpg"
rendermap rgbtintmap into:tmptexbitmap
save tmptexbitmap gamma:2.2
close (tmptexbitmap)
free tmptexbitmap
free mapbm
free rgbtintmap
)