Notifications
Clear all

[Closed] Render to texture with Alpha?

I asked this question on 3D artists forums before, but could not get an answer. More precisely, the answer was negative. Therefore, I repeat the question, with the hope of some possible programming solution:
Is it possible to render materials with an alpha channel into texture?

21 Replies

The problem I see (at first glance) rendering a material is how light and topology affects it. I guess for some materials it would be very
simple to do, but not for all, depending on what you need.

If you have a default self-illuminated material with diffuseand opacity bitmaps, just render two maps and combine them. Or you could create
a plane and render it.

But how would it look if, for example, the material is ashiny material, or if it has reflections, refractions, displacement?

And how they would be if they are materials from other renderers?

Here is a rough implementation from an old post (not meant to win the “best performance” competition):


(
    fn RenderMat material width:512 height:512 =
    (
        fn SetAlpha c1 p1 c2 p2 = (c2.a = c1.v; c2)
        
        colorMap = bitmap width height
        
        renderMap material.diffusemap size:[width,height] filter:on into:colorMap
        alphaMap = renderMap material.opacitymap size:[width,height] filter:on
        
        pasteBitmap alphaMap colorMap [0,0] [0,0] type:#function function:SetAlpha
        
        return colorMap
    )
    
    display (RenderMat meditmaterials[1])
)

thank you Jorge for you respond. but i’m asking about render to texture using projection modifier. (not render to bitmap)
for example if you want to project semitransparent fish scales to fish body you can’t do it with any renderer in MAX.

you can do some alpha test with mentalray renderer but with Alpha cut-off only. and not with full alpha blend.

that’s my problem

I was waiting for your reply, because it was too simple and though I was missing something.
I now see I completely missed the whole thing. 🙁

I still don’t fully understand the problem so any attempt to help would be just as useless as the first one.

Do you know if what you want to do is possible at all or is it just a Max limitation?

It’s possible with Vray via refraction, but that’s of course not a native renderer.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

vray with refraction… could you give me please more details (settings). i can use vray if it’s only the chance

here is a simple setup:


delete objects
source = converttopoly (plane name:#source width:10 length:10 widthsegs:1 lengthsegs:1 wirecolor:green)
target = converttopoly (plane name:#target pos:[1,1,0.1] width:8 length:8 widthsegs:1 lengthsegs:1 wirecolor:orange)
t = converttopoly (plane name:#target pos:[-1,-1,0.2] width:8 length:8 widthsegs:1 lengthsegs:1)
polyop.setfacematid target #all 1
polyop.setfacematid t #all 2
polyop.attach target t
m0 = standard name:#source_mat
s0 = standard name:#shell_1
s1 = standard name:#shell_2
t0 = s0.diffusemap = bitmaptexture filename:@"dust.tga"
t0.alphasource = 0
s0.opacitymap = t0
t1 = s1.diffusemap = bitmaptexture filename:@"dust.tga"
t1.alphasource = 0
s1.opacitymap = t1
meditmaterials[1] = m1 = multimaterial name:#target_mat numsubs:2 materiallist:#(s0, s1)
source.mat = m0
target.mat = m1

where i want render to texture of source objects the result of target object, expecting a combined texture with alpha as alpha-blend of target textures (or materials)

You put your opacity maps into the refraction channel instead of alpha and choose “color+alpha” from the “Affect channels” drop down (under refraction)
You’ll have to render a Vray Complete map in RTT that will give you color and alpha.
Diffuse and other maps don’t seem to work, but you can turn off your lights and add a white Vray ambient light to get your diffuse pass (You can deactivate GI in the render settings for that).
For other channels you might have to switch them with the diffuse map.

You put your opacity maps into the refraction channel instead of alpha and choose “color+alpha” from the “Affect channels” drop down

what types of source ant target materials do i have to use?

I’m using a normal Vray material. I don’t use a target material (that would be up to your personal requirements). If that’s something script specific or under the hood, I can’t help you, I’m afraid.

Here’s an example file:

Link (Max 2014, Vray 3.6, I saved it backwards compatible, let me know if this messed up anything.)

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

that’s what i was asking for. Thanks again.

Page 1 / 2