Changeset 2143


Ignore:
Timestamp:
Dec 18, 2012, 2:58:04 PM (7 years ago)
Author:
touky
Message:

first commit in a while, small test in ShinyLol

Location:
trunk/src/easymesh
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/easymesh/easymesh.cpp

    r2116 r2143  
    6868
    6969    m_gpu.modelview = m_gpu.shader->GetUniformLocation("in_ModelView");
     70    m_gpu.model = m_gpu.shader->GetUniformLocation("in_Model");
    7071    m_gpu.proj = m_gpu.shader->GetUniformLocation("in_Proj");
    7172    m_gpu.normalmat = m_gpu.shader->GetUniformLocation("in_NormalMat");
     
    118119    m_gpu.shader->Bind();
    119120    m_gpu.shader->SetUniform(m_gpu.modelview, modelview);
     121    m_gpu.shader->SetUniform(m_gpu.model, model);
    120122    m_gpu.shader->SetUniform(m_gpu.proj, Scene::GetDefault()->GetProjMatrix());
    121123    m_gpu.shader->SetUniform(m_gpu.normalmat, normalmat);
  • trunk/src/easymesh/easymesh.h

    r2116 r2143  
    102102        Shader *shader;
    103103        ShaderAttrib coord, norm, color;
    104         ShaderUniform modelview, proj, normalmat, damage;
     104        ShaderUniform modelview, model, proj, normalmat, damage;
    105105        VertexDeclaration *vdecl;
    106106        VertexBuffer *vbo;
  • trunk/src/easymesh/shiny.lolfx

    r1928 r2143  
    88
    99uniform mat4 in_ModelView;
     10uniform mat4 in_Model;
    1011uniform mat4 in_Proj;
    1112uniform mat3 in_NormalMat;
     
    1314varying vec4 pass_Eye;
    1415varying vec3 pass_TNormal;
     16varying vec4 pass_TPos;
    1517varying vec4 pass_Color;
    1618
     
    2224    pass_Eye = eye;
    2325    pass_TNormal = tnorm;
     26        pass_TPos = in_Model * vec4(in_Vertex, 1.0);
    2427    pass_Color = in_Color;
    2528
     
    3841varying vec4 pass_Eye;
    3942varying vec3 pass_TNormal;
     43varying vec4 pass_TPos;
    4044varying vec4 pass_Color;
    4145
    4246// FIXME: the light direction should be passed in the code
    4347vec3 in_LightDir = vec3(0.3, 0.3, 0.7);
     48vec3 in_Light2_Pos = vec3(0.0, 100.0, 0.0);
    4449
    4550void main(void)
     
    5156    /* World properties */
    5257    float ambient_mul = 0.5;
    53     vec3 ambient_color = vec3(0.25, 0.2, 0.35);
     58    vec3 ambient_color = vec3(0.0, 0.0, 0.0);
    5459    vec3 diffuse_color = vec3(1.0, 1.0, 0.6);
    5560    vec3 specular_color = vec3(1.0, 1.0, 0.6);
    5661
    57     vec3 s = normalize(in_LightDir); /* normalize(pass_Eye - lightpos); */
    58     vec3 v = normalize(-pass_Eye.xyz);
    59     vec3 r = reflect(-s, pass_TNormal);
     62    vec3 ambient = ambient_color;
     63        vec3 specular = vec3(0.0, 0.0, 0.0);
     64        vec3 diffuse = vec3(0.0, 0.0, 0.0);
     65        vec3 s = vec3(0.0, 0.0, 0.0);
     66        vec3 v = vec3(0.0, 0.0, 0.0);
     67        vec3 r = vec3(0.0, 0.0, 0.0);
     68        float sdotn = 0.0;
    6069
    61     vec3 ambient = ambient_color;
    62     float sdotn = max(dot(s, pass_TNormal), 0.0);
    63     vec3 diffuse = diffuse_color * sdotn;
    64     vec3 specular = vec3(0.0, 0.0, 0.0);
     70        /*
     71        //Light calculation for directional light
     72    s = normalize(in_LightDir);
     73    v = normalize(-pass_Eye.xyz);
     74    r = reflect(-s, pass_TNormal);
     75
     76    sdotn = max(dot(s, pass_TNormal), 0.0);
     77    diffuse += diffuse_color * sdotn;
    6578    if (sdotn > 0.0)
    66         specular = specular_color * specular_reflect
     79        specular += specular_color * specular_reflect
    6780                 * pow(max(dot(r, v), 0.0), specular_power);
     81        */
     82
     83        //Light calculation for point light
     84    s = normalize(pass_TPos.xyz - in_Light2_Pos);
     85    v = normalize(-pass_Eye.xyz);
     86    r = reflect(-s, pass_TNormal);
     87
     88    sdotn = max(dot(s, pass_TNormal), 0.0);
     89    diffuse += diffuse_color * sdotn;
     90    //if (sdotn > 0.0)
     91    //    specular += specular_color * specular_reflect
     92    //             * pow(max(dot(r, v), 0.0), specular_power);
     93
     94
    6895    vec3 light = ambient + diffuse + specular;
    6996
     
    79106          float4 in_Color : COLOR,
    80107          uniform float4x4 in_ModelView,
     108                  uniform float4x4 in_Model,
    81109          uniform float4x4 in_Proj,
    82110          uniform float3x3 in_NormalMat,
Note: See TracChangeset for help on using the changeset viewer.