PageRenderTime 457ms CodeModel.GetById 241ms app.highlight 1ms RepoModel.GetById 211ms app.codeStats 0ms

/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl

https://bitbucket.org/lindenlab/viewer-beta/
Unknown | 66 lines | 54 code | 12 blank | 0 comment | 0 complexity | 2b2aa9861d66456e675c01c49f87c73c MD5 | raw file
 1/** 
 2 * @file shinySimpleSkinnedV.glsl
 3 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
 4 * Second Life Viewer Source Code
 5 * Copyright (C) 2007, Linden Research, Inc.
 6 * 
 7 * This library is free software; you can redistribute it and/or
 8 * modify it under the terms of the GNU Lesser General Public
 9 * License as published by the Free Software Foundation;
10 * version 2.1 of the License only.
11 * 
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * Lesser General Public License for more details.
16 * 
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20 * 
21 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
22 * $/LicenseInfo$
23 */
24
25uniform mat4 projection_matrix;
26uniform mat4 texture_matrix0;
27uniform mat4 texture_matrix1;
28uniform mat4 modelview_matrix;
29
30ATTRIBUTE vec3 position;
31ATTRIBUTE vec3 normal;
32ATTRIBUTE vec4 diffuse_color;
33ATTRIBUTE vec2 texcoord0;
34
35VARYING vec4 vertex_color;
36VARYING vec2 vary_texcoord0;
37VARYING vec3 vary_texcoord1;
38
39vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
40void calcAtmospherics(vec3 inPositionEye);
41mat4 getObjectSkinnedTransform();
42
43void main()
44{
45	mat4 mat = getObjectSkinnedTransform();
46	
47	mat = modelview_matrix * mat;
48	vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
49	
50	vec4 norm = vec4(position.xyz, 1.0);
51	norm.xyz += normal.xyz;
52	norm.xyz = (mat*norm).xyz;
53	norm.xyz = normalize(norm.xyz-pos.xyz);
54		
55	vec3 ref = reflect(pos.xyz, -norm.xyz);
56
57	vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
58	vary_texcoord1 = (texture_matrix1*vec4(ref,1.0)).xyz;
59
60	calcAtmospherics(pos.xyz);
61
62	vec4 color = calcLighting(pos.xyz, norm.xyz, diffuse_color, vec4(0.));
63	vertex_color = color;
64	
65	gl_Position = projection_matrix*vec4(pos, 1.0);
66}