Last change
on this file since 12302 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 |
---|
6 | uniform mat4 worldViewProj; |
---|
7 | uniform vec4 camObjPos; |
---|
8 | uniform vec4 ambient; |
---|
9 | uniform vec4 objSpaceLight; |
---|
10 | uniform vec4 lightColour; |
---|
11 | uniform vec4 offset; |
---|
12 | |
---|
13 | in vec4 position; |
---|
14 | in vec4 normal; |
---|
15 | in vec4 uv0; |
---|
16 | |
---|
17 | out vec4 oUv0; |
---|
18 | out vec4 oColour; |
---|
19 | |
---|
20 | void 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.