Skip to content

Commit

Permalink
Bind uniforms to the opengl impl
Browse files Browse the repository at this point in the history
  • Loading branch information
ApoorvaJ committed Sep 18, 2023
1 parent 55d9822 commit 9d7dedc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions source/MaterialXView/RenderPipelineGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,15 @@ mx::ImagePtr GLRenderPipeline::convolveEnvironment()
}

mx::ImagePtr srcTex = lightHandler->getEnvRadianceMap();

int w = srcTex->getWidth();
int h = srcTex->getHeight();
int numMips = srcTex->getMaxMipCount();

// Create texture to hold the convolved environment.
mx::ImagePtr outTex = mx::Image::create(w, h, 3, mx::Image::BaseType::HALF);
glImageHandler->createRenderResources(outTex, true); // TODO: Is this needed?


int i = 0;
while (w > 0 && h > 0)
{
Expand All @@ -152,17 +153,21 @@ mx::ImagePtr GLRenderPipeline::convolveEnvironment()
material->bindShader();

// TODO: Can this be moved out of the loop?
// Bind the source texture to attachment 0
mx::GlslProgramPtr program = material->getProgram();
// Bind the source texture
mx::ImageSamplingProperties samplingProperties;
samplingProperties.uaddressMode = mx::ImageSamplingProperties::AddressMode::PERIODIC;
samplingProperties.vaddressMode = mx::ImageSamplingProperties::AddressMode::CLAMP;
samplingProperties.filterType = mx::ImageSamplingProperties::FilterType::LINEAR;
imageHandler->bindImage(srcTex, samplingProperties);

int textureLocation = glImageHandler->getBoundTextureLocation(srcTex->getResourceId());
assert(textureLocation >= 0);
material->getProgram()->bindUniform(mx::HW::ENV_RADIANCE, mx::Value::createValue(textureLocation));
glActiveTexture(GL_TEXTURE0);
// Bind other uniforms
program->bindUniform(mx::HW::CONVOLUTION_MIP_LEVEL, mx::Value::createValue(i));
const mx::Matrix44 yRotationPI = mx::Matrix44::createScale(mx::Vector3(-1, 1, -1));
program->bindUniform(mx::HW::T_ENV_MATRIX, mx::Value::createValue(yRotationPI));
program->bindUniform(mx::HW::T_ENV_RADIANCE_MIPS, mx::Value::createValue<int>(numMips));

_viewer->renderScreenSpaceQuad(material);

Expand Down

0 comments on commit 9d7dedc

Please sign in to comment.