之前做项目需要给一个板子上挖孔,用了很笨的方法.
通过shader也可以实现.
Shader "Custom/s1" {
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_PosX("PositionX",float) = 0
_PosY("PositionY",float) = 0
_Width("Width",float)=0
_Height("Height",float)=0
}
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform float _PosX;
uniform float _PosY;
uniform float _Width;
uniform float _Height;
struct vertexOutput{
float4 pos : SV_POSITION;
float4 pos2:TEXCOORD1;
float2 uv:TEXCOORD0;
};
vertexOutput vert(appdata_full v)
{
vertexOutput o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);