Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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
6precision mediump int;
7precision mediump float;
8
9//Vertex input
10in vec4 vertex;
11in vec3 normal;
12in vec3 tangent;
13in vec4 uv0;
14in vec4 blendIndices;
15in vec4 blendWeights;
16
17//Parameters
18uniform mat4 viewProjMatrix;
19uniform mat4 worldMatrix;
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//Main Vertex Shader
42//---------------------------------------------
43void 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.