Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSLES/HWBasicInstancing.vert @ 12091

Last change on this file since 12091 was 12091, checked in by wiesep, 6 years ago

Updated programs and adjusted Material to work with GLSL>150

File size: 1.6 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
6precision mediump int;
7precision mediump float;
8
9//Vertex input
10in vec4 vertex;
11in vec3 normal;
12in vec4 uv0;
13in vec4 uv1;
14in vec4 uv2;
15in vec4 uv3;
16in vec3 tangent;
17
18//Parameters
19uniform mat4 viewProjMatrix;
20
21#if (DEPTH_SHADOWCASTER || DEPTH_SHADOWRECEIVER)
22uniform vec4 depthRange;
23#endif
24
25#if DEPTH_SHADOWRECEIVER
26uniform 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//---------------------------------------------
42//Main Vertex Shader
43//---------------------------------------------
44void main(void)
45{
46        mat4 worldMatrix;
47        worldMatrix[0] = uv1;
48        worldMatrix[1] = uv2;
49        worldMatrix[2] = uv3;
50        worldMatrix[3] = vec4( 0, 0, 0, 1 );
51
52        vec4 worldPos           = vertex * worldMatrix;
53        vec3 worldNorm          = normal * mat3(worldMatrix);
54
55        //Transform the position
56        gl_Position                     = viewProjMatrix * worldPos;
57       
58#if DEPTH_SHADOWCASTER
59        depth.x                         = (gl_Position.z - depthRange.x) * depthRange.w;
60        depth.y                         = depthRange.w;
61#else
62        _uv0            = uv0.xy;
63        oNormal         = worldNorm;
64        oVPos           = worldPos.xyz;
65
66        #if DEPTH_SHADOWRECEIVER
67                oLightSpacePos          = texViewProjMatrix * worldPos;
68                oLightSpacePos.z        = (oLightSpacePos.z - depthRange.x) * depthRange.w;
69        #endif
70#endif
71}
Note: See TracBrowser for help on using the repository browser.