lightpreview: add fullbright checkbox
This commit is contained in:
parent
9a4f1ecca7
commit
b27c660022
|
|
@ -79,10 +79,11 @@ uniform sampler2D texture_sampler;
|
|||
uniform sampler2D lightmap_sampler;
|
||||
uniform float opacity;
|
||||
uniform bool lightmap_only;
|
||||
uniform bool fullbright;
|
||||
|
||||
void main() {
|
||||
vec3 texcolor = lightmap_only ? vec3(0.5) : texture(texture_sampler, uv).rgb;
|
||||
vec3 lmcolor = texture(lightmap_sampler, lightmap_uv).rgb;
|
||||
vec3 lmcolor = fullbright ? vec3(0.5) : texture(lightmap_sampler, lightmap_uv).rgb;
|
||||
|
||||
// 2.0 for overbright
|
||||
color = vec4(texcolor * lmcolor * 2.0, opacity);
|
||||
|
|
@ -126,6 +127,7 @@ void GLView::initializeGL()
|
|||
m_program_lightmap_sampler_location = m_program->uniformLocation("lightmap_sampler");
|
||||
m_program_opacity_location = m_program->uniformLocation("opacity");
|
||||
m_program_lightmap_only_location = m_program->uniformLocation("lightmap_only");
|
||||
m_program_fullbright_location = m_program->uniformLocation("fullbright");
|
||||
m_vao.create();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
|
@ -154,6 +156,7 @@ void GLView::paintGL()
|
|||
m_program->setUniformValue(m_program_lightmap_sampler_location, 1 /* texture unit */);
|
||||
m_program->setUniformValue(m_program_opacity_location, 1.0f);
|
||||
m_program->setUniformValue(m_program_lightmap_only_location, m_lighmapOnly);
|
||||
m_program->setUniformValue(m_program_fullbright_location, m_fullbright);
|
||||
|
||||
// opaque draws
|
||||
for (auto &draw : m_drawcalls) {
|
||||
|
|
@ -207,6 +210,12 @@ void GLView::setLighmapOnly(bool lighmapOnly)
|
|||
update();
|
||||
}
|
||||
|
||||
void GLView::setFullbright(bool fullbright)
|
||||
{
|
||||
m_fullbright = fullbright;
|
||||
update();
|
||||
}
|
||||
|
||||
void GLView::renderBSP(const QString &file, const mbsp_t &bsp, const std::vector<entdict_t> &entities)
|
||||
{
|
||||
// FIXME: move to a lightpreview_settings
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ private:
|
|||
|
||||
// render options
|
||||
bool m_lighmapOnly = false;
|
||||
bool m_fullbright = false;
|
||||
|
||||
QOpenGLVertexArrayObject m_vao;
|
||||
QOpenGLBuffer m_vbo;
|
||||
|
|
@ -96,6 +97,7 @@ private:
|
|||
int m_program_lightmap_sampler_location = 0;
|
||||
int m_program_opacity_location = 0;
|
||||
int m_program_lightmap_only_location = 0;
|
||||
int m_program_fullbright_location = 0;
|
||||
|
||||
public:
|
||||
GLView(QWidget *parent = nullptr);
|
||||
|
|
@ -104,6 +106,7 @@ public:
|
|||
void renderBSP(const QString &file, const mbsp_t &bsp, const std::vector<entdict_t> &entities);
|
||||
void setCamera(const qvec3d &origin, const qvec3d &fwd);
|
||||
void setLighmapOnly(bool lighmapOnly);
|
||||
void setFullbright(bool fullbright);
|
||||
|
||||
protected:
|
||||
void initializeGL() override;
|
||||
|
|
|
|||
|
|
@ -56,12 +56,14 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
light_options = new QLineEdit();
|
||||
auto *reload_button = new QPushButton(tr("Reload"));
|
||||
auto *lightmap_only = new QCheckBox(tr("Lightmap Only"));
|
||||
auto *fullbright = new QCheckBox(tr("Fullbright"));
|
||||
|
||||
formLayout->addRow(tr("qbsp"), qbsp_options);
|
||||
formLayout->addRow(vis_checkbox, vis_options);
|
||||
formLayout->addRow(tr("light"), light_options);
|
||||
formLayout->addRow(reload_button);
|
||||
formLayout->addRow(lightmap_only);
|
||||
formLayout->addRow(fullbright);
|
||||
|
||||
auto *form = new QWidget();
|
||||
form->setLayout(formLayout);
|
||||
|
|
@ -86,7 +88,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
connect(reload_button, &QAbstractButton::clicked, this, &MainWindow::reload);
|
||||
connect(
|
||||
lightmap_only, &QCheckBox::stateChanged, this, [&]() { glView->setLighmapOnly(lightmap_only->isChecked()); });
|
||||
lightmap_only, &QCheckBox::stateChanged, this, [=]() { glView->setLighmapOnly(lightmap_only->isChecked()); });
|
||||
connect(fullbright, &QCheckBox::stateChanged, this, [=]() { glView->setFullbright(fullbright->isChecked()); });
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() { }
|
||||
|
|
|
|||
Loading…
Reference in New Issue