Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSLES/instancingVp.glsles @ 12091

Last change on this file since 12091 was 12091, checked in by wiesep, 5 years ago

Updated programs and adjusted Material to work with GLSL>150

File size: 887 bytes
Line 
1#version 100
2
3precision highp int;
4precision highp float;
5
6uniform mat4 worldMatrixArray[80];
7uniform mat4 viewProjectionMatrix;
8uniform vec4 lightPos;
9uniform vec4 ambient;
10uniform vec4 lightDiffuseColour;
11
12attribute vec4 position;
13attribute vec3 normal;
14attribute vec4 uv0;
15attribute float uv1;
16
17varying vec4 oColor_0;
18#if SHADOW_CASTER
19#else
20varying vec2 oTexcoord2_0;
21#endif
22
23void main()
24{
25        // transform by indexed matrix
26        vec4 transformedPos = vec4((worldMatrixArray[int(uv1)] * position).xyz, 1.0);
27
28        // view / projection
29        gl_Position = viewProjectionMatrix * transformedPos;
30
31#if SHADOW_CASTER
32       
33        oColor_0 = ambient;
34#else
35        oTexcoord2_0 = uv0.xy;
36
37        vec3 norm = mat3(worldMatrixArray[int(uv1)]) * normal;
38       
39        vec3 lightDir =         normalize(
40                lightPos.xyz -  (transformedPos.xyz * lightPos.w));
41
42        oColor_0 = ambient + clamp(dot(lightDir, norm), 0.0, 1.0) * lightDiffuseColour;
43#endif
44}
Note: See TracBrowser for help on using the repository browser.