效果
文章目录
- 效果
- 一、内置渲染管线
- 下载
- 支持几只着色器
- Basic 基本
- Attributes 属性
- Force 力
- Rim Color 轮辋颜色
- 二、URP
- 下载
- 几只毛发着色器实现的示例
- Shell 壳
- Fin 翅片
- Fur Polygon 毛发多边形
- Compare 比较
- Move 移动
- 完结
一、内置渲染管线
缺点是仅支持内置渲染管线。且无法毛发无法动
下载
Github: https://github.com/Sorumi/UnityFurShader
支持几只着色器
Basic 基本
具有环境光、漫反射和镜面反射的基本毛发着色器。
Shader "Fur/FurBasicShader"
{Properties{_Color ("Color", Color) = (1, 1, 1, 1)_Specular ("Specular", Color) = (0, 0, 0, 1)_Shininess ("Shininess", Range(0.01, 128.0)) = 8.0_MainTex ("Texture", 2D) = "white" { }_FurTex ("Fur Pattern", 2D) = "white" { }_FurLength ("Fur Length", Range(0.0, 1)) = 0.5}Category{Tags { "RenderType" = "Transparent" "IgnoreProjector" = "True" "Queue" = "Transparent" }Cull OffZWrite OnBlend SrcAlpha OneMinusSrcAlphaSubShader{Pass{CGPROGRAM#pragma vertex vert_surface#pragma fragment frag_surface#define FURSTEP 0.00#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.05#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.10#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.15#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.20#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.25#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.30#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.35#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.40#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.45#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.50#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.55#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.60#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.65#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.70#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.75#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.80#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.85#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.90#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.95#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 1.00#include "FurHelper.cginc"ENDCG}}}
}
Attributes 属性
添加毛发属性:密度、薄度、着色。
Shader "Fur/FurAttributesShader"
{Properties{_Color ("Color", Color) = (1, 1, 1, 1)_Specular ("Specular", Color) = (1, 1, 1, 1)_Shininess ("Shininess", Range(0.01, 256.0)) = 8.0_MainTex ("Texture", 2D) = "white" { }_FurTex ("Fur Pattern", 2D) = "white" { }_FurLength ("Fur Length", Range(0.0, 1)) = 0.5_FurDensity ("Fur Density", Range(0, 2)) = 0.11_FurThinness ("Fur Thinness", Range(0.01, 10)) = 1_FurShading ("Fur Shading", Range(0.0, 1)) = 0.25}Category{Tags { "RenderType" = "Transparent" "IgnoreProjector" = "True" "Queue" = "Transparent" }Cull OffZWrite OnBlend SrcAlpha OneMinusSrcAlphaSubShader{Pass{CGPROGRAM#pragma vertex vert_surface#pragma fragment frag_surface#define FURSTEP 0.00#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.05#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.10#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.15#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.20#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.25#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.30#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.35#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.40#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.45#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.50#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.55#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.60#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.65#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.70#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.75#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.80#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.85#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.90#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.95#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 1.00#include "FurHelper.cginc"ENDCG}}}
}
Force 力
加力:全局力和局部力。
Shader "Fur/FurForceShader"
{Properties{_Color ("Color", Color) = (1, 1, 1, 1)_Specular ("Specular", Color) = (1, 1, 1, 1)_Shininess ("Shininess", Range(0.01, 256.0)) = 8.0_MainTex ("Texture", 2D) = "white" { }_FurTex ("Fur Pattern", 2D) = "white" { }_FurLength ("Fur Length", Range(0.0, 1)) = 0.5_FurDensity ("Fur Density", Range(0, 2)) = 0.11_FurThinness ("Fur Thinness", Range(0.01, 10)) = 1_FurShading ("Fur Shading", Range(0.0, 1)) = 0.25_ForceGlobal ("Force Global", Vector) = (0, 0, 0, 0)_ForceLocal ("Force Local", Vector) = (0, 0, 0, 0)}Category{Tags { "RenderType" = "Transparent" "IgnoreProjector" = "True" "Queue" = "Transparent" }Cull OffZWrite OnBlend SrcAlpha OneMinusSrcAlphaSubShader{Pass{CGPROGRAM#pragma vertex vert_surface#pragma fragment frag_surface#define FURSTEP 0.00#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.05#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.10#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.15#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.20#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.25#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.30#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.35#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.40#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.45#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.50#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.55#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.60#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.65#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.70#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.75#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.80#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.85#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.90#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.95#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 1.00#include "FurHelper.cginc"ENDCG}}}
}
Rim Color 轮辋颜色
Add rim color 添加边缘颜色
Shader "Fur/FurRimColorShader"
{Properties{_Color ("Color", Color) = (1, 1, 1, 1)_Specular ("Specular", Color) = (1, 1, 1, 1)_Shininess ("Shininess", Range(0.01, 256.0)) = 8.0_MainTex ("Texture", 2D) = "white" { }_FurTex ("Fur Pattern", 2D) = "white" { }_FurLength ("Fur Length", Range(0.0, 1)) = 0.5_FurDensity ("Fur Density", Range(0, 2)) = 0.11_FurThinness ("Fur Thinness", Range(0.01, 10)) = 1_FurShading ("Fur Shading", Range(0.0, 1)) = 0.25_ForceGlobal ("Force Global", Vector) = (0, 0, 0, 0)_ForceLocal ("Force Local", Vector) = (0, 0, 0, 0)_RimColor ("Rim Color", Color) = (0, 0, 0, 1)_RimPower ("Rim Power", Range(0.0, 8.0)) = 6.0}Category{Tags { "RenderType" = "Transparent" "IgnoreProjector" = "True" "Queue" = "Transparent" }Cull OffZWrite OnBlend SrcAlpha OneMinusSrcAlphaSubShader{Pass{CGPROGRAM#pragma vertex vert_surface#pragma fragment frag_surface#define FURSTEP 0.00#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.05#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.10#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.15#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.20#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.25#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.30#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.35#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.40#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.45#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.50#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.55#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.60#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.65#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.70#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.75#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.80#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.85#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.90#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 0.95#include "FurHelper.cginc"ENDCG}Pass{CGPROGRAM#pragma vertex vert_base#pragma fragment frag_base#define FURSTEP 1.00#include "FurHelper.cginc"ENDCG}}}
}
二、URP
下载
https://github.com/hecomi/UnityFurURP
几只毛发着色器实现的示例
这是通用渲染管道中毛发着色器实现的示例。它包括以下功能:
- 3种方法(壳/鳍/毛发多边形)(Shell / Fin / Fur Polygon)
- 1使用几何着色器(和Fin的细分)的通道
- Lit / Unlit 点亮/未点亮
- 使用法线贴图进行照明计算
- 边缘光照
- 动画动作
Shell 壳
Fin 翅片
Fur Polygon 毛发多边形
Compare 比较
Move 移动
完结
赠人玫瑰,手有余香!如果文章内容对你有所帮助,请不要吝啬你的点赞评论和关注
,你的每一次支持
都是我不断创作的最大动力。当然如果你发现了文章中存在错误
或者有更好的解决方法
,也欢迎评论私信告诉我哦!
好了,我是向宇
,https://xiangyu.blog.csdn.net
一位在小公司默默奋斗的开发者,闲暇之余,边学习边记录分享,站在巨人的肩膀上,通过学习前辈们的经验总是会给我很多帮助和启发!如果你遇到任何问题,也欢迎你评论私信或者加群找我, 虽然有些问题我也不一定会,但是我会查阅各方资料,争取给出最好的建议,希望可以帮助更多想学编程的人,共勉~