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 | |
---|
3 | precision mediump int; |
---|
4 | precision 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 |
---|
9 | uniform mat4 worldViewProj; |
---|
10 | uniform vec4 camObjPos; |
---|
11 | uniform vec4 ambient; |
---|
12 | uniform vec4 objSpaceLight; |
---|
13 | uniform vec4 lightColour; |
---|
14 | uniform vec4 offset; |
---|
15 | |
---|
16 | attribute vec4 position; |
---|
17 | attribute vec4 normal; |
---|
18 | attribute vec4 uv0; |
---|
19 | |
---|
20 | varying vec4 oUv0; |
---|
21 | varying vec4 oColour; |
---|
22 | |
---|
23 | void 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.