source: trunk/orbital/shiny.lolfx @ 1392

Last change on this file since 1392 was 1392, checked in by sam, 10 years ago

misc: move more shaders to .lolfx files.

File size: 3.1 KB
Line 
1
2-- GLSL.Vert --
3
4#version 120
5
6attribute vec3 in_Vertex;
7attribute vec3 in_Normal;
8attribute vec4 in_Color;
9uniform mat4 in_ModelView;
10uniform mat4 in_Proj;
11uniform mat3 in_NormalMat;
12uniform float in_Damage;
13varying vec4 pass_Color;
14
15void main(void)
16{
17    /* Material properties */
18    vec3 specular_reflect = vec3(0.8, 0.75, 0.4);
19    float specular_power = 60.f;
20
21    /* World properties */
22    float ambient_mul = 0.5f;
23    vec3 light_dir = normalize(vec3(0.3, 0.3, 0.7));
24    vec3 ambient_color = vec3(0.25, 0.2, 0.35);
25    vec3 diffuse_color = vec3(1.0, 1.0, 0.6);
26    vec3 specular_color = vec3(1.0, 1.0, 0.6);
27
28    vec3 tnorm = normalize(in_NormalMat * in_Normal);
29    vec4 eye = in_ModelView * vec4(in_Vertex, 1.0);
30
31    vec3 s = light_dir; /* normalize(eye - lightpos); */
32    vec3 v = normalize(-eye.xyz);
33    vec3 r = reflect(-s, tnorm);
34
35    vec3 ambient = ambient_color;
36    float sdotn = max(dot(s, tnorm), 0.0);
37    vec3 diffuse = diffuse_color * sdotn;
38    vec3 specular = vec3(0.0, 0.0, 0.0);
39    if (sdotn > 0.0)
40        specular = specular_color * specular_reflect
41                 * pow(max(dot(r, v), 0.0), specular_power);
42    vec3 light = ambient + diffuse + specular;
43
44    vec4 real_color = in_Damage * vec4(1.2, 1.2, 1.2, 1.0)
45                    + (1.0 - in_Damage) * in_Color;
46    pass_Color = real_color * vec4(light, 1.0);
47    gl_Position = in_Proj * eye;
48}
49
50-- GLSL.Frag --
51
52#version 120
53
54varying vec4 pass_Color;
55
56void main(void) {
57    gl_FragColor = pass_Color;
58}
59
60-- HLSL.Vert --
61
62void main(float3 in_Vertex : POSITION,
63          float3 in_Normal : NORMAL,
64          float4 in_Color : COLOR,
65          uniform float4x4 in_ModelView,
66          uniform float4x4 in_Proj,
67          uniform float3x3 in_NormalMat,
68          uniform float in_Damage,
69          out float4 out_Position : POSITION,
70          out float4 pass_Color : COLOR)
71{
72    float3 specular_reflect = float3(0.8, 0.75, 0.4);
73    float specular_power = 60.f;
74    float ambient_mul = 0.5f;
75    float3 light_dir = normalize(float3(0.3, 0.3, 0.7));
76    float3 ambient_color = float3(0.25, 0.2, 0.35);
77    float3 diffuse_color = float3(1.0, 1.0, 0.6);
78    float3 specular_color = float3(1.0, 1.0, 0.6);
79    float3 tnorm = normalize(mul(in_NormalMat, in_Normal));
80    float4 eye = mul(in_ModelView, float4(in_Vertex, 1.0));
81    float3 s = light_dir;
82    float3 v = normalize(-eye.xyz);
83    float3 r = reflect(-s, tnorm);
84    float3 ambient = ambient_color;
85    float sdotn = max(dot(s, tnorm), 0.0);
86    float3 diffuse = diffuse_color * sdotn;
87    float3 specular = float3(0.0, 0.0, 0.0);
88    if (sdotn > 0.0)
89        specular = specular_color * specular_reflect
90                 * pow(max(dot(r, v), 0.0), specular_power);
91    float3 light = ambient + diffuse + specular;
92#ifdef _XBOX
93    float4 real_color = in_Color.abgr;
94#else
95    float4 real_color = in_Color;
96#endif
97    real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0)
98               + (1.0 - in_Damage) * real_color;
99    pass_Color = real_color * float4(light, 1.0);
100    out_Position = mul(in_Proj, eye);
101}
102
103-- HLSL.Frag --
104
105void main(float4 pass_Color : COLOR,
106          out float4 out_FragColor : COLOR)
107{
108    out_FragColor = pass_Color;
109}
110
Note: See TracBrowser for help on using the repository browser.