Users browsing this thread: 1 Guest(s)
How To Correctly Display Textures With Transparency In Blender
#1
I downloaded a model with transparency from tMR (it was using it to put a 2D sprite onto a plane), but when I opened it in Blender, every part that should have been transparent was instead black. I looked online for answers and only found tutorials for making entire materials translucent.

Also strange: when I looked at the model through the Texture Paint tab in Solid shading mode (which would normally display the model with a blank white texture), not only was it using its texture, the parts intended to be transparent were now transparent (i.e. it was displaying correctly).

Could someone who knows Blender better than me explain this?
Reply
Thanked by:
#2
If you're using Blender 2.8+ you should go to Shading and try this to a material : 
[Image: de46pot-f5c94ee1-1b23-405a-96f3-1606264f...TVfyZiFthQ]
Also go to settings from the Material tab on the right. Change Opaque to Alpha Clip from Blend Mode and it should work.
Sorry for grammar, i'm french and dysphasia.
Reply
Thanked by:
#3
You don't need the Mix/TransparentBSDF stuff anymore, you just need to connect the texture Alpha to the PrincipledBSDF Alpha (and set the Blend Mode).

[Image: 2U7Luju.png]

Here's a script you can try that will do this automatically for all materials. Put it in the text editor and hit the Run button.

Code:
# Tested with Blender 2.90
import bpy
for mat in bpy.data.materials:
    if not mat.use_nodes: continue
    for n in mat.node_tree.nodes:
        if n.type == 'BSDF_PRINCIPLED': break
    else: continue
    if n.inputs["Alpha"].links: continue  # skip if already has linked Alpha
    soc = n.inputs["Base Color"]
    if not soc.links: continue
    if soc.links[0].from_socket.name != "Color": continue
    tex = soc.links[0].from_node
    if tex.type != 'TEX_IMAGE': continue
    if not tex.image: continue
    if tex.image.depth != 32: continue  # guess if image has alpha channel
    mat.node_tree.links.new(tex.outputs["Alpha"], n.inputs["Alpha"])
    mat.blend_method = 'HASHED'
3D Screenshot Tools (NDS / N64 / PS1 / PS2)
Other Tools (apicula / Vagrant Story / Star Ocean Blue Sphere)
Reply
Thanked by: zadayaz
#4
Thank you; that was very helpful. One last thing: do I need to run that script every time I open Blender? I ran that script and closed and reopened Blender, and transparent pixels showed up as black again.
Reply
Thanked by:
#5
It only affects materials that already exist in the file, so you have to run it after every import.
3D Screenshot Tools (NDS / N64 / PS1 / PS2)
Other Tools (apicula / Vagrant Story / Star Ocean Blue Sphere)
Reply
Thanked by:
#6
for eevee and the viewport:
if it's just a texture with alpha masking (aka the texture being only on part of the mesh with the other part being completely transparent, use alpha clip and if it's a transparent or partially transparent object use alpha blend
for cycles:
it just works
Reply
Thanked by:


Forum Jump: