2
\$\begingroup\$

Is there a way to modify a TMP shader so it has Venetian Blinds effect (text appearing in like blinds pattern) like in Adobe after effects.I found a shader that does that the problem is how do I get that shader to work with TMP. Also if there is another way to achieve this effect on TMP text I would appreciate it. Here is the shader:

Shader "Unlit/BYCShader"
{
 Properties
 {
  [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
  _Color ("Tint", Color) = (1,1,1,1)
 
  _StencilComp ("Stencil Comparison", Float) = 8
  _Stencil ("Stencil ID", Float) = 0
  _StencilOp ("Stencil Operation", Float) = 0
  _StencilWriteMask ("Stencil Write Mask", Float) = 255
  _StencilReadMask ("Stencil Read Mask", Float) = 255
 
  _ColorMask ("Color Mask", Float) = 15
 
  _Lan("Lan",Float) = 10 
  _StepX("StepX",Range(0.0,1.0))=1.0
 
  [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
 }
 
 SubShader
 {
  Tags
  {
   "Queue"="Transparent"
   "IgnoreProjector"="True"
   "RenderType"="Transparent"
   "PreviewType"="Plane"
   "CanUseSpriteAtlas"="True"
  }
 
  Stencil
  {
   Ref [_Stencil]
   Comp [_StencilComp]
   Pass [_StencilOp]
   ReadMask [_StencilReadMask]
   WriteMask [_StencilWriteMask]
  }
 
  Cull Off
  Lighting Off
  ZWrite Off
  ZTest [unity_GUIZTestMode]
  Blend SrcAlpha OneMinusSrcAlpha
  ColorMask [_ColorMask]
 
  Pass
  {
   Name "Default"
  CGPROGRAM
   #pragma vertex vert
   #pragma fragment frag
   #pragma target 2.0
 
   #include "UnityCG.cginc"
   #include "UnityUI.cginc"
 
   #pragma multi_compile __ UNITY_UI_CLIP_RECT
   #pragma multi_compile __ UNITY_UI_ALPHACLIP
 
   struct appdata_t
   {
    float4 vertex : POSITION;
    float4 color : COLOR;
    float2 texcoord : TEXCOORD0;
    UNITY_VERTEX_INPUT_INSTANCE_ID
   };
 
   struct v2f
   {
    float4 vertex : SV_POSITION;
    fixed4 color : COLOR;
    float2 texcoord : TEXCOORD0;
    float4 worldPosition : TEXCOORD1;
    UNITY_VERTEX_OUTPUT_STEREO
   };
 
   v2f vert(appdata_t v)
   {
    v2f OUT;
    UNITY_SETUP_INSTANCE_ID(v);
    UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
    OUT.worldPosition = v.vertex;
    OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
 
    OUT.texcoord = v.texcoord;
 
    OUT.color = v.color;
    return OUT;
   }
 
   sampler2D _MainTex;
 
   float _Lan;
   float _StepX;
 
   float4 frag(v2f IN) : SV_Target
   {
 
    //Cut here
    float2 uv = IN.texcoord;
    uv.x*= _Lan;
 uv.x = frac(uv.x);
 int needDiscard = step(_StepX,uv.x);
 if(needDiscard == 1){
  discard;
 }
 
 //Here is the shear
 float x1 = uv.x;
 uv = IN.texcoord;
 uv+=float2(-0.5,-0.5); 
    uv.x-=x1;// When shearing, first adjust the center of gravity to the center, and then cut around the starting point of each column (this is similar to rotating around a certain point, so the reverse operation should be carried out later. If you add, you will decrease, if you reduce, you will increase)
    float2x2 qiebian = float2x2(1,0,(1.0-_StepX),1);
    uv = mul(qiebian,uv);
    uv-=float2(-0.5,-0.5);
    uv.x+=x1;
 
 float4 color= tex2D(_MainTex, uv);
 
 
 return color;
   }
  ENDCG
  }
 }
}

Taken from this link: https://developpaper.com/unity-shader-to-achieve-blinds-effect/

On thing to note is that I'm not really good at writhing shaders I mostly translate some from shadertoy to unity and created some in shader graph(in this specific project I'm using standard render pipeline so no shade graph).

\$\endgroup\$
0

You must log in to answer this question.

Browse other questions tagged .