Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/data_extern/programs/GLSL150/GrassVp.glsl @ 12397

Last change on this file since 12397 was 12115, checked in by wiesep, 6 years ago

Changed folder structure, deletet some unused files and cleaned up code

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