|
Last change
on this file since 12091 was
12091,
checked in by wiesep, 7 years ago
|
|
Updated programs and adjusted Material to work with GLSL>150
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | #version 100 |
|---|
| 2 | precision highp int; |
|---|
| 3 | precision highp float; |
|---|
| 4 | |
|---|
| 5 | uniform mat4 world; |
|---|
| 6 | uniform mat4 worldIT; |
|---|
| 7 | uniform mat4 worldViewProj; |
|---|
| 8 | uniform mat4 texViewProj; |
|---|
| 9 | uniform vec4 lightPosition; |
|---|
| 10 | uniform vec4 lightColour; |
|---|
| 11 | #if LINEAR_RANGE |
|---|
| 12 | uniform vec4 shadowDepthRange; |
|---|
| 13 | #endif |
|---|
| 14 | |
|---|
| 15 | attribute vec4 position; |
|---|
| 16 | attribute vec3 normal; |
|---|
| 17 | |
|---|
| 18 | varying vec4 shadowUV; |
|---|
| 19 | varying vec4 vColour; |
|---|
| 20 | |
|---|
| 21 | void main() |
|---|
| 22 | { |
|---|
| 23 | gl_Position = worldViewProj * position; |
|---|
| 24 | vec4 worldPos = world * position; |
|---|
| 25 | vec3 worldNorm = (worldIT * vec4(normal, 1.0)).xyz; |
|---|
| 26 | |
|---|
| 27 | vec4 lightPos = vec4(300.0, 750.0, -700.0, 1.0); |
|---|
| 28 | // Calculate lighting (simple vertex lighting) |
|---|
| 29 | vec3 lightDir = normalize(lightPos.xyz - (worldPos.xyz * lightPos.w)); |
|---|
| 30 | |
|---|
| 31 | vColour = vec4(0.590839, 0.36056, 0.13028, 1.0) * max(dot(lightDir, worldNorm), 0.0); |
|---|
| 32 | |
|---|
| 33 | // Calculate shadow map coords |
|---|
| 34 | shadowUV = texViewProj * worldPos; |
|---|
| 35 | #if LINEAR_RANGE |
|---|
| 36 | // Adjust by fixed depth bias, rescale into range |
|---|
| 37 | shadowUV.z = (shadowUV.z - shadowDepthRange.x) * shadowDepthRange.w; |
|---|
| 38 | shadowUV.xy = shadowUV.xy / shadowUV.w; |
|---|
| 39 | #else |
|---|
| 40 | shadowUV = shadowUV / shadowUV.w; |
|---|
| 41 | #endif |
|---|
| 42 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.