summaryrefslogtreecommitdiffstats
path: root/o3d/samples/beachdemo/shaders_glsl/diffuse.glsl
blob: f33479133a577cdfcd515209ef70649efc2c7b52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
// glslv profile log:
// (70) : warning C7011: implicit cast from "float4" to "float3"
// (71) : warning C7011: implicit cast from "float4" to "float3"
// 79 lines, 2 warnings, 0 errors.

// glslf profile log:
// (70) : warning C7011: implicit cast from "float4" to "float3"
// (71) : warning C7011: implicit cast from "float4" to "float3"
// 79 lines, 2 warnings, 0 errors.

// glslv output by Cg compiler
// cgc version 2.0.0010, build date Dec 12 2007
// command line args: -profile glslv
//vendor NVIDIA Corporation
//version 2.0.0.10
//profile glslv
//program vertexShaderFunction
//semantic world : WORLD
//semantic worldViewProjection : WORLDVIEWPROJECTION
//semantic lightWorldPos
//semantic lightColor
//semantic clipHeight
//semantic viewInverse : VIEWINVERSE
//semantic worldInverseTranspose : WORLDINVERSETRANSPOSE
//semantic emissive
//semantic ambient
//semantic diffuseSampler
//semantic specular
//semantic shininess
//var float4x4 world : WORLD : _ZZ2Sworld[0], 4 : -1 : 1
//var float4x4 worldViewProjection : WORLDVIEWPROJECTION : _ZZ2SworldViewProjection[0], 4 : -1 : 1
//var float3 lightWorldPos :  :  : -1 : 0
//var float4 lightColor :  :  : -1 : 0
//var float clipHeight :  :  : -1 : 0
//var float4x4 viewInverse : VIEWINVERSE : , 4 : -1 : 0
//var float4x4 worldInverseTranspose : WORLDINVERSETRANSPOSE : _ZZ2SworldInverseTranspose[0], 4 : -1 : 1
//var float4 emissive :  :  : -1 : 0
//var float4 ambient :  :  : -1 : 0
//var sampler2D diffuseSampler :  :  : -1 : 0
//var float4 specular :  :  : -1 : 0
//var float shininess :  :  : -1 : 0
//var float4 input.position : $vin.POSITION : POSITION : 0 : 1
//var float4 input.normal : $vin.ATTR8 : $_ZZ3SZaTMP20 : 0 : 1
//var float2 input.diffuseUV : $vin.TEXCOORD0 : TEXCOORD0 : 0 : 1
//var float4 vertexShaderFunction.position : $vout.POSITION : POSITION : -1 : 1
//var float2 vertexShaderFunction.diffuseUV : $vout.TEXCOORD0 : TEXCOORD0 : -1 : 1
//var float4 vertexShaderFunction.worldPosition : $vout.TEXCOORD1 : TEXCOORD1 : -1 : 1
//var float3 vertexShaderFunction.normal : $vout.TEXCOORD2 : TEXCOORD2 : -1 : 1

attribute vec4 position;
attribute vec4 texcoord0;
vec4 _glPositionTemp;
uniform vec4 dx_clipping;

struct InVertex {
    vec4 position;
    vec4 normal;
    vec2 diffuseUV;
};

struct OutVertex {
    vec4 position;
    vec2 diffuseUV;
    vec4 worldPosition;
    vec3 normal;
};

OutVertex _ZZ3Sret_0;
vec4 _ZZ3SrZh0015;
vec4 _ZZ3SrZh0017;
vec4 _ZZ3SrZh0019;
vec4 _ZZ3SvZh0019;
attribute vec4 normal;
uniform mat4 world;
uniform mat4 worldViewProjection;
uniform mat4 worldInverseTranspose;

 // main procedure, the original name was vertexShaderFunction
