2013年5月27日 星期一

[Unity] Shader - ShaderLab


參考資料:
相關資料:
參考範例:


人生第一次的shader撰寫XD,超陽春Unlit受擊變色用shader,透過shaderLab簡單的功能只要少少幾行就能完成!呈現的效果為,不受光影響,單一貼圖表現,可以透過Color property的alpha來控制貼圖與color間的混合

● Opaque版本
Shader "Custom/Unlit Opaque With Color" {
	Properties {
		_Color ("Color (RGB) Blending (A)", Color) = (1,0,0,0)
		_MainTex ("Base (RGB)", 2D) = "white" {}
	}
	SubShader {
		Tags {"RenderType"="Opaque" "IgnoreProjector"="True"}
		Lighting Off
		Cull back
		ZWrite On
		
		Pass {
			SetTexture [_MainTex] {
				ConstantColor [_Color]
				combine constant lerp(constant) texture
			}
		}
		
	}
	FallBack "Unlit/Diffuse"
}

● Transparent Cutout版本
Shader "Custom/Unlit Transparent Cutout With Color" {
	Properties {
		_Color ("Color (RGB) Blending (A)", Color) = (1,0,0,0)
		_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
		_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
	}
	SubShader {
		Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
		Lighting Off
		Cull back
		ZWrite On
		Blend SrcAlpha OneMinusSrcAlpha
		
		Pass {
			Alphatest Greater [_Cutoff]
			SetTexture [_MainTex] {
				ConstantColor [_Color]
				combine constant lerp(constant) texture, texture
			}
		}
		
	}
	FallBack "Unlit/TransparentCutout"
}

2013年5月23日 星期四

2013年5月9日 星期四

[Unity] Prefab 不會 update 的問題

近日在作業時遇到一個嚴重的問題!
當我把一個fbx檔案包成prefab時,就會造成部分內容無法與原始的fbx檔案同步更新。

目前只知道單純變動fbx檔案內的geometry, uv是會同步更新的,
而hierarchy完全不會更新,
skin資訊雖會更新,但是看起來只有更新了權重值,所以依然會有問題發生,
若fbx檔案變動了material,也不會更新,
此外相信不會更新的內容有非常多...
而目前對於此問題沒有找到較好的解決方式...


相關文章: