|
|
@@ -7,26 +7,24 @@ attribute vec3 in_Normal; |
|
|
|
attribute vec4 in_Color; |
|
|
|
|
|
|
|
uniform mat4 in_ModelView; |
|
|
|
uniform mat4 in_Model; |
|
|
|
uniform mat4 in_View; |
|
|
|
uniform mat4 in_Proj; |
|
|
|
uniform mat3 in_NormalMat; |
|
|
|
|
|
|
|
varying vec4 pass_Eye; |
|
|
|
varying vec4 pass_Vertex; /* View space */ |
|
|
|
varying vec3 pass_TNormal; |
|
|
|
varying vec4 pass_TPos; |
|
|
|
varying vec4 pass_Color; |
|
|
|
|
|
|
|
void main(void) |
|
|
|
{ |
|
|
|
vec4 eye = in_ModelView * vec4(in_Vertex, 1.0); |
|
|
|
vec4 vertex = in_ModelView * vec4(in_Vertex, 1.0); |
|
|
|
vec3 tnorm = normalize(in_NormalMat * in_Normal); |
|
|
|
|
|
|
|
pass_Eye = eye; |
|
|
|
pass_Vertex = vertex; |
|
|
|
pass_TNormal = tnorm; |
|
|
|
pass_TPos = in_Model * vec4(in_Vertex, 1.0); |
|
|
|
pass_Color = in_Color; |
|
|
|
|
|
|
|
gl_Position = in_Proj * eye; |
|
|
|
gl_Position = in_Proj * vertex; |
|
|
|
} |
|
|
|
|
|
|
|
[frag.glsl] |
|
|
@@ -37,16 +35,15 @@ precision highp float; |
|
|
|
#endif |
|
|
|
|
|
|
|
uniform float in_Damage; |
|
|
|
uniform mat4 in_Model; |
|
|
|
uniform mat4 in_View; |
|
|
|
|
|
|
|
varying vec4 pass_Eye; |
|
|
|
varying vec4 pass_Vertex; /* View space */ |
|
|
|
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); |
|
|
|
vec4 in_Light2_Pos = in_Model * vec4(0.0, 0.0, 0.0, 1.0); |
|
|
|
vec4 in_Light2_Pos = vec4(-100.0, 100.0, -100.0, 1.0); |
|
|
|
|
|
|
|
void main(void) |
|
|
|
{ |
|
|
@@ -61,17 +58,17 @@ void main(void) |
|
|
|
vec3 specular_color = vec3(1.0, 1.0, 0.6); |
|
|
|
|
|
|
|
vec3 ambient = ambient_color; |
|
|
|
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 |
|
|
|
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); |
|
|
|
v = normalize(-pass_Vertex.xyz); |
|
|
|
r = reflect(-s, pass_TNormal); |
|
|
|
|
|
|
|
sdotn = max(dot(s, pass_TNormal), 0.0); |
|
|
@@ -79,11 +76,11 @@ void main(void) |
|
|
|
if (sdotn > 0.0) |
|
|
|
specular += specular_color * specular_reflect |
|
|
|
* pow(max(dot(r, v), 0.0), specular_power); |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
//Light calculation for point light |
|
|
|
s = normalize(pass_Eye.xyz - in_Light2_Pos.xyz); //(pass_TPos.xyz - in_Light2_Pos); |
|
|
|
v = normalize(-pass_Eye.xyz); |
|
|
|
//Light calculation for point light |
|
|
|
s = normalize((in_View * in_Light2_Pos).xyz - pass_Vertex.xyz); |
|
|
|
v = normalize(-pass_Vertex.xyz); |
|
|
|
r = reflect(-s, pass_TNormal); |
|
|
|
|
|
|
|
sdotn = max(dot(s, pass_TNormal), 0.0); |
|
|
@@ -106,10 +103,10 @@ 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_Model, |
|
|
|
uniform float4x4 in_Proj, |
|
|
|
uniform float3x3 in_NormalMat, |
|
|
|
out float4 pass_Eye : TEXCOORD0, |
|
|
|
out float4 pass_Vertex : TEXCOORD0, |
|
|
|
out float3 pass_TNormal : TEXCOORD1, |
|
|
|
out float4 pass_Color : COLOR, |
|
|
|
out float4 out_Position : POSITION) |
|
|
@@ -117,7 +114,7 @@ void main(float3 in_Vertex : POSITION, |
|
|
|
float4 eye = mul(in_ModelView, float4(in_Vertex, 1.0)); |
|
|
|
float3 tnorm = normalize(mul(in_NormalMat, in_Normal)); |
|
|
|
|
|
|
|
pass_Eye = eye; |
|
|
|
pass_Vertex = eye; |
|
|
|
pass_TNormal = tnorm; |
|
|
|
#ifdef _XBOX |
|
|
|
pass_Color = in_Color.abgr; |
|
|
@@ -130,7 +127,7 @@ void main(float3 in_Vertex : POSITION, |
|
|
|
|
|
|
|
[frag.hlsl] |
|
|
|
|
|
|
|
void main(float4 pass_Eye : TEXCOORD0, |
|
|
|
void main(float4 pass_Vertex : TEXCOORD0, |
|
|
|
float3 pass_TNormal : TEXCOORD1, |
|
|
|
float4 pass_Color : COLOR, |
|
|
|
uniform float in_Damage, |
|
|
@@ -148,8 +145,8 @@ void main(float4 pass_Eye : TEXCOORD0, |
|
|
|
float3 diffuse_color = float3(1.0, 1.0, 0.6); |
|
|
|
float3 specular_color = float3(1.0, 1.0, 0.6); |
|
|
|
|
|
|
|
float3 s = normalize(in_LightDir); /* normalize(pass_Eye - lightpos); */ |
|
|
|
float3 v = normalize(-pass_Eye.xyz); |
|
|
|
float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */ |
|
|
|
float3 v = normalize(-pass_Vertex.xyz); |
|
|
|
float3 r = reflect(-s, pass_TNormal); |
|
|
|
|
|
|
|
float3 ambient = ambient_color; |
|
|
|