Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSLES/GrassVp.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: 1.0 KB
Line 
1#version 100
2
3precision mediump int;
4precision mediump float;
5
6////////////////////////////// MOVING GRASS
7// Vertex program to wave some grass about
8// Assumes UV texture coords of v==0 indicates the top of the grass
9uniform mat4 worldViewProj;
10uniform vec4 camObjPos;
11uniform vec4 ambient;
12uniform vec4 objSpaceLight;
13uniform vec4 lightColour;
14uniform vec4 offset;
15
16attribute vec4 position;
17attribute vec4 normal;
18attribute vec4 uv0;
19
20varying vec4 oUv0;
21varying vec4 oColour;
22
23void main()
24{
25        vec4 mypos = position;
26        vec4 factor = vec4(1.0, 1.0, 1.0, 1.0) - uv0.yyyy;
27        mypos = mypos + offset * factor;
28        gl_Position = worldViewProj * mypos;
29
30        oUv0 = uv0;
31    // Color
32        // get vertex light direction (support directional and point)
33        vec3 light = normalize(objSpaceLight.xyz - (mypos.xyz * objSpaceLight.w).xyz);
34        // grass is just 2D quads, so if light passes underneath we need to invert the normal
35        // abs() will have the same effect
36    float diffuseFactor = abs(dot(normal.xyz, light));
37        oColour = ambient + diffuseFactor * lightColour;
38}
Note: See TracBrowser for help on using the repository browser.