Example #1
0
    void DSPointLightPass(unsigned int PointLightIndex)
    {
		m_gbuffer.BindForLightPass();

        m_DSPointLightPassTech.Enable();
        m_DSPointLightPassTech.SetEyeWorldPos(m_pGameCamera->GetPos());        

		glStencilFunc(GL_NOTEQUAL, 0, 0xFF);
      		
		glDisable(GL_DEPTH_TEST);
		glEnable(GL_BLEND);
		glBlendEquation(GL_FUNC_ADD);
		glBlendFunc(GL_ONE, GL_ONE);
        
        glEnable(GL_CULL_FACE);
        glCullFace(GL_FRONT);

        Pipeline p;
        p.WorldPos(m_pointLight[PointLightIndex].Position);
        float BBoxScale = CalcPointLightBSphere(m_pointLight[PointLightIndex]);        
		p.Scale(BBoxScale, BBoxScale, BBoxScale);		
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);               
        m_DSPointLightPassTech.SetWVP(p.GetWVPTrans());
        m_DSPointLightPassTech.SetPointLight(m_pointLight[PointLightIndex]);
        m_bsphere.Render(); 
        glCullFace(GL_BACK);
       
		glDisable(GL_BLEND);
    }
Example #2
0
	void DSStencilPass(unsigned int PointLightIndex)
	{
		m_nullTech.Enable();

		// Disable color/depth write and enable stencil
		m_gbuffer.BindForStencilPass();
		glEnable(GL_DEPTH_TEST);

        glDisable(GL_CULL_FACE);

		glClear(GL_STENCIL_BUFFER_BIT);

		// We need the stencil test to be enabled but we want it
		// to succeed always. Only the depth test matters.
		glStencilFunc(GL_ALWAYS, 0, 0);

		glStencilOpSeparate(GL_BACK, GL_KEEP, GL_INCR_WRAP, GL_KEEP);
		glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_DECR_WRAP, GL_KEEP);

		Pipeline p;
		p.WorldPos(m_pointLight[PointLightIndex].Position);
        float BBoxScale = CalcPointLightBSphere(m_pointLight[PointLightIndex]);
		p.Scale(BBoxScale, BBoxScale, BBoxScale);		
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);

		m_nullTech.SetWVP(p.GetWVPTrans());
		m_bsphere.Render();  
	}
Example #3
0
void VRSim::DSStencilPass(unsigned int PointLightIndex){
  m_nullTech.enable();

  // Disable color/depth write and enable stencil
  m_gbuffer.BindForStencilPass();
  glEnable(GL_DEPTH_TEST);

  glDisable(GL_CULL_FACE);

  glClear(GL_STENCIL_BUFFER_BIT);

  // We need the stencil test to be enabled but we want it
  // to succeed always. Only the depth test matters.
  glStencilFunc(GL_ALWAYS, 0, 0);

  glStencilOpSeparate(GL_BACK, GL_KEEP, GL_INCR_WRAP, GL_KEEP);
  glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_DECR_WRAP, GL_KEEP);

  float BSphereScale = CalcPointLightBSphere(m_pointLight[PointLightIndex]);
  sphere.model = cavr::math::mat4f::translate(m_pointLight[PointLightIndex].Position) * cavr::math::mat4f::scale(BSphereScale);

  auto mvp = (cavr::gfx::getProjection() * cavr::gfx::getView() * sphere.model);
  m_nullTech.set("gWVP", mvp);

  sphere.renderModel();
}
Example #4
0
    void DSPointLightsPass()
    {
        m_DSPointLightPassTech.Enable();
        m_DSPointLightPassTech.SetEyeWorldPos(m_pGameCamera->GetPos());        
        
        Pipeline p;
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);        
           
		for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_pointLight); i++) {
            m_DSPointLightPassTech.SetPointLight(m_pointLight[i]);            
            p.WorldPos(m_pointLight[i].Position);
            float BSphereScale = CalcPointLightBSphere(m_pointLight[i]);
            p.Scale(BSphereScale, BSphereScale, BSphereScale);		
            m_DSPointLightPassTech.SetWVP(p.GetWVPTrans());
            m_bsphere.Render();                   
		}        
    }
Example #5
0
void StencilPass::startPass(CGraphics* it, PointLight* Light) {
	m_shaderProg.useProgram();

	// Disable color/depth write and enable stencil
	glEnable(GL_DEPTH_TEST);

	glDisable(GL_CULL_FACE);

	glClear(GL_STENCIL_BUFFER_BIT);
	// We need the stencil test to be enabled but we want it
	// to succeed always. Only the depth test matters.
	glStencilFunc(GL_ALWAYS, 0, 0);

	glStencilOpSeparate(GL_BACK, GL_KEEP, GL_INCR_WRAP, GL_KEEP);
	glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_DECR_WRAP, GL_KEEP);

	Pipeline::position(it->getOwner()->GetTransform()->getPosition().x, it->getOwner()->GetTransform()->getPosition().y, it->getOwner()->GetTransform()->getPosition().z);
	float BSphereScale = CalcPointLightBSphere(Light);
	Pipeline::scale(BSphereScale, BSphereScale, BSphereScale);	

	glUniformMatrix4fv(m_MVPLocation, 1, GL_FALSE, &Pipeline::getTransformationMatrix()[0][0]);
}
Example #6
0
void VRSim::DSPointLightsPass(unsigned int PointLightIndex)
{
    m_gbuffer.BindForLightPass();
    pointProgram.enable();


    glStencilFunc(GL_NOTEQUAL, 0, 0xFF);
    glDisable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glBlendEquation(GL_FUNC_ADD);
    glBlendFunc(GL_ONE, GL_ONE);


    glEnable(GL_CULL_FACE);
    glCullFace(GL_FRONT);

    float BSphereScale = CalcPointLightBSphere(m_pointLight[PointLightIndex]);
    sphere.model = cavr::math::mat4f::translate(m_pointLight[PointLightIndex].Position) * cavr::math::mat4f::scale(BSphereScale);

    auto mvp = (cavr::gfx::getProjection() * cavr::gfx::getView() * sphere.model);

    pointProgram.SetPointLight(m_pointLight[PointLightIndex]);
    pointProgram.set("gWVP", mvp);
    pointProgram.set("gEyeWorldPos", playerPos);
    pointProgram.set("gPositionMap", GBuffer::GBUFFER_TEXTURE_TYPE_POSITION);
    pointProgram.set("gColorMap", GBuffer::GBUFFER_TEXTURE_TYPE_DIFFUSE);
    pointProgram.set("gNormalMap", GBuffer::GBUFFER_TEXTURE_TYPE_NORMAL);
    pointProgram.set("gMatSpecularIntensity", 10.10f);
    pointProgram.set("gSpecularPower", 3.0f);


    glUniform2f(pointProgram.getLocation("gScreenSize"), (float) windowWidth, (float) windowHeight);

    sphere.renderModel();

    glCullFace(GL_BACK);
    glDisable(GL_BLEND);

}