一天干掉一只Monkey计划_描边 (后记)

首先,祝天底下所有的小盆友,以及长不大的大盆友们,节日快乐!

 

后记,OpenPGU中有人看到LOL中的描边效果,

讨论起这个问题,

 

确实,实际应用中,还有很多细节值得讨论。
引擎中实际渲染流程的整合,性能的优化,都值得深究,

我的思路是动态增加一个法线膨胀的Pass,材质直接用描边色,标记Stencil,
然后在PostProcess里和Emitter等一并作Bloom。

 

有大大提到

“模型投影矩形区域”,

似乎很有趣,想了下,阴影,区域判断等其他地方也有可用之处,

回头也得看看。

 

这里先挖个坑,
等差不多手头活少了,

正好在UE3里实践一下,

把遮挡和Bloom加上去,看看效果如何,
也欢迎感兴趣的童鞋继续讨论。

转载于:https://www.cnblogs.com/Zephyroal/archive/2012/06/01/2529899.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个简单的Unity描边shader的示例代码: ``` Shader "Custom/Outline" { Properties { _MainTex ("Texture", 2D) = "white" {} _OutlineColor ("Outline Color", Color) = (0,0,0,1) _OutlineWidth ("Outline Width", Range (0.002, 0.1)) = 0.01 } SubShader { Tags {"Queue"="Transparent" "RenderType"="Opaque"} LOD 100 Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; sampler2D _MainTex; float4 _MainTex_ST; float4 _OutlineColor; float _OutlineWidth; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); return o; } fixed4 frag (v2f i) : SV_Target { // sample the texture fixed4 col = tex2D(_MainTex, i.uv); // calculate the outline color fixed4 outline = _OutlineColor; float2 texelSize = 1.0 / _ScreenParams.xy; float2 offset[4] = float2[]( float2(texelSize.x, 0), float2(-texelSize.x, 0), float2(0, texelSize.y), float2(0, -texelSize.y) ); for (int j = 0; j < 4; j++) { outline += tex2D(_MainTex, i.uv + _OutlineWidth * offset[j]); } outline /= 5.0; // mix the texture and outline color return lerp(outline, col, col.a); } ENDCG } } FallBack "Diffuse" } ``` 这个shader的核心思想是在每个像素周围采样一些颜色,并将它们平均值作为描边颜色。可以通过调整 `_OutlineWidth` 属性来控制描边的宽度,通过调整 `_OutlineColor` 属性来控制描边的颜色。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值