Changeset 2145
 Timestamp:
 Dec 18, 2012, 4:07:02 PM (7 years ago)
 Location:
 trunk/src/easymesh
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/easymesh/easymesh.cpp
r2144 r2145 68 68 69 69 m_gpu.modelview = m_gpu.shader>GetUniformLocation("in_ModelView"); 70 m_gpu. model = m_gpu.shader>GetUniformLocation("in_Model");70 m_gpu.view = m_gpu.shader>GetUniformLocation("in_View"); 71 71 m_gpu.proj = m_gpu.shader>GetUniformLocation("in_Proj"); 72 72 m_gpu.normalmat = m_gpu.shader>GetUniformLocation("in_NormalMat"); … … 119 119 m_gpu.shader>Bind(); 120 120 m_gpu.shader>SetUniform(m_gpu.modelview, modelview); 121 m_gpu.shader>SetUniform(m_gpu. model, Scene::GetDefault()>GetViewMatrix());121 m_gpu.shader>SetUniform(m_gpu.view, Scene::GetDefault()>GetViewMatrix()); 122 122 m_gpu.shader>SetUniform(m_gpu.proj, Scene::GetDefault()>GetProjMatrix()); 123 123 m_gpu.shader>SetUniform(m_gpu.normalmat, normalmat); 
trunk/src/easymesh/easymesh.h
r2143 r2145 102 102 Shader *shader; 103 103 ShaderAttrib coord, norm, color; 104 ShaderUniform modelview, model, proj, normalmat, damage;104 ShaderUniform modelview, view, proj, normalmat, damage; 105 105 VertexDeclaration *vdecl; 106 106 VertexBuffer *vbo; 
trunk/src/easymesh/shiny.lolfx
r2144 r2145 8 8 9 9 uniform mat4 in_ModelView; 10 uniform mat4 in_ Model;10 uniform mat4 in_View; 11 11 uniform mat4 in_Proj; 12 12 uniform mat3 in_NormalMat; 13 13 14 varying vec4 pass_ Eye;14 varying vec4 pass_Vertex; /* View space */ 15 15 varying vec3 pass_TNormal; 16 varying vec4 pass_TPos;17 16 varying vec4 pass_Color; 18 17 19 18 void main(void) 20 19 { 21 vec4 eye= in_ModelView * vec4(in_Vertex, 1.0);20 vec4 vertex = in_ModelView * vec4(in_Vertex, 1.0); 22 21 vec3 tnorm = normalize(in_NormalMat * in_Normal); 23 22 24 pass_ Eye = eye;23 pass_Vertex = vertex; 25 24 pass_TNormal = tnorm; 26 pass_TPos = in_Model * vec4(in_Vertex, 1.0);27 25 pass_Color = in_Color; 28 26 29 gl_Position = in_Proj * eye;27 gl_Position = in_Proj * vertex; 30 28 } 31 29 … … 38 36 39 37 uniform float in_Damage; 40 uniform mat4 in_ Model;38 uniform mat4 in_View; 41 39 42 varying vec4 pass_ Eye;40 varying vec4 pass_Vertex; /* View space */ 43 41 varying vec3 pass_TNormal; 44 varying vec4 pass_TPos;45 42 varying vec4 pass_Color; 46 43 47 44 // FIXME: the light direction should be passed in the code 48 45 vec3 in_LightDir = vec3(0.3, 0.3, 0.7); 49 vec4 in_Light2_Pos = in_Model * vec4(0.0, 0.0,0.0, 1.0);46 vec4 in_Light2_Pos = vec4(100.0, 100.0, 100.0, 1.0); 50 47 51 48 void main(void) … … 62 59 63 60 vec3 ambient = ambient_color; 64 65 66 67 68 69 61 vec3 specular = vec3(0.0, 0.0, 0.0); 62 vec3 diffuse = vec3(0.0, 0.0, 0.0); 63 vec3 s = vec3(0.0, 0.0, 0.0); 64 vec3 v = vec3(0.0, 0.0, 0.0); 65 vec3 r = vec3(0.0, 0.0, 0.0); 66 float sdotn = 0.0; 70 67 71 72 68 /* 69 //Light calculation for directional light 73 70 s = normalize(in_LightDir); 74 v = normalize(pass_ Eye.xyz);71 v = normalize(pass_Vertex.xyz); 75 72 r = reflect(s, pass_TNormal); 76 73 … … 80 77 specular += specular_color * specular_reflect 81 78 * pow(max(dot(r, v), 0.0), specular_power); 82 79 */ 83 80 84 85 s = normalize( pass_Eye.xyz  in_Light2_Pos.xyz); //(pass_TPos.xyz  in_Light2_Pos);86 v = normalize(pass_ Eye.xyz);81 //Light calculation for point light 82 s = normalize((in_View * in_Light2_Pos).xyz  pass_Vertex.xyz); 83 v = normalize(pass_Vertex.xyz); 87 84 r = reflect(s, pass_TNormal); 88 85 … … 107 104 float4 in_Color : COLOR, 108 105 uniform float4x4 in_ModelView, 109 106 uniform float4x4 in_Model, 110 107 uniform float4x4 in_Proj, 111 108 uniform float3x3 in_NormalMat, 112 out float4 pass_ Eye: TEXCOORD0,109 out float4 pass_Vertex : TEXCOORD0, 113 110 out float3 pass_TNormal : TEXCOORD1, 114 111 out float4 pass_Color : COLOR, … … 118 115 float3 tnorm = normalize(mul(in_NormalMat, in_Normal)); 119 116 120 pass_ Eye= eye;117 pass_Vertex = eye; 121 118 pass_TNormal = tnorm; 122 119 #ifdef _XBOX … … 131 128 [frag.hlsl] 132 129 133 void main(float4 pass_ Eye: TEXCOORD0,130 void main(float4 pass_Vertex : TEXCOORD0, 134 131 float3 pass_TNormal : TEXCOORD1, 135 132 float4 pass_Color : COLOR, … … 149 146 float3 specular_color = float3(1.0, 1.0, 0.6); 150 147 151 float3 s = normalize(in_LightDir); /* normalize(pass_ Eye lightpos); */152 float3 v = normalize(pass_ Eye.xyz);148 float3 s = normalize(in_LightDir); /* normalize(pass_Vertex  lightpos); */ 149 float3 v = normalize(pass_Vertex.xyz); 153 150 float3 r = reflect(s, pass_TNormal); 154 151
Note: See TracChangeset
for help on using the changeset viewer.