source: trunk/src/easymesh/shinydebugUV.lolfx @ 2408

Last change on this file since 2408 was 2408, checked in by lolbot, 7 years ago

fixed 3 files out of 2468:

  • removed 43 CR characters
  • removed 25 trailing whitespaces
  • replaced 0 tabs with spaces
File size: 4.3 KB
Line 
1
2[vert.glsl]
3#version 120
4
5attribute vec3 in_Vertex;
6attribute vec3 in_Normal;
7attribute vec4 in_Color;
8attribute vec2 in_TexCoord;
9
10uniform mat4 in_ModelView;
11uniform mat4 in_View;
12uniform mat4 in_Proj;
13uniform mat3 in_NormalMat;
14
15varying vec4 pass_Vertex; /* View space */
16varying vec3 pass_TNormal;
17varying vec4 pass_Color;
18varying vec2 pass_TexCoord;
19
20void main(void)
21{
22    vec4 vertex = in_ModelView * vec4(in_Vertex, 1.0);
23    vec3 tnorm = normalize(in_NormalMat * in_Normal);
24
25    pass_Vertex = vertex;
26    pass_TNormal = tnorm;
27    pass_Color = in_Color;
28    pass_TexCoord = in_TexCoord;
29
30    gl_Position = in_Proj * vertex;
31}
32
33[frag.glsl]
34#version 120
35
36#if defined GL_ES
37precision highp float;
38#endif
39
40uniform float in_Damage;
41uniform mat4 in_View;
42uniform mat4 in_Inv_View;
43
44uniform vec4 u_Lights[8 * 2];
45
46varying vec4 pass_Vertex; /* View space */
47varying vec3 pass_TNormal;
48varying vec4 pass_Color;
49varying vec2 pass_TexCoord;
50
51void main(void)
52{
53    float mode = 0.0;
54    if (mode == 0.0)
55    {
56        gl_FragColor = vec4(mod(pass_TexCoord.x, 1.0f),
57                            0.1,
58                            mod(pass_TexCoord.y, 1.0), 1.0);
59    }
60    else
61    {
62        float col = ((mod(mode, 2.0) == 1)?(mod(pass_TexCoord.x, 1.0)):(mod(pass_TexCoord.y, 1.0)));
63        if (mode == 1 || mode == 2)
64        {
65            if (col > 1.0/3.0) gl_FragColor.r = 0.0;
66            else gl_FragColor.r = min(col, 1.0/3.0);
67            if (col > 2.0/3.0) gl_FragColor.g = 0.0;
68            else gl_FragColor.g = min(max(col, 1.0/3.0) - 1.0/3.0, 1.0/3.0);
69            gl_FragColor.b = min(max(col, 2.0/3.0) - 2.0/3.0, 1.0/3.0);
70        }
71        else if (mode == 3 || mode == 4)
72        {
73            if (col > 0.5) gl_FragColor.r = 0.0;
74            else gl_FragColor.r = min(col, 0.5);
75            gl_FragColor.g = min(max(col, 0.5) - 0.5, 0.5);
76            gl_FragColor.b = 0.1;
77        }
78        else if (mode == 5 || mode == 6)
79        {
80            gl_FragColor.r = col;
81            gl_FragColor.g = 0.1;
82            gl_FragColor.b = 0.1;
83        }
84    }
85
86    gl_FragColor.a = 1.0;
87    gl_FragColor *=
88                 //= pass_Color *
89                    length(normalize(pass_TexCoord)) *
90                    length(normalize(pass_Color.xyz)) *
91                    length(normalize(pass_TNormal));
92}
93
94[vert.hlsl]
95
96void main(float3 in_Vertex : POSITION,
97          float3 in_Normal : NORMAL,
98          float4 in_Color : COLOR,
99          uniform float4x4 in_ModelView,
100          uniform float4x4 in_Model,
101          uniform float4x4 in_Proj,
102          uniform float3x3 in_NormalMat,
103          out float4 pass_Vertex : TEXCOORD0,
104          out float3 pass_TNormal : TEXCOORD1,
105          out float4 pass_Color : COLOR,
106          out float4 out_Position : POSITION)
107{
108    float4 eye = mul(in_ModelView, float4(in_Vertex, 1.0));
109    float3 tnorm = normalize(mul(in_NormalMat, in_Normal));
110
111    pass_Vertex = eye;
112    pass_TNormal = tnorm;
113#ifdef _XBOX
114    pass_Color = in_Color.abgr;
115#else
116    pass_Color = in_Color;
117#endif
118
119    out_Position = mul(in_Proj, eye);
120}
121
122[frag.hlsl]
123
124void main(float4 pass_Vertex : TEXCOORD0,
125          float3 pass_TNormal : TEXCOORD1,
126          float4 pass_Color : COLOR,
127          uniform float in_Damage,
128          out float4 out_FragColor : COLOR)
129{
130    float3 in_LightDir = float3(0.3, 0.3, 0.7);
131
132    /* Material properties */
133    float3 specular_reflect = float3(0.8, 0.75, 0.4);
134    float specular_power = 60.0;
135
136    /* World properties */
137    float ambient_mul = 0.5;
138    float3 ambient_color = float3(0.25, 0.2, 0.35);
139    float3 diffuse_color = float3(1.0, 1.0, 0.6);
140    float3 specular_color = float3(1.0, 1.0, 0.6);
141
142    float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */
143    float3 v = normalize(-pass_Vertex.xyz);
144    float3 r = reflect(-s, pass_TNormal);
145
146    float3 ambient = ambient_color;
147    float sdotn = max(dot(s, pass_TNormal), 0.0);
148    float3 diffuse = diffuse_color * sdotn;
149    float3 specular = float3(0.0, 0.0, 0.0);
150    if (sdotn > 0.0)
151        specular = specular_color * specular_reflect
152                 * pow(max(dot(r, v), 0.0), specular_power);
153    float3 light = ambient + diffuse + specular;
154
155    float4 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0)
156                      + (1.0 - in_Damage) * pass_Color;
157    out_FragColor = real_color * float4(light, 1.0);
158}
159
Note: See TracBrowser for help on using the repository browser.