Shader in Unity if the model has a bending effect

Source: Internet
Author: User
Tags mul

The code is as follows

Shader "Custom/curved" {
Properties {
_maintex ("Base (RGB)", 2D) = "White" {}
_qoffset ("Offset", Vector) = (0,0,0,0)
_brightness ("Brightness", Float) = 0.0
_dist ("Distance", Float) = 100.0
}

Subshader {
Tags {"Queue" = "Transparent"}
Pass
{

Blend Srcalpha Oneminussrcalpha
Cgprogram
#pragma vertex vert
#pragma fragment Frag
#include "Unitycg.cginc"

            sampler2d _maintex;
   float4 _qoffset;
   float _dist;
   float _brightness;
   
   struct v2f {
       float4 pos:sv_ POSITION;
       float4 uv:texcoord0;
       FLOAT3 Viewdir:texcoord1;
       fixed4 Color:color;
   };

v2f Vert (Appdata_full v)
{
v2f o;
Float4 vPOS = Mul (UNITY_MATRIX_MV, V.vertex);
float Zoff = vpos.z/_dist;
vPOS + = _qoffset*zoff*zoff;
O.pos = Mul (unity_matrix_p, vPOS);
O.UV = V.texcoord;
return o;
}
Half4 Frag (v2f i): COLOR0
{
Half4 col = tex2d (_maintex, i.uv.xy);
Col *= Unity_lightmodel_ambient*_brightness;
return col;
}
Endcg
}
}

FallBack "Diffuse"
}

Effects such as

Shader in Unity if the model has a bending effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.