Ejemplo n.º 1
0
    void RenderAmbientLight()
    {       
     	glEnable(GL_BLEND);
		glBlendEquation(GL_FUNC_ADD);
		glBlendFunc(GL_ONE, GL_ONE);
                                            
        m_LightingTech.Enable();

        m_pointLight.AmbientIntensity = 0.2f;
        m_pointLight.DiffuseIntensity = 0.0f;

        m_LightingTech.SetPointLights(1, &m_pointLight);
                             
        Pipeline p;
        p.SetPerspectiveProj(m_persProjInfo);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        
        m_boxOrientation.m_rotation = Vector3f(0, m_scale, 0);
        p.Orient(m_boxOrientation);
        m_LightingTech.SetWVP(p.GetWVPTrans());
        m_LightingTech.SetWorldMatrix(p.GetWorldTrans());        
        m_box.Render();
       
        p.Orient(m_quadOrientation);
        m_LightingTech.SetWVP(p.GetWVPTrans());
        m_LightingTech.SetWorldMatrix(p.GetWorldTrans());
        m_pGroundTex->Bind(COLOR_TEXTURE_UNIT);        
        m_quad.Render();        
        
        glDisable(GL_BLEND);
    }        
Ejemplo n.º 2
0
    void RenderShadowedScene()
    {
        glDrawBuffer(GL_BACK);
                                          
        // Draw only if the corresponding stencil value is zero
        glStencilFunc(GL_EQUAL, 0x0, 0xFF);
        
        // prevent update to the stencil buffer
        glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
                
        m_LightingTech.Enable();
        
        m_pointLight.AmbientIntensity = 0.0f;
        m_pointLight.DiffuseIntensity = 0.8f;

        m_LightingTech.SetPointLights(1, &m_pointLight);
                                     
        Pipeline p;
        p.SetPerspectiveProj(m_persProjInfo);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());        
        
        m_boxOrientation.m_rotation = Vector3f(0, m_scale, 0);
        p.Orient(m_boxOrientation);
        m_LightingTech.SetWVP(p.GetWVPTrans());
        m_LightingTech.SetWorldMatrix(p.GetWorldTrans());        
        m_box.Render();

        p.Orient(m_quadOrientation);
        m_LightingTech.SetWVP(p.GetWVPTrans());
        m_LightingTech.SetWorldMatrix(p.GetWorldTrans());        
        m_pGroundTex->Bind(COLOR_TEXTURE_UNIT);
        m_quad.Render();        
    }    
Ejemplo n.º 3
0
 void ShadowMapPass()
 {
     glCullFace(GL_FRONT);
     
     m_shadowMapEffect.Enable();
     
     PersProjInfo ProjInfo;
     ProjInfo.FOV = 90.0f;
     ProjInfo.Height = WINDOW_HEIGHT;
     ProjInfo.Width = WINDOW_WIDTH;
     ProjInfo.zNear = 1.0f;
     ProjInfo.zFar = 100.0f;  
     
     Pipeline p;
     p.SetPerspectiveProj(m_persProjInfo);                           
     
     glClearColor(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX);
     
     for (uint i = 0 ; i < NUM_OF_LAYERS ; i++) {
         m_shadowMapFBO.BindForWriting(gCameraDirections[i].CubemapFace);
         glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);                       
                 
         p.SetCamera(m_pointLight.Position, gCameraDirections[i].Target, gCameraDirections[i].Up);
         
         p.Orient(m_mesh1Orientation);
         m_shadowMapEffect.SetWorld(p.GetWorldTrans());
         m_shadowMapEffect.SetWVP(p.GetWVPTrans());
         m_mesh.Render();
 
         p.Orient(m_mesh2Orientation);
         m_shadowMapEffect.SetWorld(p.GetWorldTrans());
         m_shadowMapEffect.SetWVP(p.GetWVPTrans());
         m_mesh.Render();
     }        
 }
Ejemplo n.º 4
0
    void RenderShadowVolIntoStencil()
    {
        glDepthMask(GL_FALSE);
        glEnable(GL_DEPTH_CLAMP);        
        glDisable(GL_CULL_FACE);
                    
		// We need the stencil test to be enabled but we want it
		// to succeed always. Only the depth test matters.
		glStencilFunc(GL_ALWAYS, 0, 0xff);

        glStencilOpSeparate(GL_BACK, GL_KEEP, GL_INCR_WRAP, GL_KEEP);
        glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_DECR_WRAP, GL_KEEP);       
		        
        m_ShadowVolTech.Enable();

        m_ShadowVolTech.SetLightPos(m_pointLight.Position);
             
        // Render the occluder
        Pipeline p;
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());        
        p.SetPerspectiveProj(m_persProjInfo);                       
        m_boxOrientation.m_rotation = Vector3f(0, m_scale, 0);
        p.Orient(m_boxOrientation);
        m_ShadowVolTech.SetWVP(p.GetWVPTrans());        
        m_box.Render();        
        
        // Restore local stuff
        glDisable(GL_DEPTH_CLAMP);
        glEnable(GL_CULL_FACE);                  
    }
Ejemplo n.º 5
0
    void RenderSceneIntoDepth()
    {
        glDrawBuffer(GL_NONE);
              
        m_nullTech.Enable();

        Pipeline p;
        
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);                       
                
        m_boxOrientation.m_rotation = Vector3f(0, m_scale, 0);
        p.Orient(m_boxOrientation);
        m_nullTech.SetWVP(p.GetWVPTrans());        
        m_box.Render();                
        
        p.Orient(m_quadOrientation);
        m_nullTech.SetWVP(p.GetWVPTrans());
        m_quad.Render();             
    }
Ejemplo n.º 6
0
    void RenderPass()
    {
        glCullFace(GL_BACK);
        
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        m_lightingEffect.Enable();
        m_shadowMapFBO.BindForReading(SHADOW_TEXTURE_UNIT);
        m_lightingEffect.SetEyeWorldPos(m_pGameCamera->GetPos());
        
        Pipeline p;
        p.SetPerspectiveProj(m_persProjInfo);    
        p.SetCamera(*m_pGameCamera);
        
        // Render the quads
        m_pGroundTex->Bind(COLOR_TEXTURE_UNIT);
        p.Orient(m_quad1Orientation);
        m_lightingEffect.SetWorldMatrix(p.GetWorldTrans());
        m_lightingEffect.SetWVP(p.GetWVPTrans());        
        m_quad.Render();
        
        p.Orient(m_quad2Orientation);
        m_lightingEffect.SetWorldMatrix(p.GetWorldTrans());
        m_lightingEffect.SetWVP(p.GetWVPTrans());        
        m_quad.Render();        

        // Render the meshes
        p.Orient(m_mesh1Orientation);
        m_lightingEffect.SetWorldMatrix(p.GetWorldTrans());
        m_lightingEffect.SetWVP(p.GetWVPTrans());       
        m_mesh.Render();        
        
        p.Orient(m_mesh2Orientation);
        m_lightingEffect.SetWorldMatrix(p.GetWorldTrans());
        m_lightingEffect.SetWVP(p.GetWVPTrans());       
        m_mesh.Render();                
    }