fixed the light problem,
very basic light at the moment, needs a lot of work: - custom position, - custom intensities, - calculate at better positions, others: - adjust zoom speed
This commit is contained in:
parent
1c962a481f
commit
f5863752e2
|
@ -39,7 +39,7 @@ private:
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
QVector3D position = { 1,1,1 };
|
QVector3D position = { 1,1,1 };
|
||||||
QVector3D intensities = { 1,1,1 };
|
QVector3D intensities = { 1,0.25,0.25 };
|
||||||
} m_light;
|
} m_light;
|
||||||
|
|
||||||
QOpenGLShaderProgram m_program;
|
QOpenGLShaderProgram m_program;
|
||||||
|
|
|
@ -4,8 +4,9 @@ precision mediump int;
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uniform mat3 n_matrix;
|
//uniform mat3 n_matrix;
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
|
uniform mat4 norm_matrix;
|
||||||
uniform mat4 m_matrix;
|
uniform mat4 m_matrix;
|
||||||
|
|
||||||
uniform struct Light {
|
uniform struct Light {
|
||||||
|
@ -21,7 +22,7 @@ varying vec3 v_normal;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
mat3 normalMatrix = transpose(inverse(mat3(m_matrix)));
|
mat3 n_matrix = transpose(inverse(mat3(norm_matrix * m_matrix)));
|
||||||
vec3 normal = normalize(n_matrix * v_normal);
|
vec3 normal = normalize(n_matrix * v_normal);
|
||||||
|
|
||||||
vec3 surfaceToLight = light.position - v_position;
|
vec3 surfaceToLight = light.position - v_position;
|
||||||
|
|
|
@ -179,7 +179,8 @@ void OglViewerWidget::initializeGL()
|
||||||
{
|
{
|
||||||
initializeOpenGLFunctions();
|
initializeOpenGLFunctions();
|
||||||
|
|
||||||
glClearColor(0.5000f, 0.8000f, 1.0000f, 0.0000f);
|
//glClearColor(0.5000f, 0.8000f, 1.0000f, 0.0000f);
|
||||||
|
glClearColor(0.02f, 0.01f, 0.01f, 0.0000f);
|
||||||
|
|
||||||
initShaders();
|
initShaders();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue