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:
923 bytes
|
Rev | Line | |
---|
[12115] | 1 | #version 150 |
---|
| 2 | |
---|
| 3 | uniform mat4 world; |
---|
| 4 | uniform mat4 worldIT; |
---|
| 5 | uniform mat4 worldViewProj; |
---|
| 6 | uniform mat4 texViewProj; |
---|
| 7 | uniform vec4 lightPosition; |
---|
| 8 | uniform vec4 lightColour; |
---|
| 9 | uniform vec4 shadowDepthRange; |
---|
| 10 | |
---|
| 11 | in vec4 position; |
---|
| 12 | in vec3 normal; |
---|
| 13 | in vec4 ambient; |
---|
| 14 | |
---|
| 15 | out vec4 shadowUV; |
---|
| 16 | out vec4 oColour; |
---|
| 17 | |
---|
| 18 | void main() |
---|
| 19 | { |
---|
| 20 | gl_Position = worldViewProj * position; |
---|
| 21 | vec4 worldPos = world * position; |
---|
| 22 | vec3 worldNorm = (worldIT * vec4(normal, 1)).xyz; |
---|
| 23 | |
---|
| 24 | // calculate lighting (simple vertex lighting) |
---|
| 25 | vec3 lightDir = normalize( |
---|
| 26 | lightPosition.xyz - (worldPos.xyz * lightPosition.w)); |
---|
| 27 | |
---|
| 28 | oColour = lightColour * max(dot(lightDir, worldNorm), 0.0); |
---|
| 29 | |
---|
| 30 | // calculate shadow map coords |
---|
| 31 | shadowUV = texViewProj * worldPos; |
---|
| 32 | #if LINEAR_RANGE |
---|
| 33 | // adjust by fixed depth bias, rescale into range |
---|
| 34 | // shadowUV.z = (shadowUV.z - shadowDepthRange.x) * shadowDepthRange.w; |
---|
| 35 | shadowUV.xy = shadowUV.xy / shadowUV.w; |
---|
| 36 | #else |
---|
| 37 | shadowUV = shadowUV / shadowUV.w; |
---|
| 38 | #endif |
---|
| 39 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.