1 | /* YUV -> RGB shader for 4:2:2 I420 format (+ rounded rectangles) |
---|
2 | * |
---|
3 | * MIT X11 license, Copyright (c) 2007 by: |
---|
4 | * |
---|
5 | * Authors: |
---|
6 | * Michael Dominic K. <mdk@mdk.am> |
---|
7 | * |
---|
8 | * Permission is hereby granted, free of charge, to any person obtaining a |
---|
9 | * copy of this software and associated documentation files (the "Software"), |
---|
10 | * to deal in the Software without restriction, including without limitation |
---|
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
---|
12 | * and/or sell copies of the Software, and to permit persons to whom the |
---|
13 | * Software is furnished to do so, subject to the following conditions: |
---|
14 | * |
---|
15 | * The above copyright notice and this permission notice shall be included |
---|
16 | * in all copies or substantial portions of the Software. |
---|
17 | * |
---|
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
---|
19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
---|
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
---|
21 | * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
---|
22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
---|
23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
---|
24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | struct pixel_in { |
---|
29 | float2 texcoord1 : TEXCOORD0; |
---|
30 | float2 texcoord2 : TEXCOORD1; |
---|
31 | float2 texcoord3 : TEXCOORD2; |
---|
32 | uniform samplerRECT texture1 : TEXUNIT0; |
---|
33 | uniform samplerRECT texture2 : TEXUNIT1; |
---|
34 | uniform samplerRECT texture3 : TEXUNIT2; |
---|
35 | float4 color : COLOR0; |
---|
36 | }; |
---|
37 | |
---|
38 | struct pixel_out { |
---|
39 | float4 color : COLOR0; |
---|
40 | }; |
---|
41 | |
---|
42 | pixel_out |
---|
43 | main (pixel_in IN) |
---|
44 | { |
---|
45 | pixel_out OUT; |
---|
46 | |
---|
47 | float3 pre; |
---|
48 | |
---|
49 | pre.r = texRECT (IN.texture1, IN.texcoord1).x; |
---|
50 | pre.g = texRECT (IN.texture2, IN.texcoord2).x - (128.0 / 256.0); |
---|
51 | pre.b = texRECT (IN.texture3, IN.texcoord3).x - (128.0 / 256.0); |
---|
52 | |
---|
53 | //const float3 red = float3 (1/219, 0.0, 1.371/219) * 255.0; |
---|
54 | //const float3 green = float3 (1/219, -0.336/219, -0.698/219) * 255.0; |
---|
55 | //const float3 blue = float3 (1/219, 1.732/219, 0.0) * 255.0; |
---|
56 | const float3 red = float3 (1.0/255.0, 0.0, 1.371/255.0) * 255.0; |
---|
57 | const float3 green = float3 (1.0/255.0, -0.336/255.0, -0.698/255.0) * 255.0; |
---|
58 | const float3 blue = float3 (1.0/255.0, 1.732/255.0, 0.0) * 255.0; |
---|
59 | |
---|
60 | OUT.color.r = dot (red, pre); |
---|
61 | OUT.color.g = dot (green, pre); |
---|
62 | OUT.color.b = dot (blue, pre); |
---|
63 | OUT.color.a = IN.color.a; |
---|
64 | |
---|
65 | return OUT; |
---|
66 | } |
---|