예제 #1
0
// draw slice of particles from light's point of view
void VHParticlesRender::drawSliceLightView(int i)
{
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadMatrixf((GLfloat *) lightView.get_value());

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadMatrixf((GLfloat *) lightProj.get_value());


	lightFbo->bind();
    glViewport(0, 0, lightBufferSize, lightBufferSize);

	//int db;
	//glGetIntegerv ( GL_DRAW_BUFFER, &db );

    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);

	shadowMapSpriteProg->enable();
	shadowMapSpriteProg->setUniform1f("pointRadius",pointSize);
	shadowMapSpriteProg->setUniform4f("uShadowColor", colorAttenuation.x,colorAttenuation.y,colorAttenuation.z,shadowAlpha);

	shadowMapSpriteProg->bindTexture("sDiffuseMap", TextureManager::Inst()->m_texID[id1],GL_TEXTURE_2D,0);

    drawPointSprites(i*batchSize, batchSize);
	shadowMapSpriteProg->disable();
    

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
}
예제 #2
0
void VHParticlesRender::drawSlice(int i)
{
	imageFbo->bind();
    glViewport(0, 0, width*resMul, height*resMul);

	//int db;
	//glGetIntegerv ( GL_DRAW_BUFFER, &db );


    if (invertedView) {
        // front-to-back
        glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);
    } else {
        // back-to-front
        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    }

	shadowedSpriteProg->enable();
	shadowedSpriteProg->setUniform1f("pointRadius",pointSize);
    shadowedSpriteProg->bindTexture("sDiffuseMap", TextureManager::Inst()->m_texID[id1],GL_TEXTURE_2D,0);
	shadowedSpriteProg->bindTexture("shadowTex", lightTex[srcLightTexture], GL_TEXTURE_2D, 1);


	drawPointSprites(i*batchSize, batchSize);

	shadowedSpriteProg->disable();

}
// draw slice of particles from light's point of view
void SmokeRenderer::drawSliceLightView(int i)
{
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadMatrixf((GLfloat *) m_lightView.get_value());

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadMatrixf((GLfloat *) m_lightProj.get_value());

    m_lightFbo->Bind();
    glViewport(0, 0, m_lightBufferSize, m_lightBufferSize);

    glColor4f(m_colorAttenuation[0] * m_shadowAlpha, m_colorAttenuation[1] * m_shadowAlpha, m_colorAttenuation[2] * m_shadowAlpha, 1.0);
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);

    drawPointSprites(m_particleProg, i*m_batchSize, m_batchSize, false);

    m_lightFbo->Disable();

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
}
void SmokeRenderer::render()
{
	switch(mDisplayMode) {
	case POINTS:
		glColor3f(1.0, 1.0, 1.0);
		m_simpleProg->enable();
		drawPoints(0, mNumParticles, false);
		m_simpleProg->disable();
		break;
	case SPRITES:
        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
		glColor4f(1.0, 1.0, 1.0, m_spriteAlpha);
		drawPointSprites(m_particleProg, 0, mNumParticles, false);
		break;
	case VOLUMETRIC:
		drawSlices();
		compositeResult();
		break;
	case NUM_MODES:
		break;
	}

    if (m_displayLightBuffer) {
        // display light buffer to screen
        glViewport(0, 0, m_lightBufferSize, m_lightBufferSize);
        glDisable(GL_DEPTH_TEST);
        displayTexture(m_lightTexture[m_srcLightTexture]);
        glViewport(0, 0, mWindowW, mWindowH);
    }

    glutReportErrors();
}
// draw slice of particles from camera view
void SmokeRenderer::drawSlice(int i)
{
    m_imageFbo->Bind();
    glViewport(0, 0, m_imageW, m_imageH);

    glColor4f(1.0, 1.0, 1.0, m_spriteAlpha);

    if (m_invertedView) {
        // front-to-back
        glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);
    } else {
        // back-to-front
        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    }
    drawPointSprites(m_particleShadowProg, i*m_batchSize, m_batchSize, true);

    m_imageFbo->Disable();
}