in roboschool/cpp-household/render-ssao.cpp [232:297]
void ContextViewport::_ssao_run(int sampleIdx)
{
if (blur) {
glBindFramebuffer(GL_FRAMEBUFFER, fbuf_hbao_calc->handle);
glDrawBuffer(GL_COLOR_ATTACHMENT0);
} else {
glBindFramebuffer(GL_FRAMEBUFFER, fbuf_scene->handle);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_ZERO,GL_SRC_COLOR);
if (samples > 1){
glEnable(GL_SAMPLE_MASK);
glSampleMaski(0, 1<<sampleIdx);
}
}
//glUseProgram( (USE_AO_SPECIALBLUR && blur) ?
// cx->program_calc_blur->programId() :
// cx->program_hbao_calc->programId() );
cx->program_hbao_calc->bind();
cx->program_hbao_calc->setUniformValue(cx->location_RadiusToScreen, cx->useful->hbaoUbo.RadiusToScreen);
cx->program_hbao_calc->setUniformValue(cx->location_R2, cx->useful->hbaoUbo.R2);
cx->program_hbao_calc->setUniformValue(cx->location_NegInvR2, cx->useful->hbaoUbo.NegInvR2);
cx->program_hbao_calc->setUniformValue(cx->location_NDotVBias, cx->useful->hbaoUbo.NDotVBias);
cx->program_hbao_calc->setUniformValue(cx->location_InvFullResolution, cx->useful->hbaoUbo.InvFullResolution[0], cx->useful->hbaoUbo.InvFullResolution[1]);
cx->program_hbao_calc->setUniformValue(cx->location_InvQuarterResolution, cx->useful->hbaoUbo.InvQuarterResolution[0], cx->useful->hbaoUbo.InvQuarterResolution[1]);
cx->program_hbao_calc->setUniformValue(cx->location_AOMultiplier, cx->useful->hbaoUbo.AOMultiplier);
cx->program_hbao_calc->setUniformValue(cx->location_PowExponent, cx->useful->hbaoUbo.PowExponent);
cx->program_hbao_calc->setUniformValue(cx->location_projInfo,
cx->useful->hbaoUbo.projInfo[0],
cx->useful->hbaoUbo.projInfo[1],
cx->useful->hbaoUbo.projInfo[2],
cx->useful->hbaoUbo.projInfo[3]);
cx->program_hbao_calc->setUniformValue(cx->location_projScale, cx->useful->hbaoUbo.projScale[0], cx->useful->hbaoUbo.projScale[1]);
cx->program_hbao_calc->setUniformValue(cx->location_projOrtho, cx->useful->hbaoUbo.projOrtho);
// layered etc
glUniform4fv(cx->location_float2Offsets, sizeof(cx->useful->hbaoUbo.float2Offsets)/sizeof(cx->useful->hbaoUbo.float2Offsets[0])/4, cx->useful->hbaoUbo.float2Offsets);
glUniform4fv(cx->location_jitters, sizeof(cx->useful->hbaoUbo.jitters)/sizeof(cx->useful->hbaoUbo.jitters[0])/4, cx->useful->hbaoUbo.jitters);
glUniform1i(cx->location_texLinearDepth, 1); // texture unit 0
glUniform1i(cx->location_texRandom, 0); // texture unit 1
glBindVertexArray(cx->ruler_vao->handle);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, cx->hbao_randomview[sampleIdx]->handle);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, tex_depthlinear->handle);
glDrawArrays(GL_TRIANGLES,0,3);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
if (blur) {
//drawHbaoBlur(projection,width,height,sampleIdx);
}
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glDisable(GL_SAMPLE_MASK);
glSampleMaski(0, ~0);
cx->program_hbao_calc->release();
}