Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by fschaar · Jul 10, 2012 at 08:17 AM · shadertexturematerialtransparentpng

apply transparent png, material color shine through

I want to do the following: I have some cubes made by script from a prefab. I assigned a material to them with green color. now i want to assign a png textuure on top so that there is still ggreen color, were there is no picture (transparent spaces.)Is there a possibility to achive that? At the moment I have black color where there should be transparency ans the picture is colored green. I have the standard properties of the material. If I change to a transparent material i get a cutout. :(( Any ideas?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fschaar · Jul 18, 2012 at 11:40 AM 0
Share

Ok I switched to a decal shader and now I see tha transparent png on the cube. The cube has a material with diffuse green color. but somehow the color is mixed with the color of the decals. how can I prevent that??

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ScroodgeM · Jul 14, 2012 at 09:15 AM

you just need to make a one geometry (little smaller to draw behind texture) with solid diffuse green color and the second one with transparency shader and your texture attached

the best way is to write own shader, it's will be a very simple shader. better to take one that can do everyting you want but havn't a color at write 2-3 rows to it with multiply by Color. may be "Transparent/Diffues" or "Transparent/Cutout/Diffuse"?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fschaar · Jul 18, 2012 at 11:20 AM 0
Share

Thanks for your help, but I'm new to unity and writing a new shader is not exactly what I was going to try first ;) What does it mean to write a one geometry??du i have to double the cube and apply the texture to the outer cube??

avatar image
0

Answer by ScroodgeM · Jul 18, 2012 at 09:04 PM

Shader "Diffuse colored in alpha" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base (RGBA)", 2D) = "white" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 250

     CGPROGRAM
     #pragma surface surf Lambert

     sampler2D _MainTex;
     fixed4 _Color;

     struct Input
     {
         float2 uv_MainTex;
         float2 uv_DecalTex;
     };

     void surf (Input IN, inout SurfaceOutput o)
     {
         fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
         o.Albedo = lerp(_Color, c.rgb, c.a);
         o.Alpha = 1;
     }
     ENDCG
 }
 Fallback "Diffuse"

}

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fschaar · Jul 19, 2012 at 07:32 AM 0
Share

Is this a C# Script? I'm currently using Javascript. Do I have to attach this to the material?

avatar image ScroodgeM · Jul 19, 2012 at 07:47 AM 0
Share

it's a shader you asked for. save it to .shader file ti your project and choose this shader 'Diffuse colored in alpha' in material u need

avatar image Doddi · Sep 01, 2013 at 09:02 PM 0
Share

Awesome! That's exactly what I was looking for :D

avatar image
0

Answer by fschaar · Jul 19, 2012 at 12:23 PM

OK, thank you very much - doesn't look that compicated. I will try it out!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Tint transparent texture 1 Answer

Changing Eye Colour (Colour only non-white parts of a texture?) 2 Answers

How can i change detail texture? 1 Answer

Material trouble 0 Answers

How can i get my quad to only render my texture without stretching it? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges