Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/Samples/Media/DeferredShadingMedia/DeferredShading/material/glsl/nm_notex_ps.glsl @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

File size: 2.0 KB
Line 
1/******************************************************************************
2Copyright (c) W.J. van der Laan
3
4Permission is hereby granted, free of charge, to any person obtaining a copy of
5this software  and associated documentation files (the "Software"), to deal in
6the Software without restriction, including without limitation the rights to use,
7copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8Software, and to permit persons to whom the Software is furnished to do so, subject
9to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all copies
12or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE
19SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20******************************************************************************/
21/** Deferred shading framework
22        // W.J. :wumpus: van der Laan 2005 //
23       
24        Material shader: Single colour normal mapped
25*/
26
27#extension GL_ARB_draw_buffers : enable
28
29varying vec3 normal;
30varying vec3 tangent_;
31varying vec3 binormal;
32
33varying vec2 texCoord0;
34varying float depth;
35
36uniform sampler2D normTex;
37
38uniform float specularity;
39uniform vec3 colour;
40
41void main()                   
42{
43        // Frame for normal mapping
44        mat3 rotation = mat3(tangent_, binormal, normal);
45        vec3 texnormal = (vec3(texture2D(normTex, texCoord0))-0.5)*2.0;
46       
47        gl_FragData[0].rgb = colour;
48        gl_FragData[0].a = specularity;
49        // rotation*texnormal is reversed for GL because matrices are stored transposed internally
50        // compared to HLSL
51        gl_FragData[1].xyz = normalize(rotation*texnormal); // Do normalisation here, saves an operation per light
52        gl_FragData[1].w = depth;
53       
54}
Note: See TracBrowser for help on using the repository browser.