<commit_before>#include "saiga/rendering/lighting/ssao.h"
#include "saiga/opengl/shader/shaderLoader.h"
#include "saiga/geometry/triangle_mesh_generator.h"
#include "saiga/opengl/texture/imageGenerator.h"
#include "saiga/rendering/gbuffer.h"

void SSAOShader::checkUniforms(){
    DeferredShader::checkUniforms();
    location_invProj = getUniformLocation("invProj");
    location_randomImage = getUniformLocation("randomImage");
    location_kernelSize = getUniformLocation("uKernelSize");
    location_kernelOffsets = getUniformLocation("uKernelOffsets");
    location_radius = getUniformLocation("radius");
    location_power = getUniformLocation("power");
}



void SSAOShader::uploadInvProj(mat4 &mat){
    Shader::upload(location_invProj,mat);
}

void SSAOShader::uploadData(){

    Shader::upload(location_kernelSize,(int)kernelOffsets.size());
    Shader::upload(location_kernelOffsets,kernelOffsets.size(),kernelOffsets.data());

    Shader::upload(location_radius,radius);
    Shader::upload(location_power,power);
}

void SSAOShader::uploadRandomImage(Texture *img)
{
    Shader::upload(location_randomImage,img,4);
}


SSAO::SSAO(int w, int h)
{
    screenSize = vec2(w,h);
    ssaoSize = glm::ivec2(w/2,h/2);

    ssao_framebuffer.create();
    ssaotex = new Texture();
    ssaotex->createEmptyTexture(ssaoSize.x,ssaoSize.y,GL_RED,GL_R8,GL_UNSIGNED_BYTE);
    ssao_framebuffer.attachTexture( std::shared_ptr<raw_Texture>(ssaotex) );
    ssao_framebuffer.drawToAll();
    ssao_framebuffer.check();
    ssao_framebuffer.unbind();

    ssao_framebuffer2.create();
    bluredTexture = new Texture();
    bluredTexture->createEmptyTexture(ssaoSize.x,ssaoSize.y,GL_RED,GL_R8,GL_UNSIGNED_BYTE);
    ssao_framebuffer2.attachTexture( std::shared_ptr<raw_Texture>(bluredTexture) );
    ssao_framebuffer2.drawToAll();
    ssao_framebuffer2.check();
    ssao_framebuffer2.unbind();

    auto qb = TriangleMeshGenerator::createFullScreenQuadMesh();
    qb->createBuffers(quadMesh);

    ssaoShader  =  ShaderLoader::instance()->load<SSAOShader>("post_processing/ssao2.glsl");
    blurShader = ShaderLoader::instance()->load<MVPTextureShader>("post_processing/ssao_blur.glsl");

    setKernelSize(32);

    auto randomImage = ImageGenerator::randomNormalized(32,32);
    randomTexture = std::make_shared<Texture>();
    randomTexture->fromImage(*randomImage);
    randomTexture->setWrap(GL_REPEAT);

    clearSSAO();
}

void SSAO::resize(int w, int h)
{
    screenSize = vec2(w,h);
    ssaoSize = glm::ivec2(w/2,h/2);

    ssao_framebuffer.resize(ssaoSize.x,ssaoSize.y);
    ssao_framebuffer2.resize(ssaoSize.x,ssaoSize.y);
    clearSSAO();
}

void SSAO::clearSSAO()
{
    ssao_framebuffer2.bind();
    //clear with 1 -> no ambient occlusion
//    glClearColor(1.0f,1.0f,1.0f,1.0f);
    glClearColor(0.0f,0.0f,0.0f,0.0f);
    glClear( GL_COLOR_BUFFER_BIT );
//    glClearColor(0.0f,0.0f,0.0f,0.0f);
    ssao_framebuffer2.unbind();
}

void SSAO::render(Camera *cam, GBuffer* gbuffer)<commit_msg>minimize fix<commit_after>#include "saiga/rendering/lighting/ssao.h"
#include "saiga/opengl/shader/shaderLoader.h"
#include "saiga/geometry/triangle_mesh_generator.h"
#include "saiga/opengl/texture/imageGenerator.h"
#include "saiga/rendering/gbuffer.h"

