x


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?

more ▼

asked Jul 10 '12 at 08:17 AM

fschaar gravatar image

fschaar
40 6 9 16

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??

Jul 18 '12 at 11:40 AM fschaar
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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"?

more ▼

answered Jul 14 '12 at 09:15 AM

ScroodgeM gravatar image

ScroodgeM
7.6k 2 6

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??

Jul 18 '12 at 11:20 AM fschaar
(comments are locked)
10|3000 characters needed characters left
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"
}
more ▼

answered Jul 18 '12 at 09:04 PM

ScroodgeM gravatar image

ScroodgeM
7.6k 2 6

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

Jul 19 '12 at 07:32 AM fschaar

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

Jul 19 '12 at 07:47 AM ScroodgeM
(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Jul 19 '12 at 12:23 PM

fschaar gravatar image

fschaar
40 6 9 16

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2207
x1666
x819
x178
x72

asked: Jul 10 '12 at 08:17 AM

Seen: 703 times

Last Updated: Jul 19 '12 at 12:23 PM