ScriptSpot

Forum topic · General Scripting

Transparent color channel

By amelia · 2009-02-02

Description

I am a new user of MaxScript.

1- I need to apply an image with a transparent color # 185 With rgb 255 0 255
the image is used also in POV_Ray
...
texture
{
pigment
{
image_map
{
gif ImageFile
once
transmit 185, 1.0 // rgb 255 0 255
}
}
}
...
2- with this I am able to display the image but with the transparent color
...
theBmp = openBitMap "Image.gif"
meditMaterials[23] = RaytraceMaterial ()
meditMaterials[23].diffusemap = bitmapTexture()
meditMaterials[23].diffusemap.bitmap = theBmp
meditMaterials[23].showInViewport = true
...
cylinder ...
material:meditMaterials[23]

3- I need help.

amelia

Comments (4)

Anubis · 2009-05-21

Then dont store alpha channel in your bitmaps.
See attached shot below.

Attachments

amelia · 2009-05-21

I changed all from "diffuseMap" to "opacityMap" on above script.
The image is displayed with transparency OK, but with "gray scale" color.
I am a beginner, please continue to help me.
Thanks.

amelia

Anubis · 2009-05-20

This was asked many times from the first Max release to the pressent days and answer is still the same -- Alpha channel can not be displayed through Diffuse. Use Opacity. :)

amelia · 2009-05-20

my actual step:
*******************************************************
manual steps to display an image with transparent areas

1: select a free material
2: set "diffuse color" RGB that will be visible through
the "holes" of the image
3: select Maps->"Diffuse Color", Map-Bitmap->image.tga
4: deselect "Coordinates->Tile U V"
5: select "Standard Map in Viewport"
6: create a plane
7: apply the new material **OK**
*******************************************************
MAXScript to display an image with transparent areas

cc = 2
theBmp = openBitMap "....image.tga"

meditMaterials[cc].shaderType = 2
meditMaterials[cc].diffuse = color 0 196 196 --back color
meditMaterials[cc].diffuseMapEnable = true
meditMaterials[cc].diffuseMap = bitmapTexture()
meditMaterials[cc].diffuseMap.bitmap = theBmp
--meditMaterials[cc].diffuseMap.enabled = true --ERROR--
meditMaterials[cc].diffuseMap.filtering = 0 -- 0:Pyramidal 1:Summed Ara 2:None
meditMaterials[cc].diffuseMap.monoOutput = 1 -- 0:RGB 1:Alpha Channel
meditMaterials[cc].diffuseMap.RGBOutput = 0 -- 0:RGB 1:Alpha
meditMaterials[cc].diffuseMap.apply = true -- 0:crop OFF 1:ON
meditMaterials[cc].diffuseMap.cropPlace = 0 -- 0:Crop 1:Place
meditMaterials[cc].diffuseMap.alphasource = 0 -- 0:Alpha 1:Gray 2:Opaque
meditMaterials[cc].diffuseMap.preMultAlpha = false
meditMaterials[cc].diffuseMap.coordinates.V_Tile = false
meditMaterials[cc].diffuseMap.coordinates.U_Tile = false
meditMaterials[cc].diffuseMap.coordinates.V_Tiling = 1.0
meditMaterials[cc].diffuseMap.coordinates.U_Tiling = 1.0
meditMaterials[cc].diffuseMap.viewImage()
meditMaterials[cc].showInViewport = true

p = plane width:8.0 \
length:2.0 \
pos:[0.0,0.0, 0.010] \
material:meditMaterials[cc]\
showInViewport:true

*******************************************************
at the end, the trasnparent areas will be "black" (the Alpha mask displayed ???)
the only difference in the "Material Editor->Maps" rollout parameters is:
manual =
v Diffuse Color Map#1(image.tga)
MAXScript =
v Diffuse Color Bitmaptexture(image.tga)
*******************************************************

Any suggestions ?

Thanks.

amelia