void SSAOShader::checkUniforms(){
    DeferredShader::checkUniforms();
    location_invProj = getUniformLocation("invProj");
    location_randomImage = getUniformLocation("randomImage");
    location_kernelSize = getUniformLocation("uKernelSize");
    location_kernelOffsets = getUniformLocation("uKernelOffsets");
    location_radius = getUniformLocation("radius");
    location_power = getUniformLocation("power");
}



void SSAOShader::uploadInvProj(mat4 &mat){
    Shader::upload(location_invProj,mat);
}

void SSAOShader::uploadData(){

    Shader::upload(location_kernelSize,(int)kernelOffsets.size());
    Shader::upload(location_kernelOffsets,kernelOffsets.size(),kernelOffsets.data());

    Shader::upload(location_radius,radius);
    Shader::upload(location_power,power);
}

void SSAOShader::uploadRandomImage(Texture *img)
{
    Shader::upload(location_randomImage,img,4);
}


SSAO::SSAO(int w, int h)
{
    screenSize = vec2(w,h);
    ssaoSize = glm::ivec2(w/2,h/2);

    ssao_framebuffer.create();
    ssaotex = new Texture();
    ssaotex->createEmptyTexture(ssaoSize.x,ssaoSize.y,GL_RED,GL_R8,GL_UNSIGNED_BYTE);
    ssao_framebuffer.attachTexture( std::shared_ptr<raw_Texture>(ssaotex) );
    ssao_framebuffer.drawToAll();
    ssao_framebuffer.check();
    ssao_framebuffer.unbind();

    ssao_framebuffer2.create();
    bluredTexture = new Texture();
    bluredTexture->createEmptyTexture(ssaoSize.x,ssaoSize.y,GL_RED,GL_R8,GL_UNSIGNED_BYTE);
    ssao_framebuffer2.attachTexture( std::shared_ptr<raw_Texture>(bluredTexture) );
    ssao_framebuffer2.drawToAll();
    ssao_framebuffer2.check();
    ssao_framebuffer2.unbind();

    auto qb = TriangleMeshGenerator::createFullScreenQuadMesh();
    qb->createBuffers(quadMesh);

    ssaoShader  =  ShaderLoader::instance()->load<SSAOShader>("post_processing/ssao2.glsl");
    blurShader = ShaderLoader::instance()->load<MVPTextureShader>("post_processing/ssao_blur.glsl");

    setKernelSize(32);

    auto randomImage = ImageGenerator::randomNormalized(32,32);
    randomTexture = std::make_shared<Texture>();
    randomTexture->fromImage(*randomImage);
    randomTexture->setWrap(GL_REPEAT);

    clearSSAO();
}

void SSAO::resize(int w, int h)
{
    screenSize = vec2(w,h);
    ssaoSize = glm::ivec2(w/2,h/2);
	ssaoSize.x = glm::max(ssaoSize.x, 1);
	ssaoSize.y = glm::max(ssaoSize.y, 1);

    ssao_framebuffer.resize(ssaoSize.x,ssaoSize.y);
    ssao_framebuffer2.resize(ssaoSize.x,ssaoSize.y);
    clearSSAO();
}

void SSAO::clearSSAO()
{
    ssao_framebuffer2.bind();
    //clear with 1 -> no ambient occlusion
//    glClearColor(1.0f,1.0f,1.0f,1.0f);
    glClearColor(0.0f,0.0f,0.0f,0.0f);
    glClear( GL_COLOR_BUFFER_BIT );
//    glClearColor(0.0f,0.0f,0.0f,0.0f);
    ssao_framebuffer2.unbind();
}

void SSAO::render(Camera *cam, GBuffer* gbuffer)
{'fraction_non_alphanumeric': 0.14481279894441695, 'fraction_numerical': 0.01748309417779977, 'mean_word_length': 5.605664488017429, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3287530', 'n_tokens_mistral': 2288, 'n_tokens_neox': 2201, 'n_words': 238}