Last change
on this file since 12373 was
12115,
checked in by wiesep, 6 years ago
|
Changed folder structure, deletet some unused files and cleaned up code
|
File size:
988 bytes
|
Rev | Line | |
---|
[12115] | 1 | #version 120 |
---|
| 2 | |
---|
| 3 | uniform mat4 world; |
---|
| 4 | uniform mat4 worldViewProj; |
---|
| 5 | uniform mat4 texViewProj; |
---|
| 6 | uniform vec4 lightPosition; // object space |
---|
| 7 | |
---|
| 8 | attribute vec4 vertex; |
---|
| 9 | attribute vec3 normal; |
---|
| 10 | attribute vec3 tangent; |
---|
| 11 | attribute vec4 uv0; |
---|
| 12 | |
---|
| 13 | varying vec3 tangentLightDir; |
---|
| 14 | varying vec4 oUv; |
---|
| 15 | varying vec2 oUv2; |
---|
| 16 | |
---|
| 17 | void main() |
---|
| 18 | { |
---|
| 19 | vec4 worldPos = world * vertex; |
---|
| 20 | |
---|
| 21 | // Get object space light direction |
---|
| 22 | vec3 lightDir = normalize(lightPosition.xyz - (vertex.xyz * lightPosition.w)); |
---|
| 23 | |
---|
| 24 | // calculate shadow map coords |
---|
| 25 | oUv = texViewProj * worldPos; |
---|
| 26 | |
---|
| 27 | // pass the main uvs straight through unchanged |
---|
| 28 | oUv2 = uv0.xy; |
---|
| 29 | |
---|
| 30 | // Calculate the binormal (NB we assume both normal and tangent are |
---|
| 31 | // already normalised) |
---|
| 32 | vec3 binormal = cross(normal, tangent); |
---|
| 33 | |
---|
| 34 | // Form a rotation matrix out of the vectors |
---|
| 35 | mat3 rotation = mat3(tangent, binormal, normal); |
---|
| 36 | |
---|
| 37 | // Transform the light vector according to this matrix |
---|
| 38 | tangentLightDir = normalize(rotation * lightDir); |
---|
| 39 | |
---|
| 40 | gl_Position = worldViewProj * vertex; |
---|
| 41 | } |
---|
| 42 | |
---|
Note: See
TracBrowser
for help on using the repository browser.