[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [analitza] analitzaplot: Simplify pixel and vertex shader
From:       Aleix Pol <aleixpol () kde ! org>
Date:       2015-10-01 1:39:51
Message-ID: E1ZhSqd-0006Xk-Th () scm ! kde ! org
[Download RAW message or body]

Git commit 80a3833ee306ee62ef61126d31fd7649bc7394af by Aleix Pol.
Committed on 01/10/2015 at 01:35.
Pushed by apol into branch 'master'.

Simplify pixel and vertex shader

The lighting system implemented wasn't working to well, so for now just
dim the coloring depending on the distance of the vertex to the camera. It
gives the distance visual differenciation which is what we were after
anyway.

M  +3    -18   analitzaplot/plotter3d_es.cpp

http://commits.kde.org/analitza/80a3833ee306ee62ef61126d31fd7649bc7394af

diff --git a/analitzaplot/plotter3d_es.cpp b/analitzaplot/plotter3d_es.cpp
index c26ecb9..aec9c17 100644
--- a/analitzaplot/plotter3d_es.cpp
+++ b/analitzaplot/plotter3d_es.cpp
@@ -99,33 +99,21 @@ void Plotter3DES::initGL()
     program.addShaderFromSourceCode(QOpenGLShader::Vertex,
         "attribute highp vec4 vertex;\n"
         "attribute highp vec4 normal;\n"
-        "varying vec4 vx;\n"
-        "varying vec4 vertNormal;\n"
-        "varying vec4 lp;\n"
         "uniform highp mat4 matrix;\n"
-        "uniform highp mat4 projection;\n"
-        "uniform highp vec4 lightPos;\n"
 
         "void main(void)\n"
         "{\n"
         "   gl_Position = matrix * vertex;\n"
-        "   vx = vertex;\n"
-        "   lp = lightPos * matrix;\n"
-        "   vertNormal = normalize(normal * vertex);\n"
         "}"
     );
     program.addShaderFromSourceCode(QOpenGLShader::Fragment,
         "uniform mediump vec4 color;\n"
 
-        "varying highp vec4 lp;\n"
-        "varying highp vec4 vx;\n"
-        "varying highp vec4 vertNormal;\n"
         "void main(void)\n"
         "{\n"
-        "   highp vec4 Lv = normalize(lp - vx);\n"
-        "   highp float incidence = max(dot(vertNormal, Lv), 0.5);\n"
-        "   highp vec3 col = incidence * color.rgb;\n"
-        "   gl_FragColor = vec4(col, 1.0);\n"
+        "   float w = 10.*gl_FragCoord.w;\n"
+        "   highp vec4 zvec = vec4(w, w, w, 1.0);"
+        "   gl_FragColor = mix(color, zvec, vec4(.5,.5,.5,1.));\n"
         "}"
     );
     program.link();
@@ -171,11 +159,8 @@ void Plotter3DES::drawPlots()
     }
 
     program.bind();
-    program.setUniformValue("projection", m_projection);
     program.setUniformValue("matrix", m_projection * m_rot);
 
-    program.setUniformValue("lightPos", QVector4D { 500.0, 500.0, 500.0, 0 });
-
     const int vertexLocation = program.attributeLocation("vertex");
     const int normalLocation = program.attributeLocation("normal");
 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic