- Home /
Transparency showing as black - textures and images loaded using www
Hi,
I am using the WWW class to load some .png images as textures, which I then apply to programmatically generated meshes. I am setting the texture of the mesh using the game object's MeshRenderer, and I know this is working to a point as the mesh displays the texture, just with transparency as black:
gameObject.GetComponent.<MeshRenderer>().material.mainTexture = texture;
I have a feeling the problem has something to do with the way I'm setting the material up, but I don't know what it is I might be doing wrong.
Any pointers as to why transparency isn't displaying properly would be appreciated.
Thanks,
Wibbs
Answer by efge · Mar 16, 2011 at 01:42 PM
Maybe it's because you have a standard shader apllied?
You could try to use a simple Transparent/Diffuse shader as the default shader for your object.
Thanks for the quick reply - it worked :) Never even thought of shaders affecting it
$$anonymous$$y gameobject too has a Diffuse, but still it's black texture. Can you please check $$anonymous$$e here http://answers.unity3d.com/questions/936602/image-loaded-is-not-getting-displayed.html
Answer by Anton1274 · Dec 15, 2014 at 05:42 PM
I've the same problem using Unity 5 beta.. This is my code:- var www = new WWW("http://www.tonypec1974.altervista.org/snap_1.jpg"); // wait until the download is done yield www; // assign the downloaded image to the main texture of the object www.LoadImageIntoTexture(GetComponent.().material.mainTexture);
it shows only black texture Transparent/Diffuse shader doesn't work for me
03/04/2015. I've solved the issue, isn't unity problem is a server problem. Some server use a service named Cloufire. This service for speed reason keep in memory old image uploaded on the server without updating. Deactivate Cloudfire on the server will fix the problem.
$$anonymous$$y gameobject too has a Diffuse, but still it's black texture. have you solved your issue. please check $$anonymous$$e here http://answers.unity3d.com/questions/936602/image-loaded-is-not-getting-displayed.html
03/04/2015. I've solved the issue, isn't unity problem is a server problem. Some server use a service named Cloufire. This service for speed reason keep in memory old image uploaded on the server without updating. Deactivate Cloudfire on the server will fix the problem.
Answer by sumitbabucutevil · Nov 27, 2020 at 06:11 AM
you need to be using texture.EncodeToPNG(); very importnat
Answer by darthmodulus_unity · Jun 20, 2021 at 09:27 AM
I know this is an old post. But, I happened across it and decided to place an answer since as of June 19, 2021, the answer to this could also be the following:
Check your Material's option for Rendering Mode. There is Opaque, Cutout, Fade, and Transparent. If you choose Opaque, any "natural" transparency for the 2D image placed in the Albedo of the material will show as black. It also seems Opaque is selected by default.
I choose the Cutout option because it provides the most sheer edge around the image, which typically suits my needs (2D, sharp edging). But depending on what your needs are, you may wish to play with the setting for a few minutes to see its effects and pick the one that best suits you. Hope this helps!
Your answer
Follow this Question
Related Questions
www.LoadImageIntoTexture doesn't work? 1 Answer
cannot set texture 0 Answers
Unlit/Transparent texture leaves dark lines on the transparent edges 1 Answer
cant get Texture2D.LoadImage() to work 0 Answers