Render to texture with Alpha?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

REPLY TO THREAD
 
Thread Tools Display Modes
  06 June 2018
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?
 
  06 June 2018
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?
__________________
Jorge Rodríguez
PolyTools3D
 
  06 June 2018
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])
)
__________________
Jorge Rodríguez
PolyTools3D
 
  06 June 2018
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
 
  06 June 2018
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?
__________________
Jorge Rodríguez
PolyTools3D
 
  06 June 2018
It's possible with Vray via refraction, but that's of course not a native renderer.
 
  06 June 2018
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)
 
  06 June 2018
Originally Posted by Noren: It's possible with Vray via refraction, but that's of course not a native renderer.
vray with refraction... could you give me please more details (settings). i can use vray if it's only the chance
 
  06 June 2018
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.
 
  06 June 2018
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?
 
  06 June 2018
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.)

Last edited by Noren : 06 June 2018 at 02:55 AM.
 
  06 June 2018
Link  (Max 2014, Vray 3.6, I saved it backwards compatible, let me know if this messed up anything.)

it seems like it works! nice. I will check it more carefully and let you know. Thanks a lot!
 
  06 June 2018
I can confirm that VRay + Refraction slot works the best way for my needs. Specifically - I need to bake a high-res roof covered with palm leaves (diffuse + alpha + normal-map + lighting) to one flat texture for low-res 
roof covered with palm leavesroof covered with palm leaves
roof covered with palm leaves
 
  06 June 2018
Originally Posted by Noren: I'm using a normal Vray material.
that's what i was asking for. Thanks again. 
 
  06 June 2018
No problem, glad It works for you!

Edit: You might have to resort to a cutout method for rendering the normal maps (assuming that recalculating them is necessary in most cases)

Last edited by Noren : 06 June 2018 at 11:58 AM.
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:59 PM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.