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
I see you already solved the problem so this is coming late.

Just out of curiosity, because I tried it with mental ray and I am trying to understand the problem you described, does this setup work on your end?

The only problem I see is that the final rendered texture does not have proper alpha (based on the images), but for people that don't have VRay, there could be a workaround to create a separated image and use it as alpha.

I tried with lights, shadows, normal map, and everything renders correctly in Max 2014. The normal map (same as AO) uses the geometry and not the alpha from the materials.


(
    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 diffuse:black name:#source_mat
    s0 = raytracematerial name:#shell_1
    s1 = raytracematerial name:#shell_2
    
    diff = bitmaptexture filename:@"c:\dust.jpg"
    mask = bitmaptexture filename:@"c:\dust_mask.jpg"
    
    s0.diffusemap = diff
    s0.transparencymap = mask
    
    s1.diffusemap = diff
    s1.transparencymap = mask
    
    meditmaterials[1] = m1 = multimaterial name:#target_mat numsubs:2 materiallist:#(s0, s1)
    meditmaterials[2] = m0
    
    source.mat = m0
    target.mat = m1
)





__________________
Jorge Rodríguez
PolyTools3D

Last edited by PolyTools3D : 06 June 2018 at 11:28 PM.
 
  07 July 2018
Jorge,

i can't reproduce your result. i'm probably missing something... 
 
  07 July 2018
This one should be ready for rendering. I think the only parameter that makes a difference in this example is the hitResolveMode, which by default is set to #closest.


(
    resetmaxfile #noprompt

    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 diffuse:black name:#source_mat
    s0 = raytracematerial name:#shell_1
    s1 = raytracematerial name:#shell_2

    diff = bitmaptexture filename:@"c:\dust.jpg"
    mask = bitmaptexture filename:@"c:\dust_mask.jpg"

    s0.diffusemap = diff
    s0.transparencymap = mask
    s0.specular_level = 0
    s0.glossiness = 0

    s1.diffusemap = diff
    s1.transparencymap = mask
    s1.specular_level = 0
    s1.glossiness = 0

    meditmaterials[1] = m1 = multimaterial name:#target_mat numsubs:2 materiallist:#(s0, s1)
    meditmaterials[2] = m0

    source.mat = m0
    target.mat = m1
    
    
    /* RENDERING */
    renderers.current = mental_ray_renderer()
    
    
    /* PROJECTION */
    select source
    max modify mode
    mdf = projection()
    addmodifier source mdf
    mdf.addobjectnode target
    mdf.pushCage 0.25
    
    
    /* RTT */
    source.INodeBakeProperties.addBakeElement (diffusemap())
    source.INodeBakeProperties.bakeEnabled = true
    source.INodeBakeProjProperties.enabled = true
    source.hitResolveMode = #furthest
    source.warnRayMiss = false
)
__________________
Jorge Rodríguez
PolyTools3D
 
  07 July 2018
i didn't do any rendering for many years and probably forgot everything...

here is a simple setup for Standard and Raytrace materials. I expect to have at least the similar results. 
after i render the scene using just the scanline render the Standard looks exactly how i expect it, but the Raytrace is completely off.

do you have any ideas how to match second and first one (get result for raytrace similar as for standard)?


delete objects
b0 = box name:#std_box width:20 length:20 height:20 pos:[-15,0,-10] wirecolor:green
s0 = sphere name:#std_sph radius:9 segs:32 pos:[-15,0,0] wirecolor:orange
meditmaterials[1] = m0 = b0.mat = standard()
m0.diffusemap = bitmaptexture filename:@"ELMLEAF.TGA"
m0.opacitymap = bitmaptexture filename:@"ELMLEAF.TGA"


b1 = box name:#ray_box width:20 length:20 height:20 pos:[15,0,-10] wirecolor:green
s1 = sphere name:#ray_sph radius:9 segs:32 pos:[15,0,0] wirecolor:orange
meditmaterials[2] = m1 = b1.mat = raytracematerial()
m1.diffusemap = bitmaptexture filename:@"ELMLEAF.TGA"
m1.transparencymap = bitmaptexture filename:@"ELMLEAF.TGA"
  
 
  07 July 2018
Originally Posted by denisT: i didn't do any rendering for many years and probably forgot everything...

Me too. Just trying to work it out with you.
This seems to produce the same result (rendering). Didn't try RTT.


(
    delete objects
    
    chkmat = standard diffusemap:(checker())
    chkmat.diffusemap.coords.u_tiling = chkmat.diffusemap.coords.v_tiling = 10
    
    b0 = box name:#std_box width:20 length:20 height:20 pos:[-15,0,-10] wirecolor:green
    s0 = sphere name:#std_sph radius:9 segs:32 pos:[-15,0,0] wirecolor:orange material:chkmat
    meditmaterials[1] = m0 = b0.mat = standard()
    m0.diffusemap = bitmaptexture filename:@"C:\dust.tga"
    m0.opacitymap = bitmaptexture filename:@"C:\dust.tga" monooutput:1
    
    
    b1 = box name:#ray_box width:20 length:20 height:20 pos:[15,0,-10] wirecolor:green
    s1 = sphere name:#ray_sph radius:9 segs:32 pos:[15,0,0] wirecolor:orange material:chkmat
    meditmaterials[2] = m1 = b1.mat = raytracematerial()
    m1.diffusemap      = bitmaptexture filename:@"C:\dust.tga"
    m1.transparencymap = bitmaptexture filename:@"C:\dust.tga" monooutput:1
    
    m1.transparencymap.output.invert = true
    m1.index_of_refraction = 1.0
    m1.options___self_reflect_refract = false
    m1.transparency_color_on = false
    m1.enable_raytraced_reflections = false
    m1.enable_raytraced_refractions = true
)


"dust.tga" is just a .TGA made with the previous dust.jpg and dust_mask.jpg
__________________
Jorge Rodríguez
PolyTools3D
 
  07 July 2018
Deleted... I was doing something wrong.
__________________
Jorge Rodríguez
PolyTools3D

Last edited by PolyTools3D : 07 July 2018 at 12:20 AM.
 
  07 July 2018
Originally Posted by PolyTools3D: Me too. Just trying to work it out with you.
This seems to produce the same result (rendering). Didn't try RTT.

Super! It really looks the same... But the settings that make it don't make sense sometimes. I appreciate your help very much, Jorge!
 
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 04:36 PM.


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