Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL120/HWBasicInstancing.vert @ 12187

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

Changed folder structure, deletet some unused files and cleaned up code

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