1 | /******************************************************************************
|
---|
2 | Copyright (c) W.J. van der Laan
|
---|
3 |
|
---|
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of
|
---|
5 | this software and associated documentation files (the "Software"), to deal in
|
---|
6 | the Software without restriction, including without limitation the rights to use,
|
---|
7 | copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
---|
8 | Software, and to permit persons to whom the Software is furnished to do so, subject
|
---|
9 | to the following conditions:
|
---|
10 |
|
---|
11 | The above copyright notice and this permission notice shall be included in all copies
|
---|
12 | or substantial portions of the Software.
|
---|
13 |
|
---|
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
---|
15 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
---|
16 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
17 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
---|
18 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE
|
---|
19 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
20 | ******************************************************************************/
|
---|
21 | /** Deferred shading framework
|
---|
22 | // W.J. :wumpus: van der Laan 2005 //
|
---|
23 |
|
---|
24 | Post shader: Multipass, ambient (base) pass
|
---|
25 | */
|
---|
26 | sampler Tex0: register(s0);
|
---|
27 | sampler Tex1: register(s1);
|
---|
28 |
|
---|
29 | // Ambient and depth pass
|
---|
30 | float4 ambientColor;
|
---|
31 |
|
---|
32 | float4x4 proj;
|
---|
33 |
|
---|
34 | struct POUTPUT
|
---|
35 | {
|
---|
36 | float4 colour: COLOR;
|
---|
37 | float depth: DEPTH;
|
---|
38 | };
|
---|
39 |
|
---|
40 | POUTPUT main(float2 texCoord: TEXCOORD0, float3 projCoord: TEXCOORD1)
|
---|
41 | {
|
---|
42 | float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess
|
---|
43 | float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth
|
---|
44 |
|
---|
45 | // Clip fragment if depth is too close, so the skybox can be rendered on the background
|
---|
46 | clip(a1.w-0.001);
|
---|
47 |
|
---|
48 | // Attributes
|
---|
49 | POUTPUT o;
|
---|
50 | float3 colour = a0.rgb;
|
---|
51 | o.colour = float4( ambientColor*colour ,0);
|
---|
52 | o.depth = projCoord.z*proj[2][2] + proj[2][3]/a1.w;
|
---|
53 | return o;
|
---|
54 | }
|
---|
55 |
|
---|