|
|
@@ -7,11 +7,13 @@ attribute vec3 in_Normal; |
|
|
|
attribute vec4 in_Color; |
|
|
|
|
|
|
|
uniform mat4 in_ModelView; |
|
|
|
uniform mat4 in_Model; |
|
|
|
uniform mat4 in_Proj; |
|
|
|
uniform mat3 in_NormalMat; |
|
|
|
|
|
|
|
varying vec4 pass_Eye; |
|
|
|
varying vec3 pass_TNormal; |
|
|
|
varying vec4 pass_TPos; |
|
|
|
varying vec4 pass_Color; |
|
|
|
|
|
|
|
void main(void) |
|
|
@@ -21,6 +23,7 @@ void main(void) |
|
|
|
|
|
|
|
pass_Eye = eye; |
|
|
|
pass_TNormal = tnorm; |
|
|
|
pass_TPos = in_Model * vec4(in_Vertex, 1.0); |
|
|
|
pass_Color = in_Color; |
|
|
|
|
|
|
|
gl_Position = in_Proj * eye; |
|
|
@@ -37,10 +40,12 @@ uniform float in_Damage; |
|
|
|
|
|
|
|
varying vec4 pass_Eye; |
|
|
|
varying vec3 pass_TNormal; |
|
|
|
varying vec4 pass_TPos; |
|
|
|
varying vec4 pass_Color; |
|
|
|
|
|
|
|
// FIXME: the light direction should be passed in the code |
|
|
|
vec3 in_LightDir = vec3(0.3, 0.3, 0.7); |
|
|
|
vec3 in_Light2_Pos = vec3(0.0, 100.0, 0.0); |
|
|
|
|
|
|
|
void main(void) |
|
|
|
{ |
|
|
@@ -50,21 +55,43 @@ void main(void) |
|
|
|
|
|
|
|
/* World properties */ |
|
|
|
float ambient_mul = 0.5; |
|
|
|
vec3 ambient_color = vec3(0.25, 0.2, 0.35); |
|
|
|
vec3 ambient_color = vec3(0.0, 0.0, 0.0); |
|
|
|
vec3 diffuse_color = vec3(1.0, 1.0, 0.6); |
|
|
|
vec3 specular_color = vec3(1.0, 1.0, 0.6); |
|
|
|
|
|
|
|
vec3 s = normalize(in_LightDir); /* normalize(pass_Eye - lightpos); */ |
|
|
|
vec3 v = normalize(-pass_Eye.xyz); |
|
|
|
vec3 r = reflect(-s, pass_TNormal); |
|
|
|
|
|
|
|
vec3 ambient = ambient_color; |
|
|
|
float sdotn = max(dot(s, pass_TNormal), 0.0); |
|
|
|
vec3 diffuse = diffuse_color * sdotn; |
|
|
|
vec3 specular = vec3(0.0, 0.0, 0.0); |
|
|
|
vec3 specular = vec3(0.0, 0.0, 0.0); |
|
|
|
vec3 diffuse = vec3(0.0, 0.0, 0.0); |
|
|
|
vec3 s = vec3(0.0, 0.0, 0.0); |
|
|
|
vec3 v = vec3(0.0, 0.0, 0.0); |
|
|
|
vec3 r = vec3(0.0, 0.0, 0.0); |
|
|
|
float sdotn = 0.0; |
|
|
|
|
|
|
|
/* |
|
|
|
//Light calculation for directional light |
|
|
|
s = normalize(in_LightDir); |
|
|
|
v = normalize(-pass_Eye.xyz); |
|
|
|
r = reflect(-s, pass_TNormal); |
|
|
|
|
|
|
|
sdotn = max(dot(s, pass_TNormal), 0.0); |
|
|
|
diffuse += diffuse_color * sdotn; |
|
|
|
if (sdotn > 0.0) |
|
|
|
specular = specular_color * specular_reflect |
|
|
|
specular += specular_color * specular_reflect |
|
|
|
* pow(max(dot(r, v), 0.0), specular_power); |
|
|
|
*/ |
|
|
|
|
|
|
|
//Light calculation for point light |
|
|
|
s = normalize(pass_TPos.xyz - in_Light2_Pos); |
|
|
|
v = normalize(-pass_Eye.xyz); |
|
|
|
r = reflect(-s, pass_TNormal); |
|
|
|
|
|
|
|
sdotn = max(dot(s, pass_TNormal), 0.0); |
|
|
|
diffuse += diffuse_color * sdotn; |
|
|
|
//if (sdotn > 0.0) |
|
|
|
// specular += specular_color * specular_reflect |
|
|
|
// * pow(max(dot(r, v), 0.0), specular_power); |
|
|
|
|
|
|
|
|
|
|
|
vec3 light = ambient + diffuse + specular; |
|
|
|
|
|
|
|
vec4 real_color = in_Damage * vec4(1.2, 1.2, 1.2, 1.0) |
|
|
@@ -78,6 +105,7 @@ void main(float3 in_Vertex : POSITION, |
|
|
|
float3 in_Normal : NORMAL, |
|
|
|
float4 in_Color : COLOR, |
|
|
|
uniform float4x4 in_ModelView, |
|
|
|
uniform float4x4 in_Model, |
|
|
|
uniform float4x4 in_Proj, |
|
|
|
uniform float3x3 in_NormalMat, |
|
|
|
out float4 pass_Eye : TEXCOORD0, |
|
|
|