PageRenderTime 5ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl

https://bitbucket.org/lindenlab/viewer-beta/
text | 72 lines | 54 code | 18 blank | 0 comment | 0 complexity | 64e69ae13d27279531fbadca7a2d9dba MD5 | raw file
 1/**
 2 * @file terrainV.glsl
 3 *
 4 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
 5 * Second Life Viewer Source Code
 6 * Copyright (C) 2007, Linden Research, Inc.
 7 * 
 8 * This library is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation;
11 * version 2.1 of the License only.
12 * 
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * Lesser General Public License for more details.
17 * 
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 * 
22 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
23 * $/LicenseInfo$
24 */
25 
26
27
28void calcAtmospherics(vec3 inPositionEye);
29
30vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
31
32vec4 texgen_object(vec4  vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
33{
34	vec4 tcoord;
35	
36	tcoord.x = dot(vpos, tp0);
37	tcoord.y = dot(vpos, tp1);
38	tcoord.z = tc.z;
39	tcoord.w = tc.w;
40	
41	tcoord = mat * tcoord; 
42	
43	return tcoord; 
44}
45
46void main()
47{
48	//transform vertex
49	gl_Position = ftransform();
50
51	vec4 pos = gl_ModelViewMatrix * gl_Vertex;
52	vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
53
54	/// Potentially better without it for water.
55	pos /= pos.w;
56
57	calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz);
58
59	vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0));
60	
61	gl_FrontColor = color;
62
63	// Transform and pass tex coords
64 	gl_TexCoord[0].xy = texgen_object(gl_Vertex, gl_MultiTexCoord0, gl_TextureMatrix[0], gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy;
65	
66	vec4 t = gl_MultiTexCoord1;
67	
68	gl_TexCoord[0].zw = t.xy;
69	gl_TexCoord[1].xy = t.xy-vec2(2.0, 0.0);
70	gl_TexCoord[1].zw = t.xy-vec2(1.0, 0.0);
71}
72