void main()
{


    _ZZ3SrZh0015 = position.x*worldViewProjection[0];
    _ZZ3SrZh0015 = _ZZ3SrZh0015 + position.y*worldViewProjection[1];
    _ZZ3SrZh0015 = _ZZ3SrZh0015 + position.z*worldViewProjection[2];
    _ZZ3SrZh0015 = _ZZ3SrZh0015 + position.w*worldViewProjection[3];
    _ZZ3SrZh0017 = position.x*world[0];
    _ZZ3SrZh0017 = _ZZ3SrZh0017 + position.y*world[1];
    _ZZ3SrZh0017 = _ZZ3SrZh0017 + position.z*world[2];
    _ZZ3SrZh0017 = _ZZ3SrZh0017 + position.w*world[3];
    _ZZ3SvZh0019 = vec4(normal.x, normal.y, normal.z, 0.00000000E+00);
    _ZZ3SrZh0019 = _ZZ3SvZh0019.x*worldInverseTranspose[0];
    _ZZ3SrZh0019 = _ZZ3SrZh0019 + _ZZ3SvZh0019.y*worldInverseTranspose[1];
    _ZZ3SrZh0019 = _ZZ3SrZh0019 + _ZZ3SvZh0019.z*worldInverseTranspose[2];
    _ZZ3SrZh0019 = _ZZ3SrZh0019 + _ZZ3SvZh0019.w*worldInverseTranspose[3];
    _ZZ3SrZh0019.xyz;
    _ZZ3Sret_0.position = _ZZ3SrZh0015;
    _ZZ3Sret_0.diffuseUV = texcoord0.xy;
    _ZZ3Sret_0.worldPosition = _ZZ3SrZh0017;
    _ZZ3Sret_0.normal = _ZZ3SrZh0019.xyz;
    gl_TexCoord[0].xy = texcoord0.xy;
    gl_TexCoord[2].xyz = _ZZ3SrZh0019.xyz;
    _glPositionTemp = _ZZ3SrZh0015; gl_Position = vec4(_glPositionTemp.x + _glPositionTemp.w * dx_clipping.x, dx_clipping.w * (_glPositionTemp.y + _glPositionTemp.w * dx_clipping.y), _glPositionTemp.z * 2.0 - _glPositionTemp.w, _glPositionTemp.w);
    gl_TexCoord[1] = _ZZ3SrZh0017;
    return;
} // main end


// #o3d SplitMarker
// #o3d MatrixLoadOrder RowMajor

// glslf output by Cg compiler
// cgc version 2.0.0010, build date Dec 12 2007
// command line args: -profile glslf
//vendor NVIDIA Corporation
//version 2.0.0.10
//profile glslf
//program pixelShaderFunction
//semantic world : WORLD
//semantic worldViewProjection : WORLDVIEWPROJECTION
//semantic lightWorldPos
//semantic lightColor
//semantic clipHeight
//semantic viewInverse : VIEWINVERSE
//semantic worldInverseTranspose : WORLDINVERSETRANSPOSE
//semantic emissive
//semantic ambient
//semantic diffuseSampler
//semantic specular
//semantic shininess
//var float4x4 world : WORLD : , 4 : -1 : 0
//var float4x4 worldViewProjection : WORLDVIEWPROJECTION : , 4 : -1 : 0
//var float3 lightWorldPos :  : _ZZ2SlightWorldPos : -1 : 1
//var float4 lightColor :  : _ZZ2SlightColor : -1 : 1
//var float clipHeight :  : _ZZ2SclipHeight : -1 : 1
//var float4x4 viewInverse : VIEWINVERSE : _ZZ2SviewInverse[0], 4 : -1 : 1
//var float4x4 worldInverseTranspose : WORLDINVERSETRANSPOSE : , 4 : -1 : 0
//var float4 emissive :  : _ZZ2Semissive : -1 : 1
//var float4 ambient :  : _ZZ2Sambient : -1 : 1
//var sampler2D diffuseSampler :  : _ZZ2SdiffuseSampler : -1 : 1
//var float4 specular :  : _ZZ2Sspecular : -1 : 1
//var float shininess :  : _ZZ2Sshininess : -1 : 1
//var float2 input.diffuseUV : $vin.TEXCOORD0 : TEXCOORD0 : 0 : 1
//var float4 input.worldPosition : $vin.TEXCOORD1 : TEXCOORD1 : 0 : 1
//var float3 input.normal : $vin.TEXCOORD2 : TEXCOORD2 : 0 : 1
//var float4 pixelShaderFunction : $vout.COLOR : COLOR : -1 : 1



struct InVertex {
    vec4 normal;
    vec2 diffuseUV;
};

struct OutVertex {
    vec2 diffuseUV;
    vec4 worldPosition;
    vec3 normal;
};

vec4 _ZZ3Sret_0;
vec3 _ZZ3SZDtemp16;
float _ZZ3SxZh0021;
vec3 _ZZ3SZDtemp22;
vec3 _ZZ3SvZh0023;
float _ZZ3SxZh0027;
vec4 _ZZ3SZDtemp28;
vec4 _ZZ3SvZh0029;
float _ZZ3SxZh0033;
vec3 _ZZ3SZDtemp34;
vec3 _ZZ3SvZh0035;
float _ZZ3SxZh0039;
vec4 _ZZ3StmpZh0045;
float _ZZ3SndotlZh0045;
float _ZZ3SndothZh0045;
vec4 _ZZ3SZDtemp46;
float _ZZ3SspecularZh0047;
float _ZZ3SxZh0051;
uniform vec3 lightWorldPos;
uniform vec4 lightColor;
uniform float clipHeight;
uniform mat4 viewInverse;
uniform vec4 emissive;
uniform vec4 ambient;
uniform sampler2D diffuseSampler;
uniform vec4 specular;
uniform float shininess;

 // main procedure, the original name was pixelShaderFunction
void main()
{

    vec4 _ZZ4Sdiffuse;
    float _ZZ4Salpha;
    vec3 _ZZ4SZaTMP1;

    _ZZ4Sdiffuse = texture2D(diffuseSampler, gl_TexCoord[0].xy);
    _ZZ3SxZh0021 = dot(gl_TexCoord[2].xyz, gl_TexCoord[2].xyz);
    _ZZ3SZDtemp16 = inversesqrt(_ZZ3SxZh0021)*gl_TexCoord[2].xyz;
    _ZZ3SvZh0023 = lightWorldPos - gl_TexCoord[1].xyz;
    _ZZ3SxZh0027 = dot(_ZZ3SvZh0023, _ZZ3SvZh0023);
    _ZZ3SZDtemp22 = inversesqrt(_ZZ3SxZh0027)*_ZZ3SvZh0023;
    _ZZ3SvZh0029 = viewInverse[3] - gl_TexCoord[1];
    _ZZ3SxZh0033 = dot(_ZZ3SvZh0029, _ZZ3SvZh0029);
    _ZZ3SZDtemp28 = inversesqrt(_ZZ3SxZh0033)*_ZZ3SvZh0029;
    _ZZ3SvZh0035 = _ZZ3SZDtemp22 + _ZZ3SZDtemp28.xyz;
    _ZZ3SxZh0039 = dot(_ZZ3SvZh0035, _ZZ3SvZh0035);
    _ZZ3SZDtemp34 = inversesqrt(_ZZ3SxZh0039)*_ZZ3SvZh0035;
    _ZZ3SndotlZh0045 = dot(_ZZ3SZDtemp16, _ZZ3SZDtemp22);
    _ZZ3SndothZh0045 = dot(_ZZ3SZDtemp16, _ZZ3SZDtemp34);
    _ZZ3StmpZh0045 = vec4(_ZZ3SndotlZh0045, _ZZ3SndothZh0045, shininess, shininess);
    _ZZ3SxZh0051 = max(0.00000000E+00, _ZZ3StmpZh0045.y);
    _ZZ3SspecularZh0047 = _ZZ3StmpZh0045.x > 0.00000000E+00 ? pow(_ZZ3SxZh0051, _ZZ3StmpZh0045.z) : 0.00000000E+00;
    _ZZ3SZDtemp46 = vec4(1.00000000E+00, max(0.00000000E+00, _ZZ3StmpZh0045.x), _ZZ3SspecularZh0047, 1.00000000E+00);
    _ZZ4Salpha = gl_TexCoord[1].z > clipHeight ? 0.00000000E+00 : _ZZ4Sdiffuse.w;
    _ZZ4SZaTMP1 = (emissive + lightColor*(ambient*_ZZ4Sdiffuse + _ZZ4Sdiffuse*_ZZ3SZDtemp46.y + specular*_ZZ3SZDtemp46.z)).xyz;
    _ZZ3Sret_0 = vec4(_ZZ4SZaTMP1.x, _ZZ4SZaTMP1.y, _ZZ4SZaTMP1.z, _ZZ4Salpha);
    gl_FragColor = _ZZ3Sret_0;
    return;
} // main end