添加调整主光源强度的滑动条,场景渲染中四个滑动条分别对应光强、光Pitch角、光Yaw角、曝光

main
wuyize 2023-04-22 10:54:35 +08:00
parent 00b04fc33c
commit 645797f8f5
4 changed files with 51 additions and 24 deletions

View File

@ -165,6 +165,19 @@
<property name="rightMargin">
<number>12</number>
</property>
<item>
<widget class="QSlider" name="lightRadianceSlider">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>600</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="horizontalSlider">
<property name="sizePolicy">

View File

@ -14,7 +14,7 @@
using namespace Renderer;
QVector3D mainLightRadiance = 40 * QVector3D(0.7529, 0.7450, 0.6784).normalized();
QVector3D mainLightRadiance = 10 * QVector3D(0.7529, 0.7450, 0.6784).normalized();
static float sunPitch = 105, sunYaw = 80;
static int sunSpeed = 10;
@ -89,6 +89,11 @@ void RendererGLWidget::setModel(QString path)
doneCurrent();
}
void Renderer::RendererGLWidget::setMainLightRadiance(QVector3D radiance)
{
mainLightRadiance = radiance;
}
void RendererGLWidget::setMainLightPitch(float pitch)
{
//qDebug() << "pitch" << pitch;
@ -344,30 +349,34 @@ void RendererGLWidget::paintGL()
if (model != nullptr)
model->draw();
//plainProgramPtr->bind();
//plainProgramPtr->setUniformValue("projection", projection);
//plainProgramPtr->setUniformValue("view", view);
//plainProgramPtr->setUniformValue("albedo", 0.5f, 0.5f, 0.5f);
//QMatrix4x4 model;
//int nrRows = 7, nrColumns = 7;
//float spacing = 2.5;
//for (int row = 0; row < nrRows; ++row)
//{
// plainProgramPtr->setUniformValue("metallic", (float)row / (float)nrRows);
// for (int col = 0; col < nrColumns; ++col)
// {
// plainProgramPtr->setUniformValue("roughness", glm::clamp((float)col / (float)nrColumns, 0.05f, 1.0f));
/// Debug Lighting
if (false)
{
plainProgramPtr->bind();
plainProgramPtr->setUniformValue("projection", projection);
plainProgramPtr->setUniformValue("view", view);
plainProgramPtr->setUniformValue("albedo", 0.5f, 0.5f, 0.5f);
QMatrix4x4 model;
int nrRows = 7, nrColumns = 7;
float spacing = 2.5;
for (int row = 0; row < nrRows; ++row)
{
plainProgramPtr->setUniformValue("metallic", (float)row / (float)nrRows);
for (int col = 0; col < nrColumns; ++col)
{
plainProgramPtr->setUniformValue("roughness", glm::clamp((float)col / (float)nrColumns, 0.05f, 1.0f));
// model.setToIdentity();
// model.scale(10);
// model.translate(QVector3D((float)(col - (nrColumns / 2)) * spacing,
// (float)(row - (nrRows / 2)) * spacing + 20,
// -2.0f));
// plainProgramPtr->setUniformValue("model", model);
// IblUtils::renderSphere(glFunc);
// }
//}
//plainProgramPtr->release();
model.setToIdentity();
model.scale(10);
model.translate(QVector3D((float)(col - (nrColumns / 2)) * spacing,
(float)(row - (nrRows / 2)) * spacing + 20,
-2.0f));
plainProgramPtr->setUniformValue("model", model);
IblUtils::renderSphere(glFunc);
}
}
plainProgramPtr->release();
}
pageIdDownsampleProgramPtr->bind();
gl->BindImageTexture(3, gbuffers[4], 0, GL_FALSE, 0, GL_READ_WRITE, GL_RG16UI);

View File

@ -29,6 +29,7 @@ namespace Renderer
public slots:
void setModel(QString path);
void setMainLightRadiance(QVector3D radiance);
void setMainLightPitch(float pitch);
void setMainLightYaw(float yaw);
void setExposure(float exposure);

View File

@ -64,6 +64,9 @@ Renderer::RendererWidget::RendererWidget(QWidget* parent)
emit openPaintingFile(paintingPath);
});
QObject::connect(ui.lightRadianceSlider, &QSlider::valueChanged, [&](int value) {
ui.openGLWidget->setMainLightRadiance(value / 10.f * QVector3D(0.7529, 0.7450, 0.6784).normalized());
});
QObject::connect(ui.horizontalSlider, &QSlider::valueChanged,
ui.openGLWidget, &Renderer::RendererGLWidget::setMainLightPitch);
QObject::connect(ui.horizontalSlider_2, &QSlider::valueChanged,
@ -71,6 +74,7 @@ Renderer::RendererWidget::RendererWidget(QWidget* parent)
QObject::connect(ui.exposureSlider, &QSlider::valueChanged, [&](int value) {
ui.openGLWidget->setExposure(value / 100.f);
});
ui.lightRadianceSlider->setValue(100);
ui.horizontalSlider->setValue(105);
ui.horizontalSlider_2->setValue(80);
ui.exposureSlider->setValue(60);