被遮挡部分高亮
2021/5/16 18:55:40
本文主要是介绍被遮挡部分高亮,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1.前言
实现被遮挡部分高亮的shader
2.完整shader
Shader "Custom/HiddenHilight" { Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} _Glossiness ("Smoothness", Range(0,1)) = 0.5 _Metallic ("Metallic", Range(0,1)) = 0.0 //part of being occlusion _Color("Occlusion Color", Color) = (0,1,1,1) _Width("Occlusion Width", Range(0, 10)) = 1 _Intensity("Occlusion Intensity",Range(0, 10)) = 1 } SubShader { Tags { "Queue" = "Transparent"} LOD 200 CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Standard fullforwardshadows // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 sampler2D _MainTex; struct Input { float2 uv_MainTex; }; half _Glossiness; half _Metallic; fixed4 _Color; // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. // #pragma instancing_options assumeuniformscaling UNITY_INSTANCING_BUFFER_START(Props) // put more per-instance properties here UNITY_INSTANCING_BUFFER_END(Props) void surf (Input IN, inout SurfaceOutputStandard o) { // Albedo comes from a texture tinted by color fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; // Metallic and smoothness come from slider variables o.Metallic = _Metallic; o.Smoothness = _Glossiness; o.Alpha = c.a; } ENDCG Pass { ZTest Greater ZWrite Off Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct v2f { float4 worldPos : SV_POSITION; float3 viewDir : TEXCOORD0; float3 worldNor : TEXCOORD1; }; fixed4 _Color; fixed _Width; half _Intensity; v2f vert(appdata_base v) { v2f o; o.worldPos = UnityObjectToClipPos(v.vertex); o.viewDir = normalize(WorldSpaceViewDir(v.vertex)); o.worldNor = UnityObjectToWorldNormal(v.normal); return o; } float4 frag(v2f i) : SV_Target { half NDotV = saturate(dot(i.worldNor, i.viewDir)); NDotV = pow(1 - NDotV, _Width) * _Intensity; fixed4 color; color.rgb = _Color.rgb; color.a = NDotV; return color; } ENDCG } } FallBack "Diffuse" }
3.结论
此方法对于简模,比如正方体,高亮会有问题
这篇关于被遮挡部分高亮的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-06小米11i印度快充版ROM合集:极致体验,超越期待
- 2024-10-06【ROM下载】小米11i 5G 印度版系统, 疾速跃迁,定义新速度
- 2024-10-06【ROM下载】小米 11 青春活力版,青春无极限,活力全开
- 2024-10-05小米13T Pro系统合集:性能与摄影的极致融合,值得你升级的系统ROM
- 2024-10-01基于Python+Vue开发的医院门诊预约挂号系统
- 2024-10-01基于Python+Vue开发的旅游景区管理系统
- 2024-10-01RestfulAPI入门指南:打造简单易懂的API接口
- 2024-10-01初学者指南:了解和使用Server Action
- 2024-10-01Server Component入门指南:搭建与配置详解
- 2024-10-01React 中使用 useRequest 实现数据请求