1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24THE SOFTWARE.
25-----------------------------------------------------------------------------
26*/
27
28//-----------------------------------------------------------------------------
29// Program Name: FFPLib_Common
30// Program Desc: Common functions of the FFP.
31// Program Type: Vertex/Pixel shader
32// Language: HLSL
33// Notes: Common functions needed by all FFP implementation classes.
34//-----------------------------------------------------------------------------
35//-----------------------------------------------------------------------------
36void FFP_Assign(in float vIn, out float vOut)
37{
38	vOut = vIn;
39}
40//-----------------------------------------------------------------------------
41void FFP_Assign(in float2 vIn, out float2 vOut)
42{
43	vOut = vIn;
44}
45
46//-----------------------------------------------------------------------------
47void FFP_Assign(in float3 vIn, out float3 vOut)
48{
49	vOut = vIn;
50}
51
52//-----------------------------------------------------------------------------
53void FFP_Assign(in float4 vIn, out float4 vOut)
54{
55	vOut = vIn;
56}
57
58//-----------------------------------------------------------------------------
59void FFP_Assign(in float2x4 vIn, out float2x4 vOut)
60{
61	vOut = vIn;
62}
63
64//-----------------------------------------------------------------------------
65void FFP_Assign(in float3x4 vIn, out float3x4 vOut)
66{
67	vOut = vIn;
68}
69
70//-----------------------------------------------------------------------------
71void FFP_Construct(in float r,
72				   in float g,
73				   in float b,
74				   in float a,
75				   out float4 vOut)
76{
77	vOut = float4(r,g,b,a);
78}
79
80//-----------------------------------------------------------------------------
81void FFP_Construct(in float r,
82			 in float g,
83			 out float2 vOut)
84{
85	vOut = float2(r,g);
86}
87
88//-----------------------------------------------------------------------------
89void FFP_Construct(in float r,
90				   in float g,
91				   in float b,
92				   out float3 vOut)
93{
94	vOut = float3(r,g,b);
95}
96
97//-----------------------------------------------------------------------------
98void FFP_Construct(in float r,
99				   out float4 vOut)
100{
101	vOut = float4(r,r,r,r);
102}
103
104//-----------------------------------------------------------------------------
105void FFP_Modulate(in float vIn0, in float vIn1, out float vOut)
106{
107	vOut = vIn0 * vIn1;
108}
109
110//-----------------------------------------------------------------------------
111void FFP_Modulate(in float2 vIn0, in float2 vIn1, out float2 vOut)
112{
113	vOut = vIn0 * vIn1;
114}
115
116//-----------------------------------------------------------------------------
117void FFP_Modulate(in float3 vIn0, in float3 vIn1, out float3 vOut)
118{
119	vOut = vIn0 * vIn1;
120}
121
122//-----------------------------------------------------------------------------
123void FFP_Modulate(in float4 vIn0, in float4 vIn1, out float4 vOut)
124{
125	vOut = vIn0 * vIn1;
126}
127
128//-----------------------------------------------------------------------------
129void FFP_Add(in float vIn0, in float vIn1, out float vOut)
130{
131	vOut = vIn0 + vIn1;
132}
133
134//-----------------------------------------------------------------------------
135void FFP_Add(in float2 vIn0, in float2 vIn1, out float2 vOut)
136{
137	vOut = vIn0 + vIn1;
138}
139
140//-----------------------------------------------------------------------------
141void FFP_Add(in float3 vIn0, in float3 vIn1, out float3 vOut)
142{
143	vOut = vIn0 + vIn1;
144}
145
146//-----------------------------------------------------------------------------
147void FFP_Add(in float4 vIn0, in float4 vIn1, out float4 vOut)
148{
149	vOut = vIn0 + vIn1;
150}
151
152//-----------------------------------------------------------------------------
153void FFP_Add(in float2x4 vIn0, in float2x4 vIn1, out float2x4 vOut)
154{
155	vOut = vIn0 + vIn1;
156}
157
158//-----------------------------------------------------------------------------
159void FFP_Add(in float3x4 vIn0, in float3x4 vIn1, out float3x4 vOut)
160{
161	vOut = vIn0 + vIn1;
162}
163
164//-----------------------------------------------------------------------------
165void FFP_Subtract(in float vIn0, in float vIn1, out float vOut)
166{
167	vOut = vIn0 - vIn1;
168}
169
170//-----------------------------------------------------------------------------
171void FFP_Subtract(in float2 vIn0, in float2 vIn1, out float2 vOut)
172{
173	vOut = vIn0 - vIn1;
174}
175
176//-----------------------------------------------------------------------------
177void FFP_Subtract(in float3 vIn0, in float3 vIn1, out float3 vOut)
178{
179	vOut = vIn0 - vIn1;
180}
181
182//-----------------------------------------------------------------------------
183void FFP_Subtract(in float4 vIn0, in float4 vIn1, out float4 vOut)
184{
185	vOut = vIn0 - vIn1;
186}
187
188//-----------------------------------------------------------------------------
189void FFP_Lerp(in float vIn0, in float vIn1, float T, out float vOut)
190{
191	vOut = lerp(vIn0, vIn1, T);
192}
193
194//-----------------------------------------------------------------------------
195void FFP_Lerp(in float2 vIn0, in float2 vIn1, float T, out float2 vOut)
196{
197	vOut = lerp(vIn0, vIn1, T);
198}
199
200//-----------------------------------------------------------------------------
201void FFP_Lerp(in float3 vIn0, in float3 vIn1, float T, out float3 vOut)
202{
203	vOut = lerp(vIn0, vIn1, T);
204}
205
206//-----------------------------------------------------------------------------
207void FFP_Lerp(in float4 vIn0, in float4 vIn1, float T, out float4 vOut)
208{
209	vOut = lerp(vIn0, vIn1, T);
210}
211
212//-----------------------------------------------------------------------------
213void FFP_Lerp(in float4 vIn0, in float4 vIn1, float4 T, out float4 vOut)
214{
215	vOut = lerp(vIn0, vIn1, T);
216}
217
218//-----------------------------------------------------------------------------
219void FFP_DotProduct(in float vIn0, in float vIn1, out float vOut)
220{
221	vOut = dot(vIn0, vIn1);
222}
223
224//-----------------------------------------------------------------------------
225void FFP_DotProduct(in float2 vIn0, in float2 vIn1, out float2 vOut)
226{
227	vOut = dot(vIn0, vIn1);
228}
229
230//-----------------------------------------------------------------------------
231void FFP_DotProduct(in float3 vIn0, in float3 vIn1, out float3 vOut)
232{
233	vOut = dot(vIn0, vIn1);
234}
235
236//-----------------------------------------------------------------------------
237void FFP_DotProduct(in float4 vIn0, in float4 vIn1, out float4 vOut)
238{
239	vOut = dot(vIn0, vIn1);
240}
241
242//-----------------------------------------------------------------------------
243void FFP_Normalize(inout float3 vIn)
244{
245	vIn = normalize(vIn);
246}
247
248
249
250