Commit 6de802e7 authored by Luis Penaranda's avatar Luis Penaranda

pass ZB parameters to the shader automatically

parent d8c970c0
...@@ -709,11 +709,17 @@ void OpenGLCanvas::setShaders() { ...@@ -709,11 +709,17 @@ void OpenGLCanvas::setShaders() {
GLuint p = glCreateProgram(); GLuint p = glCreateProgram();
// Bind attributes zblambda and zbR to the vertex shader // Bind attributes zblambda and zbR to the vertex shader. Nvidia hardware
glVertexAttrib1f(0,zblambda); // only leaves attributes 1 and 7 unreserved; attributes 8 to 15 are
glBindAttribLocation(p,0,"zblambda"); // reserved for textures.
glVertexAttrib1f(1,zbR); // TODO: we use attributes 14 and 15, which work for Nvidia; we need to
glBindAttribLocation(p,1,"zbR"); // test with other hardware.
#define ZBL_ATTR 14
#define ZBR_ATTR 15
glVertexAttrib1f(ZBL_ATTR,zblambda);
glBindAttribLocation(p,ZBL_ATTR,"zblambda");
glVertexAttrib1f(ZBR_ATTR,zbR);
glBindAttribLocation(p,ZBR_ATTR,"zbR");
glAttachShader(p,v); glAttachShader(p,v);
glAttachShader(p,f); glAttachShader(p,f);
......
...@@ -6,9 +6,7 @@ float u, v, x, y, z; ...@@ -6,9 +6,7 @@ float u, v, x, y, z;
varying float r, theta, s; varying float r, theta, s;
float lambda, phi; float lambda, phi;
float extent, scale, vis_mode, center_lambda, center_phi; float extent, scale, vis_mode, center_lambda, center_phi;
float zbr,zbalpha,zbrho; attribute float zblambda,zbR;
/*attribute*/ float zblambda;
/*attribute*/ float zbR;
void main(void){ void main(void){
...@@ -87,11 +85,9 @@ void main(void){ ...@@ -87,11 +85,9 @@ void main(void){
u=x/(-z); u=x/(-z);
v=y/(-z); v=y/(-z);
// Z-B transformation // Z-B transformation
zblambda=0.1; float zbalpha=atan(v,u);
zbR=1.0; float zbr=sqrt(u*u+v*v);
zbalpha=atan(v,u); float zbrho=(zblambda*zbr/zbR)+(1.0-zblambda)*(zbR*(sqrt(zbr*zbr+1.0)-1.0))/(zbr*(sqrt(zbR*zbR+1.0)-1.0));
zbr=sqrt(u*u+v*v);
zbrho=(zblambda*zbr/zbR)+(1.0-zblambda)*(zbR*(sqrt(zbr*zbr+1.0)-1.0))/(zbr*(sqrt(zbR*zbR+1.0)-1.0));
u=zbrho*cos(zbalpha); u=zbrho*cos(zbalpha);
v=zbrho*sin(zbalpha); v=zbrho*sin(zbalpha);
gl_Position = vec4(u/extent,v/extent,z,1.0); gl_Position = vec4(u/extent,v/extent,z,1.0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment