blob: 2296c835faf9ad771e9137044e08381fb28eb385 (
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
|
//
// Vertex shader for environment mapping with an
// equirectangular 2D texture
//
// Authors: John Kessenich, Randi Rost
//
// Copyright (c) 2002-2004 3Dlabs Inc. Ltd.
//
// See 3Dlabs-License.txt for license information
//
// GL2ES2: Java3D built-in attributes, these are calculated and passsed in if declared here
attribute vec4 glVertex;
attribute vec3 glNormal;
// GL2ES2: Java3D built-in uniforms, these are calculated and passsed in if declared here
uniform mat4 glModelViewMatrix;
uniform mat4 glModelViewProjectionMatrix;
uniform mat3 glNormalMatrix;
varying vec3 Normal;
varying vec3 EyeDir;
varying float LightIntensity;
uniform vec3 LightPos;
void main(void)
{
// GL2ES2: ftransform() no longer exists, but it is simple (note use of Java3D built-in uniforms and attributes)
// GL2ES2: gl_Position is unchanged
//gl_Position = ftransform();
gl_Position = glModelViewProjectionMatrix * glVertex;
// compute the transformed normal
// GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top)
//vec3 Normal = normalize(gl_NormalMatrix * gl_Normal);
Normal = normalize(glNormalMatrix * glNormal);
// GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top)
//vec4 pos = gl_ModelViewMatrix * gl_Vertex;
vec4 pos = glModelViewMatrix * glVertex;
EyeDir = pos.xyz;
LightIntensity = max(dot(normalize(LightPos - EyeDir), Normal), 0.0);
}
|