Home > other >  Unity3D do an object fade-in effect
Unity3D do an object fade-in effect

Time:09-27

Want to take advantage of the Unity in the implementation of the scene of a physical model fade-in, fade-in here not through transparency to achieve overall fade-in, but a similar game sword hilt appeared to tip percentages fade-in, strives for the great god assists, grateful

CodePudding user response:

Shader "Custom/Fade - FadeIn" {
The Properties {
_MainTex (" Base (RGB), "2 d)=" white "{}
_Rate (" Rate ", the Range (0.1, 1))=1
}
SubShader
{
Cull Off
Tags {" RenderType "=" Geometry "}
Pass
{
Tags {" LightMode "=" ForwardBase "}

CGPROGRAM
# pragma vertex vert
# pragma fragments frag
# include "UnityCG. Cginc
"
Uniform sampler2D _MainTex;
Uniform float4 _MainTex_ST;
Uniform float _Rate;

Struct v2f
{
Float4 pos: SV_POSITION;
Float2 uv: TEXCOORD0;
};

V2f vert (appdata_full v)
{
V2f o;
V.v ertex. * y=_Rate;
O.p OS=the mul (UNITY_MATRIX_MVP, v.v ertex);
V.t excoord. * y=_Rate;
O.u v=v.t excoord. Y * _MainTex_ST. Y + _MainTex_ST. Zw;
The return o;
}

Fixed4 frag (v2f I) : SV_Target
{
Fixed3 Albedo=tex2D (_MainTex, i.u v). The RGB.
Return fixed4 (Albedo, 1.0);
}

ENDCG
}
}
}
Don't know if you want the effect

CodePudding user response:


reference 1st floor Hey_Mill response:
Shader "Custom/Fade - FadeIn" {
The Properties {
_MainTex (" Base (RGB), "2 d)=" white "{}
_Rate (" Rate ", the Range (0.1, 1))=1
}
SubShader
{
Cull Off
Tags {" RenderType "=" Geometry "}
Pass
{
Tags {" LightMode "=" ForwardBase "}

CGPROGRAM
# pragma vertex vert
# pragma fragments frag
# include "UnityCG. Cginc
"
Uniform sampler2D _MainTex;
Uniform float4 _MainTex_ST;
Uniform float _Rate;

Struct v2f
{
Float4 pos: SV_POSITION;
Float2 uv: TEXCOORD0;
};

V2f vert (appdata_full v)
{
V2f o;
V.v ertex. * y=_Rate;
O.p OS=the mul (UNITY_MATRIX_MVP, v.v ertex);
V.t excoord. * y=_Rate;
O.u v=v.t excoord. Y * _MainTex_ST. Y + _MainTex_ST. Zw;
The return o;
}

Fixed4 frag (v2f I) : SV_Target
{
Fixed3 Albedo=tex2D (_MainTex, i.u v). The RGB.
Return fixed4 (Albedo, 1.0);
}

ENDCG
}
}
}
Don't know if you want the effect of

Thank you, this is a Java code, first I see don't quite understand, I try to study with c #,

CodePudding user response:

This is the Shader, you create a Shder program in U3D directly, delete the contents, the paste me go in and then create a corresponding material is ok,

CodePudding user response:

reference Hey_Mill reply: 3/f
this is the Shader, you create a Shder program in U3D directly, delete the contents, the paste me go in and then create a corresponding material,

Ok, thanks, I try, not how to contact the shader,,, forgive me

CodePudding user response:

Using the object and the distance of the camera, you can use simple interpolation to the fragment shader modify gl_FragColor. The value of a (transparent)

CodePudding user response:

references to 3 floor _ yukio okamoto, reply:
this is the Shader, you create a Shder program in U3D directly, delete the contents, the paste me go in and then create a corresponding material,
you this not line, I got a try, you are the direct compression mapping
  • Related