The VG Resource
How To Correctly Display Textures With Transparency In Blender - Printable Version

+- The VG Resource (https://www.vg-resource.com)
+-- Forum: The Resources (https://www.vg-resource.com/forum-109.html)
+--- Forum: The Models Resource (https://www.vg-resource.com/forum-111.html)
+---- Forum: Ripping Help (https://www.vg-resource.com/forum-115.html)
+---- Thread: How To Correctly Display Textures With Transparency In Blender (/thread-37788.html)



How To Correctly Display Textures With Transparency In Blender - Katach314 - 08-29-2020

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?


RE: How To Correctly Display Textures With Transparency In Blender - GianaSistersFan64 - 08-29-2020

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.


RE: How To Correctly Display Textures With Transparency In Blender - scurest - 08-29-2020

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'



RE: How To Correctly Display Textures With Transparency In Blender - Katach314 - 08-29-2020

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.


RE: How To Correctly Display Textures With Transparency In Blender - scurest - 08-29-2020

It only affects materials that already exist in the file, so you have to run it after every import.


RE: How To Correctly Display Textures With Transparency In Blender - Koopa512 - 07-27-2021

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