|
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?
(comments are locked)
|
|
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"? 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)
|
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"
}
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)
|
|
OK, thank you very much - doesn't look that compicated. I will try it out!
(comments are locked)
|

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