t1 / TFDContents / Assets / VLC for Unity / Misc / BackgroundKeyShader.shader @ 11
이력 | 보기 | 이력해설 | 다운로드 (1.4 KB)
| 1 | 11 | YCH | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' |
|---|---|---|---|
| 2 | |||
| 3 | Shader "Custom/BackgroundKeyShader" {
|
||
| 4 | Properties {
|
||
| 5 | _MainTex ("Base (RGB)", 2D) = "white" {}
|
||
| 6 | _ColorKey ("Color Key", Color) = (0,0,0,1)
|
||
| 7 | _ColorSensitivity ("Color Sensitivity", Float) = 0.6
|
||
| 8 | } |
||
| 9 | SubShader {
|
||
| 10 | Pass {
|
||
| 11 | Tags { "RenderType"="Opaque" }
|
||
| 12 | LOD 200 |
||
| 13 | |||
| 14 | CGPROGRAM |
||
| 15 | |||
| 16 | #pragma vertex VertexShaderFunction |
||
| 17 | #pragma fragment FragmentShaderFunction |
||
| 18 | |||
| 19 | #include "UnityCG.cginc" |
||
| 20 | |||
| 21 | struct VertexData{
|
||
| 22 | float4 position : POSITION; |
||
| 23 | float2 uvs : TEXCOORD0; |
||
| 24 | }; |
||
| 25 | |||
| 26 | struct VertexToFragment {
|
||
| 27 | float4 position : SV_POSITION; |
||
| 28 | float2 uvs : TEXCOORD0; |
||
| 29 | }; |
||
| 30 | |||
| 31 | VertexToFragment VertexShaderFunction(VertexData input) {
|
||
| 32 | VertexToFragment result; |
||
| 33 | result.position = UnityObjectToClipPos (input.position); |
||
| 34 | result.uvs = input.uvs; |
||
| 35 | return result; |
||
| 36 | } |
||
| 37 | |||
| 38 | sampler2D _MainTex; |
||
| 39 | float3 _ColorKey; |
||
| 40 | float _ColorSensitivity; |
||
| 41 | |||
| 42 | float4 FragmentShaderFunction(VertexToFragment input) : SV_Target {
|
||
| 43 | float4 color = tex2D(_MainTex, input.uvs); |
||
| 44 | |||
| 45 | float R = abs(color.r - _ColorKey.r); |
||
| 46 | float G = abs(color.g - _ColorKey.g); |
||
| 47 | float B = abs(color.b - _ColorKey.b); |
||
| 48 | |||
| 49 | if (R < _ColorSensitivity && G < _ColorSensitivity && B < _ColorSensitivity){
|
||
| 50 | return float4(0.0f, 0.0f, 0.0f, 0.0f); |
||
| 51 | } |
||
| 52 | |||
| 53 | return color; |
||
| 54 | } |
||
| 55 | ENDCG |
||
| 56 | } |
||
| 57 | } |
||
| 58 | } |