Show plain color without any light

master
Jeremy HU 2022-09-21 22:14:02 +10:00
parent e3a412df3c
commit ba452b41c9
3 changed files with 27 additions and 5 deletions

View File

@ -1,7 +1,12 @@
#version 330
uniform vec4 defaultColor;
in vec3 pointPosition;
in vec3 pointNormal;
in vec3 pointColor;
in float pointAlpha;
in float pointMetalness;
in float pointRoughness;
out vec4 fragColor;
void main()
{
fragColor = defaultColor;
fragColor = vec4(pointColor, pointAlpha);
}

View File

@ -10,7 +10,23 @@ layout(location = 7) in float alpha;
uniform mat4 modelMatrix;
uniform mat4 viewMatrix;
uniform mat4 projectionMatrix;
uniform vec3 lightDirection;
uniform vec3 eyePosition;
out vec3 pointPosition;
out vec3 pointNormal;
out vec3 pointColor;
out float pointAlpha;
out float pointMetalness;
out float pointRoughness;
void main()
{
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vertex;
pointPosition = (modelMatrix * vertex).xyz;
pointNormal = normalize((modelMatrix * vec4(normal, 1.0)).xyz);
pointColor = color;
pointAlpha = alpha;
pointMetalness = metalness;
pointRoughness = roughness;
gl_Position = projectionMatrix * viewMatrix * vec4(pointPosition, 1.0);
}

View File

@ -176,10 +176,11 @@ void ModelWidget::paintGL()
m_openGLProgram->bind();
m_openGLProgram->setUniformValue(m_openGLProgram->getUniformLocationByName("eyePosition"), m_eyePosition);
m_openGLProgram->setUniformValue(m_openGLProgram->getUniformLocationByName("lightDirection"), QVector3D(-1.0, -1.0, -1.0).normalized());
m_openGLProgram->setUniformValue(m_openGLProgram->getUniformLocationByName("projectionMatrix"), m_projection);
m_openGLProgram->setUniformValue(m_openGLProgram->getUniformLocationByName("modelMatrix"), m_world);
m_openGLProgram->setUniformValue(m_openGLProgram->getUniformLocationByName("viewMatrix"), m_camera);
m_openGLProgram->setUniformValue(m_openGLProgram->getUniformLocationByName("defaultColor"), QVector4D(1.0, 1.0, 1.0, 1.0));
if (m_openGLObject)
m_openGLObject->draw();