• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1attribute highp   vec3  inVertex;
2attribute mediump vec3  inNormal;
3attribute mediump vec2  inTexCoord;
4
5uniform highp   mat4  MVPMatrix;
6uniform mediump vec3  LightDirection;
7uniform mediump	float  DisplacementFactor;
8
9varying lowp    float  LightIntensity;
10varying mediump vec2   TexCoord;
11
12uniform sampler2D  sDisMap;
13
14void main()
15{
16	/*
17		Calculate the displacemnt value by taking the colour value from our texture
18		and scale it by out displacement factor.
19	*/
20	mediump float disp = texture2D(sDisMap, inTexCoord).r * DisplacementFactor;
21
22	/*
23		Transform position by the model-view-projection matrix but first
24		move the untransformed position along the normal by our displacement
25		value.
26	*/
27	gl_Position = MVPMatrix * vec4(inVertex + (inNormal * disp), 1.0);
28
29	// Pass through texcoords
30	TexCoord = inTexCoord;
31
32	// Simple diffuse lighting in model space
33	LightIntensity = dot(inNormal, -LightDirection);
34}