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.5 KB
|
Line | |
---|
1 | //--------------------------------------------------------------------------- |
---|
2 | //These materials/shaders are part of the NEW InstanceManager implementation |
---|
3 | //Written by Matias N. Goldberg ("dark_sylinc") |
---|
4 | //--------------------------------------------------------------------------- |
---|
5 | #version 300 es |
---|
6 | precision mediump int; |
---|
7 | precision mediump float; |
---|
8 | |
---|
9 | //Vertex input |
---|
10 | in vec4 vertex; |
---|
11 | in vec3 normal; |
---|
12 | in vec3 tangent; |
---|
13 | in vec4 uv0; |
---|
14 | in vec4 blendIndices; |
---|
15 | in vec4 blendWeights; |
---|
16 | |
---|
17 | //Parameters |
---|
18 | uniform mat4 viewProjMatrix; |
---|
19 | uniform mat4 worldMatrix; |
---|
20 | |
---|
21 | #if (DEPTH_SHADOWCASTER || DEPTH_SHADOWRECEIVER) |
---|
22 | uniform vec4 depthRange; |
---|
23 | #endif |
---|
24 | |
---|
25 | #if DEPTH_SHADOWRECEIVER |
---|
26 | uniform mat4 texViewProjMatrix; |
---|
27 | #endif |
---|
28 | |
---|
29 | //Output |
---|
30 | #if DEPTH_SHADOWCASTER |
---|
31 | out vec2 depth; |
---|
32 | #else |
---|
33 | out vec2 _uv0; |
---|
34 | out vec3 oNormal; |
---|
35 | out vec3 oVPos; |
---|
36 | #if DEPTH_SHADOWRECEIVER |
---|
37 | out vec4 oLightSpacePos; |
---|
38 | #endif |
---|
39 | #endif |
---|
40 | //--------------------------------------------- |
---|
41 | //Main Vertex Shader |
---|
42 | //--------------------------------------------- |
---|
43 | void main(void) |
---|
44 | { |
---|
45 | vec4 worldPos = vertex * worldMatrix; |
---|
46 | vec3 worldNorm = normal * mat3(worldMatrix); |
---|
47 | |
---|
48 | //Transform the position |
---|
49 | gl_Position = viewProjMatrix * worldPos; |
---|
50 | |
---|
51 | #if DEPTH_SHADOWCASTER |
---|
52 | depth.x = (gl_Position.z - depthRange.x) * depthRange.w; |
---|
53 | depth.y = depthRange.w; |
---|
54 | #else |
---|
55 | _uv0 = uv0.xy; |
---|
56 | oNormal = worldNorm; |
---|
57 | oVPos = worldPos.xyz; |
---|
58 | |
---|
59 | #if DEPTH_SHADOWRECEIVER |
---|
60 | oLightSpacePos = texViewProjMatrix * worldPos; |
---|
61 | oLightSpacePos.z = (oLightSpacePos.z - depthRange.x) * depthRange.w; |
---|
62 | #endif |
---|
63 | #endif |
---|
64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.