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

Last change on this file since 2379 was 2379, checked in by touky, 7 years ago

Added VertexDictionnary object to manage vertices with same coord && connected vertices.
Added UVs system with and UVs generation test (not very conclusive)

File size: 3.1 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    gl_FragColor = vec4(mod(pass_TexCoord.x, 1.0f), 0.2, mod(pass_TexCoord.y, 1.0), 1.0) * length(normalize(pass_Color.xyz)) * length(normalize(pass_TNormal));
54}
55
56[vert.hlsl]
57
58void main(float3 in_Vertex : POSITION,
59          float3 in_Normal : NORMAL,
60          float4 in_Color : COLOR,
61          uniform float4x4 in_ModelView,
62          uniform float4x4 in_Model,
63          uniform float4x4 in_Proj,
64          uniform float3x3 in_NormalMat,
65          out float4 pass_Vertex : TEXCOORD0,
66          out float3 pass_TNormal : TEXCOORD1,
67          out float4 pass_Color : COLOR,
68          out float4 out_Position : POSITION)
69{
70    float4 eye = mul(in_ModelView, float4(in_Vertex, 1.0));
71    float3 tnorm = normalize(mul(in_NormalMat, in_Normal));
72
73    pass_Vertex = eye;
74    pass_TNormal = tnorm;
75#ifdef _XBOX
76    pass_Color = in_Color.abgr;
77#else
78    pass_Color = in_Color;
79#endif
80
81    out_Position = mul(in_Proj, eye);
82}
83
84[frag.hlsl]
85
86void main(float4 pass_Vertex : TEXCOORD0,
87          float3 pass_TNormal : TEXCOORD1,
88          float4 pass_Color : COLOR,
89          uniform float in_Damage,
90          out float4 out_FragColor : COLOR)
91{
92    float3 in_LightDir = float3(0.3, 0.3, 0.7);
93
94    /* Material properties */
95    float3 specular_reflect = float3(0.8, 0.75, 0.4);
96    float specular_power = 60.0;
97
98    /* World properties */
99    float ambient_mul = 0.5;
100    float3 ambient_color = float3(0.25, 0.2, 0.35);
101    float3 diffuse_color = float3(1.0, 1.0, 0.6);
102    float3 specular_color = float3(1.0, 1.0, 0.6);
103
104    float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */
105    float3 v = normalize(-pass_Vertex.xyz);
106    float3 r = reflect(-s, pass_TNormal);
107
108    float3 ambient = ambient_color;
109    float sdotn = max(dot(s, pass_TNormal), 0.0);
110    float3 diffuse = diffuse_color * sdotn;
111    float3 specular = float3(0.0, 0.0, 0.0);
112    if (sdotn > 0.0)
113        specular = specular_color * specular_reflect
114                 * pow(max(dot(r, v), 0.0), specular_power);
115    float3 light = ambient + diffuse + specular;
116
117    float4 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0)
118                      + (1.0 - in_Damage) * pass_Color;
119    out_FragColor = real_color * float4(light, 1.0);
120}
121
Note: See TracBrowser for help on using the repository browser.