I am trying to implement the Epic's game split sum approximation and I am stuck on the BRDF Look up texture creation.
I have already implemented this but the code was very messy hence I have decided to create some sort of class structure.
Everything works just fine. Iradiance map, Prefilter map etc... are generated as they should be
However when I am trying to render BRDF Texture I am getting the following artifacts.


As I was trying to solve the issue I have stumbled upon the Following article which described my issue and suggested that I should use glPixelStorei(GL_UNPACK_ALIGNMENT, alignment) function.
So I have tried it before I initialized the draw call like so
void BRDF::execute() { auto colorAttachemnt = std::make_unique(512,512,GL_RG16F); colorAttachemnt->setUnpackAlignment(2); this->frameBuffer = std::make_unique(colorAttachemnt->texWidth,colorAttachemnt->texHeight, this->shader,std::move(colorAttachemnt)); this->frameBuffer->drawInsideSelf(); } where setUnpcackAlignment(2) method is declared in the base class of the Texture like so
void TextureBase::setUnpackAlignment(int alignment) { this->bind(); glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); this->unbind(); } It did not work, so I started digging deeper into the deocumentation of the above mentioned GL function however I did not quite understand what to use or what could be beneficial for me hence I am seeking help here.
To provide more insight the Texture2D is created like so
Texture2D::Texture2D(int width, int height, GLenum foramt): TextureBase() { this->type = GL_TEXTURE_2D; this->isPBRMaterial = false; //more class properties... // ------------------ // TEXTURE GENERATION // ------------------- glCreateTextures(GL_TEXTURE_2D,1, &this->ID); glBindTexture(GL_TEXTURE_2D, this->ID); glTexStorage2D(GL_TEXTURE_2D, 1, foramt, width, height); // ------------------ // TEXTURE PARAMETERS // ------------------- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glBindTexture(GL_TEXTURE_2D,0); } The draw call that is responsible for rendering BRDF texture itself is located in FrameBuffer class which constructor looks like this
FrameBuffer::FrameBuffer(int SCR_WIDTH, int SCR_HEIGHT,std::shared_ptr customShader, std::unique_ptr customColorAttachment) this->shader = customShader; //FRAME BUFFER CONFIG glCreateFramebuffers(1, &this->ID); glBindFramebuffer(GL_FRAMEBUFFER, this->ID); // RENDER BUFFER CONFIG this->renderBuffer = std::make_unique(SCR_WIDTH, SCR_HEIGHT); this->renderBuffer->bind(); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, this->renderBuffer->ID); this->colorAttachment = std::move(customColorAttachement); this->colorAttachment->bind(); this->colorAttachment->setSamplerID(0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, this->colorAttachment->ID, 0); //-------------------- // MORE CONFIGURATION // ..... //-------------------- glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindTexture(GL_TEXTURE_2D, 0); glBindRenderbuffer(GL_RENDERBUFFER, 0); } NOTE: Render buffer storage is GL_DEPTH24_STENCIL8
And lastly I am executing the draw call in the following FrameBuffer method
void FrameBuffer::drawInsideSelf() { glViewport(0, 0, width, height); this->bind(); glClearColor(0.1f, 0.1f, 0.1f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); this->objectMaterial->configureShader(); this->objectGeometry->render(); } I have not included BRDF shader code as it seems to be correct however I can attach it later if needed.
This is the RenderDoc capture uploaded on my iCloud if anyone is interested
Sorry for the long question, every help is greatly appreciated.
FINAL NOTE: I have glError validation and I am getting no errors whatsoever to be 100% sure I have ran this through the RenderDoc and everything looks correct except..., well, the BRDF texture
Источник: https://stackoverflow.com/questions/780 ... -artifacts