Changeset 2148


Ignore:
Timestamp:
Dec 18, 2012, 10:59:23 PM (10 years ago)
Author:
touky
Message:

the stupidest idea of the day : the cube light, specular still missing.

Location:
trunk
Files:
4 edited

Legend:

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

    r2145 r2148  
    6969    m_gpu.modelview = m_gpu.shader->GetUniformLocation("in_ModelView");
    7070    m_gpu.view = m_gpu.shader->GetUniformLocation("in_View");
     71        m_gpu.invview = m_gpu.shader->GetUniformLocation("in_Inv_View");
    7172    m_gpu.proj = m_gpu.shader->GetUniformLocation("in_Proj");
    7273    m_gpu.normalmat = m_gpu.shader->GetUniformLocation("in_NormalMat");
     
    120121    m_gpu.shader->SetUniform(m_gpu.modelview, modelview);
    121122    m_gpu.shader->SetUniform(m_gpu.view, Scene::GetDefault()->GetViewMatrix());
     123    m_gpu.shader->SetUniform(m_gpu.invview, inverse(Scene::GetDefault()->GetViewMatrix()));
    122124    m_gpu.shader->SetUniform(m_gpu.proj, Scene::GetDefault()->GetProjMatrix());
    123125    m_gpu.shader->SetUniform(m_gpu.normalmat, normalmat);
  • trunk/src/easymesh/easymesh.h

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

    r2146 r2148  
    3737uniform float in_Damage;
    3838uniform mat4 in_View;
     39uniform mat4 in_Inv_View;
    3940
    4041varying vec4 pass_Vertex; /* View space */
     
    4243varying vec4 pass_Color;
    4344
    44 // FIXME: the light direction should be passed in the code
     45// FIXME: all the light parameters should be passed in the code
     46//Dir Light
    4547vec3 in_LightDir = vec3(-0.3, -0.3, -0.7);
    46 vec4 in_Light2_Pos = vec4(0.0, 10.0, 0.0, 1.0);
     48
     49//Point Light
     50vec4 in_Light2_Pos = vec4(20.0, 10.0, 0.0, 1.0);
    4751float in_Light2_Radius = 20.0;
    4852vec3 in_Light2_diffuse = vec3(0.4, 0.4, 1.0);
     53
     54//Cube Light
     55vec4 in_Light3_Pos = vec4(-10.0, 10.0, 5.0, 1.0);
     56vec3 in_Light3_Size_Inner = vec3(1.0, 1.0, 1.0);
     57vec3 in_Light3_Size_Outer = vec3(10.0, 10.0, 10.0);
     58vec3 in_Light3_diffuse = vec3(0.4, 1.0, 0.4);
    4959
    5060void main(void)
     
    6777    vec3 r = vec3(0.0, 0.0, 0.0);
    6878    float sdotn = 0.0;
     79        float light_radius_mod = 0.0;
    6980
    7081    //Light calculation for directional light
     
    7889        specular += specular_color * specular_reflect
    7990                 * pow(max(dot(r, v), 0.0), specular_power);
    80 
     91        //----------
    8192   
    8293    //Light calculation for point light
    8394        vec3 tmpLightDir = (in_View * in_Light2_Pos).xyz - pass_Vertex.xyz;
    84         float light_radius_mod = max(0.0, 1.0 - (length(tmpLightDir) / in_Light2_Radius));
     95        light_radius_mod = max(0.0, 1.0 - (length(tmpLightDir) / in_Light2_Radius));
    8596    s = normalize(tmpLightDir);
    8697    v = normalize(-pass_Vertex.xyz);
     
    92103        specular += specular_color * min(specular_reflect, light_radius_mod)
    93104                 * pow(max(dot(r, v), 0.0), specular_power);
     105        //----------
    94106   
     107    //Light calculation for cube light
     108        vec3 Local_Vertex = (in_Inv_View * pass_Vertex).xyz - (in_Light3_Pos).xyz;
     109        vec3 Proj_Vertex = clamp(Local_Vertex.xyz, -in_Light3_Size_Inner, in_Light3_Size_Inner);
     110        vec3 new_LightDir = Local_Vertex - Proj_Vertex;
     111
     112        vec3 light_radius = max(vec3(0.0,0.0,0.0), vec3(1.0,1.0,1.0) - abs(new_LightDir / in_Light3_Size_Outer));
     113        light_radius_mod = min(light_radius.x, min(light_radius.y, light_radius.z));
     114
     115        if (length(new_LightDir) == 0.0)
     116                sdotn = 1.0;
     117        else
     118        {
     119                new_LightDir = (in_View * vec4(Proj_Vertex + in_Light3_Pos.xyz,1.0)).xyz - pass_Vertex.xyz;
     120                sdotn = max(dot(normalize(new_LightDir), pass_TNormal), 0.0);
     121        }
     122    diffuse += in_Light3_diffuse * min(sdotn, light_radius_mod);
     123        //----------
    95124
    96125    vec3 light = ambient + diffuse + specular;
  • trunk/test/Physics/Src/BulletCharacterController.cpp

    r1888 r2148  
    176176}
    177177
    178 //The PreStepis done in order to recover from any HasPenetration.
     178//The PreStep is done in order to recover from any HasPenetration.
    179179void BulletKinematicCharacterController::PreStep(btCollisionWorld* CollisionWorld)
    180180{
Note: See TracChangeset for help on using the changeset viewer.