Unity优化风格的着色器
2021-01-29 05:14
标签:mic ade hit sub tom col res sigma ret 使用时子在UI图片上可以看到效果。 Unity优化风格的着色器 标签:mic ade hit sub tom col res sigma ret 原文地址:https://www.cnblogs.com/ezhar/p/12833544.htmlShader "Custom/OilPaintEffect" {
Properties{
_MainTex("MainTex",2D)="white"{}
//迭代次数
_Radius("_Radius",Range(0.0,5.0)) = 2.0
//模糊程度
_ResolutionValue("_ResolutionValue",Range(0.0,5.0)) = 1.0
//原始图片宽的像素
_Width("Width",Int) = 0
//原始图片高的像素
_Height("Height", Int) = 0
}
SubShader{
Pass{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
int _Radius;
float _ResolutionValue;
int _Width;
int _Height;
float4 frag(v2f_img i) :SV_Target{
float2 src_size = float2(_ResolutionValue / _Width,_ResolutionValue / _Height);
float2 uv = i.uv;
float n = (_Radius + 1)*(_Radius + 1);
float3 m0 = 0.0;
float3 m1 = 0.0;
float3 s0 = 0.0;
float3 s1 = 0.0;
float3 color = 0.0;
for (int j = -_Radius;j