[Paraview] PointSprite with Recent Intel HD Graphics

Biddiscombe, John A. biddisco at cscs.ch
Mon Feb 10 12:47:33 EST 2014


NB. Before testing lots of other stuff … Make sure you disable depth peeling the main paraview options. The point sprite shader stuff will never work if there’s another shader active.

From: Aashish Chaudhary <aashish.chaudhary at kitware.com<mailto:aashish.chaudhary at kitware.com>>
Date: Monday 10 February 2014 18:45
To: Bruce Jones <bruce.david.jones at gmail.com<mailto:bruce.david.jones at gmail.com>>
Cc: "paraview at paraview.org<mailto:paraview at paraview.org>" <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: Re: [Paraview] PointSprite with Recent Intel HD Graphics

Sorry, I hit send by mistake,

In this directory,

PARAVIEW_SRC/Plugins/PointSprite/Rendering/Resources/Shaders

Can you add line below at the beginning of all of the shaders.  You may have to compile ParaView (or plugin again).  This may not fix the problem but it would be great if you can provide some
feedback after this.

- Aashish


 #version 150



On Mon, Feb 10, 2014 at 12:43 PM, Aashish Chaudhary <aashish.chaudhary at kitware.com<mailto:aashish.chaudhary at kitware.com>> wrote:
Bruce,

In the



On Mon, Feb 10, 2014 at 12:08 PM, Aashish Chaudhary <aashish.chaudhary at kitware.com<mailto:aashish.chaudhary at kitware.com>> wrote:
This is very helpful. I am speculating that it could be related to the default shader version on your system (yours is shader model 5 I believe).

Let me come up with a quick fix (unless somone else beats me to it) which you can try. I will send that in a separate email.

- Aashish



On Mon, Feb 10, 2014 at 11:57 AM, Bruce Jones <bruce.david.jones at gmail.com<mailto:bruce.david.jones at gmail.com>> wrote:
Hi Aashish,

Thanks for getting back to me, I'll have a look at the breakpoint this afternoon. In the mean time, the full error logs are below, which appear to show the shader source for the failed shader.

Using PointSprite with Sphere(Texture) and a constant radius works fine.

Using PointSprite with Sphere(Texture) and a variable radius fails with the following message,


ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 530

vtkShaderProgram2 (0000000012D40520): the shader program failed to link. Its log is:

the shaders are:



ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 540

vtkShaderProgram2 (0000000012D40520): shader #0/3 (vertex shader) log is:


. Its source code is:

/*=========================================================================


Program: Visualization Toolkit

Module: AttributeRadiusHelper.glsl


Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen

All rights reserved.

See Copyright.txt or http://www.kitware.com/Copyright.htm for details.


This software is distributed WITHOUT ANY WARRANTY; without even

the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

PURPOSE. See the above copyright notice for more information.


=========================================================================*/


// .NAME AttributeRadiusHelper.glsl

// .SECTION Thanks

// <verbatim>

//

// This file is part of the PointSprites plugin developed and contributed by

//

// Copyright (c) CSCS - Swiss National Supercomputing Centre

// EDF - Electricite de France

//

// John Biddiscombe, Ugo Varetto (CSCS)

// Stephane Ploix (EDF)

//

// </verbatim>


uniform vec2 RadiusSpan;

attribute float Radius;


float GetRadius()

{

return RadiusSpan.x + Radius*RadiusSpan.y;

}






ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 540

vtkShaderProgram2 (0000000012D40520): shader #1/3 (vertex shader) log is:


. Its source code is:

/*=========================================================================


Program: Visualization Toolkit

Module: Texture_vs.glsl


Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen

All rights reserved.

See Copyright.txt or http://www.kitware.com/Copyright.htm for details.


This software is distributed WITHOUT ANY WARRANTY; without even

the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

PURPOSE. See the above copyright notice for more information.


=========================================================================*/


// .NAME Texture_vs.glsl

// .SECTION Thanks

// <verbatim>

//

// This file is part of the PointSprites plugin developed and contributed by

//

// Copyright (c) CSCS - Swiss National Supercomputing Centre

// EDF - Electricite de France

//

// John Biddiscombe, Ugo Varetto (CSCS)

// Stephane Ploix (EDF)

//

// </verbatim>


uniform float MaxPixelSize;

uniform vec2 viewport;


float GetRadius();


void propFuncVS()

{

float radius = GetRadius();


gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;

gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;

//

// Convert position to window coordinates

//


//

// Convert Radius to window coordinates

// radius/w is homogenous clip coord

//

float pixelSize = (radius/gl_Position.w)*(4.0*viewport.y);


// Clamp radius to prevent overloading if bad scalars were passed in

if (pixelSize>MaxPixelSize)

pixelSize = MaxPixelSize;


gl_PointSize = pixelSize;

gl_FrontColor = gl_Color;

}





ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 540

vtkShaderProgram2 (0000000012D40520): shader #2/3 (vertex shader) log is:


. Its source code is:

// ============================================================================

//

// Program: Visualization Toolkit

// Module: vtkOpenGLPropertyDefaultMain_vs.glsl

//

// Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen

// All rights reserved.

// See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

//

// This software is distributed WITHOUT ANY WARRANTY; without even

// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

// PURPOSE. See the above copyright notice for more information.

//

// ============================================================================


// This is the default vertex shader with the main() function. It is used when

// no main() is provided at the renderer level and some vertex shader is

// defined by the user on a property.


#version 110


void propFuncVS();


void main()

{

propFuncVS();

}





ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkOpenGLProperty.cxx, line 415

vtkPointSpriteProperty (000000001118DD20): Couldn't build the shader program. At this point , it can be an error in a shader or a driver bug.



ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 530

vtkShaderProgram2 (0000000012D40520): the shader program failed to link. Its log is:

the shaders are:



ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 540

vtkShaderProgram2 (0000000012D40520): shader #0/3 (vertex shader) log is:


. Its source code is:

/*=========================================================================


Program: Visualization Toolkit

Module: AttributeRadiusHelper.glsl


Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen

All rights reserved.

See Copyright.txt or http://www.kitware.com/Copyright.htm for details.


This software is distributed WITHOUT ANY WARRANTY; without even

the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

PURPOSE. See the above copyright notice for more information.


=========================================================================*/


// .NAME AttributeRadiusHelper.glsl

// .SECTION Thanks

// <verbatim>

//

// This file is part of the PointSprites plugin developed and contributed by

//

// Copyright (c) CSCS - Swiss National Supercomputing Centre

// EDF - Electricite de France

//

// John Biddiscombe, Ugo Varetto (CSCS)

// Stephane Ploix (EDF)

//

// </verbatim>


uniform vec2 RadiusSpan;

attribute float Radius;


float GetRadius()

{

return RadiusSpan.x + Radius*RadiusSpan.y;

}






ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 540

vtkShaderProgram2 (0000000012D40520): shader #1/3 (vertex shader) log is:


. Its source code is:

/*=========================================================================


Program: Visualization Toolkit

Module: Texture_vs.glsl


Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen

All rights reserved.

See Copyright.txt or http://www.kitware.com/Copyright.htm for details.


This software is distributed WITHOUT ANY WARRANTY; without even

the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

PURPOSE. See the above copyright notice for more information.


=========================================================================*/


// .NAME Texture_vs.glsl

// .SECTION Thanks

// <verbatim>

//

// This file is part of the PointSprites plugin developed and contributed by

//

// Copyright (c) CSCS - Swiss National Supercomputing Centre

// EDF - Electricite de France

//

// John Biddiscombe, Ugo Varetto (CSCS)

// Stephane Ploix (EDF)

//

// </verbatim>


uniform float MaxPixelSize;

uniform vec2 viewport;


float GetRadius();


void propFuncVS()

{

float radius = GetRadius();


gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;

gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;

//

// Convert position to window coordinates

//


//

// Convert Radius to window coordinates

// radius/w is homogenous clip coord

//

float pixelSize = (radius/gl_Position.w)*(4.0*viewport.y);


// Clamp radius to prevent overloading if bad scalars were passed in

if (pixelSize>MaxPixelSize)

pixelSize = MaxPixelSize;


gl_PointSize = pixelSize;

gl_FrontColor = gl_Color;

}





ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 540

vtkShaderProgram2 (0000000012D40520): shader #2/3 (vertex shader) log is:


. Its source code is:

// ============================================================================

//

// Program: Visualization Toolkit

// Module: vtkOpenGLPropertyDefaultMain_vs.glsl

//

// Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen

// All rights reserved.

// See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

//

// This software is distributed WITHOUT ANY WARRANTY; without even

// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

// PURPOSE. See the above copyright notice for more information.

//

// ============================================================================


// This is the default vertex shader with the main() function. It is used when

// no main() is provided at the renderer level and some vertex shader is

// defined by the user on a property.


#version 110


void propFuncVS();


void main()

{

propFuncVS();

}





ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkOpenGLProperty.cxx, line 415

vtkPointSpriteProperty (000000001118DD20): Couldn't build the shader program. At this point , it can be an error in a shader or a driver bug.



ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 1084

vtkShaderProgram2 (0000000012D40520): glGetAttribLocation 1 OpenGL errors detected

0 : (1281) Invalid value




ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 1084

vtkShaderProgram2 (0000000012D40520): glGetAttribLocation 1 OpenGL errors detected

0 : (1281) Invalid value




ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 1084

vtkShaderProgram2 (0000000012D40520): glGetAttribLocation 1 OpenGL errors detected

0 : (1281) Invalid value


Using PointSprite with Sphere and a constant radius fails with the following message,


ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 481

vtkShaderProgram2 (0000000012D40520): a shader failed to compile. Its log is:

WARNING: 0:89: 'assigning' : implict conversion between types allowed from GLSL 1.20

WARNING: 0:143: 'assigning' : implict conversion between types allowed from GLSL 1.20

WARNING: 0:159: 'assigning' : implict conversion between types allowed from GLSL 1.20

WARNING: 0:196: 'assigning' : implict conversion between types allowed from GLSL 1.20

WARNING: 0:207: 'assign' : implicit type conversion allowed from GLSL 1.20

ERROR: 0:207: '=' : cannot convert from 'const int' to '3-component vector of float'

ERROR: 0:216: 'assign' : cannot convert from '4-component vector of float' to '3-component vector of float'

ERROR: 0:217: 'N' : undeclared identifier

ERROR: 0:217: 'assign' : cannot convert from '3-component vector of float' to 'float'

ERROR: 0:218: 'dot' : no matching overloaded function found (using implicit conversion)

ERROR: 0:218: 'assign' : l-value required "d" (can't modify a varying)

ERROR: 0:219: 'viewdir' : undeclared identifier

ERROR: 0:219: 'assign' : cannot convert from '3-component vector of float' to 'float'

ERROR: 0:220: 'vl' : undeclared identifier

ERROR: 0:220: 'reflect' : no matching overloaded function found (using implicit conversion)

ERROR: 0:221: 's' : undeclared identifier

ERROR: 0:222: 'assign' : cannot convert from '4-component vector of float' to '3-component vector of float'

WARNING: 0:251: 'assigning' : implict conversion between types allowed from GLSL 1.20



. Its source code is:

/*=========================================================================


Program: Visualization Toolkit

Module: Quadrics_fs.glsl


Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen

All rights reserved.

See Copyright.txt or http://www.kitware.com/Copyright.htm for details.


This software is distributed WITHOUT ANY WARRANTY; without even

the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

PURPOSE. See the above copyright notice for more information.


=========================================================================*/


// .NAME Quadrics_fs.glsl

// .SECTION Thanks

// <verbatim>

//

// This file is part of the PointSprites plugin developed and contributed by

//

// Copyright (c) CSCS - Swiss National Supercomputing Centre

// EDF - Electricite de France

//

// John Biddiscombe, Ugo Varetto (CSCS)

// Stephane Ploix (EDF)

//

// </verbatim>


//

// IN:

// - vertex position

// - point size

// - ray origin

// - perspective flag

// - quadric equation coefficients

// - color

// - viewport (width and height only)

// - min point size (pointThreshold)

//

// OUT:

// - fragment color computed from point intersected by ray shot from

// viewpoint through point computed from current fragment coordinate

// - fragment depth computed by projecting the intersection point into screen

// coordinates



// OPTIMAL

#define ELLIPSOID

//#define CYLINDER

//#define CONE

//#define HYPERBOLOID1

//#define HYPERBOLOID2

//#define PARABOLOID


// SUB OPTIMAL

//#define HYPER_PARABOLOID


uniform vec2 viewport; // only width and height passed, no origin

uniform float pointSizeThreshold; // minimum point size


varying vec4 color;

varying float a;

varying float b;

varying float c;

varying float d;

varying float e;

varying float f;

varying float g;

varying float h;

varying float i;

varying float j;

varying float pointSize;

varying float perspective;


vec3 raydir; // ray direction in screen space

vec3 rayorigin; // ray origin in screen space


#ifndef ELLIPSOID

varying mat4 Ti;

#endif


const float FLAT_SHADE_POINT_SIZE = 1.0; //if point size < 1 use flat shading


const float FEPS = 0.0001;


const float BOUND = 1.0 + FEPS;


const vec3 MIN_BOUND = vec3(-BOUND);


const vec3 MAX_BOUND = vec3(BOUND);


//------------------------------------------------------------------------------

// BOUNDS CHECK

// in general it makes sense to check only along the z direction for:

// - paraboloids

// - hyperboloids of one sheet

// - cylinders

// - cones

// and no checking at all is required for ellipsoids

#ifndef ELLIPSOID

bool InBounds( vec3 P )

{

vec4 v = Ti * gl_ModelViewMatrixInverse * vec4( P, 1. );

#if defined( CYLINDER ) || defined( CONE ) || defined( HYPERBOLOID1 ) || defined( PARABOLOID )

return v.z >= -BOUND && v.z <= BOUND;

#else

return all( greaterThanEqual( v.xyz, MIN_BOUND ) ) &&

all( lessThanEqual( v.xyz, MAX_BOUND ) );

#endif

}

#endif

//------------------------------------------------------------------------------

// INTERSECTION

struct I

{

vec3 P;

vec3 N;

float t;

};


// compute unit normal from gradient

vec3 ComputeNormal(vec3 P)

{

return normalize(vec3(dot(vec4(a, d, e, 1.), vec4(P, g)), // should multiply by 2 for actual gradient

dot(vec4(d, b, f, 1.), vec4(P, h)), // should multiply by 2 for actual gradient

dot(vec4(e, f, c, 1.), vec4(P, i)) // should multiply by 2 for actual gradient

));

}


// compute ray quadric intersection; if no intersection occurs I.t is < 0

// main axis length and orientation are used to clip the quadric; not

// required for closed quadrics (ellipsoids)

// | a d e g |

// | d b f h |

// | e f c i |

// | g h i j |

// ax^2 + by^2 + cz^2 + 2dxy +2exz + 2fyz + 2gx + 2hy + 2iz + j = 0

/// @todo pass vec3(a, b, c), vec3( d, e, f ) and vec3( g, h, i ) instead of single coefficients

I ComputeRayQuadricIntersection()

{

I ip;

ip.t = -1.0;

vec3 P = rayorigin;

vec3 D = raydir;

float A = 0.0;

float B = 0.0;

float C = 0.0;

if (bool(perspective))

{

A = dot(vec3(a, b, c), D * D) + 2. * dot(vec3(d, e, f), D.xxy * D.yzz);

B = 2. * dot(vec3(g, h, i), D);

C = j;

}

else

{

A = c;

//B = -2. * dot( vec4( c, e, f, 1. ), vec4( P.zxy, 1. ) );

B = -2. * dot(vec4(d, e, f, i), vec4(P.zxy, 1.));

C = dot(vec3(a, b, c), P * P) + 2. * (dot(vec3(d, e, f), P.xxy * P.yzz)

+ dot(vec3(g, h, i), P)) + j;

}

float delta = B * B - 4. * A * C;

if (delta < 0.0)

return ip;

float d = sqrt(delta);

A = 1. / A;

A *= 0.5;

float t2 = A * (-B + d);

float t1 = A * (-B - d);

#ifdef ELLIPSOID

ip.P = rayorigin + D * min(t1, t2);

ip.N = ComputeNormal(ip.P);

ip.t = 0.;

#else

vec3 P1 = rayorigin + D * min( t1, t2 );

vec3 P2 = rayorigin + D * max( t1, t2 );

if( InBounds( P1 ) )

{

ip.P = P1;

ip.N = ComputeNormal( P1 );

ip.t = 0.;

}

else if( InBounds( P2 ) )

{

ip.P = P2;

ip.N = ComputeNormal( P2 );

ip.t = 0.;

}

#endif

return ip;

}


//------------------------------------------------------------------------------

// LIGHTING, standard phong lighting model

vec3 lightDir = normalize(vec3(0.1, 0.1, 1.));

float kd = 1.0;

float ka = 0.01;

float ks = .5;

float sh = 90.0;

vec4 refcolor = vec4(1., 1., 1., 1.);

vec4 ComputeColor(vec4 color, vec3 n, vec3 P)

{

if (pointSize < FLAT_SHADE_POINT_SIZE)

return color;


vec3 col = (0, 0, 0);

vec3 N;

float d;

vec3 viewdir;

float vl;

float s;


for (int li = 0; li < 4; li++)

{

lightDir = normalize(gl_LightSource[li].position);

N = faceforward(-n, lightDir, n);

d = dot(N, lightDir);

viewdir = normalize(-P);

vl = max(0., dot(reflect(-lightDir, N), viewdir));

s = pow(vl, gl_FrontMaterial.shininess);

col += gl_FrontMaterial.specular * s * gl_LightSource[li].specular.rgb + kd

* d * color.rgb * gl_LightSource[li].diffuse.rgb + ka * color.rgb

* gl_LightSource[li].ambient.rgb;

}


return vec4(col, color.a);


}


//------------------------------------------------------------------------------

// MAIN

void propFuncFS(void)

{

if (pointSize < pointSizeThreshold || color.a <= 0.0)

discard;

vec3 fc = gl_FragCoord.xyz;

fc.xy /= viewport;

fc *= 2.0;

fc -= 1.0;

vec4 p = gl_ProjectionMatrixInverse * vec4(fc, 1.);

if (bool(perspective))

{

// in perspective mode, rayorigin is always at (0, 0, 0)

rayorigin = vec3(0., 0., 0.);

raydir = vec3(p) / p.w;

}

else

{

// in orthographic mode, raydir is always ( 0., 0., -1. );

raydir = vec3(0., 0., -1.);

rayorigin = vec3(p.x / p.w, p.y / p.w, 0.);

}

// compute intersection

I i = ComputeRayQuadricIntersection();

if (i.t < 0.0)

discard;

// compute color

gl_FragColor = ComputeColor(color, i.N, i.P);

// update depth by projecting point and updating depth coordinate

// the transposed version of the projection matrix is used to

// perform vector, matrix row product in one line:

// M[2][*] x V = Vt x Mt[*][2] where:

// % V is a column vector

// % Vt is a row vector

// % M is a square matrix

// % Mt is the transpose of M

float z = dot(vec4(i.P, 1.), gl_ProjectionMatrixTranspose[2]);

float w = dot(vec4(i.P, 1.), gl_ProjectionMatrixTranspose[3]);

gl_FragDepth = 0.5 * (z / w + 1.0);

}





ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkOpenGLProperty.cxx, line 415

vtkPointSpriteProperty (000000001118DD20): Couldn't build the shader program. At this point , it can be an error in a shader or a driver bug.



ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 481

vtkShaderProgram2 (0000000012D40520): a shader failed to compile. Its log is:

WARNING: 0:89: 'assigning' : implict conversion between types allowed from GLSL 1.20

WARNING: 0:143: 'assigning' : implict conversion between types allowed from GLSL 1.20

WARNING: 0:159: 'assigning' : implict conversion between types allowed from GLSL 1.20

WARNING: 0:196: 'assigning' : implict conversion between types allowed from GLSL 1.20

WARNING: 0:207: 'assign' : implicit type conversion allowed from GLSL 1.20

ERROR: 0:207: '=' : cannot convert from 'const int' to '3-component vector of float'

ERROR: 0:216: 'assign' : cannot convert from '4-component vector of float' to '3-component vector of float'

ERROR: 0:217: 'N' : undeclared identifier

ERROR: 0:217: 'assign' : cannot convert from '3-component vector of float' to 'float'

ERROR: 0:218: 'dot' : no matching overloaded function found (using implicit conversion)

ERROR: 0:218: 'assign' : l-value required "d" (can't modify a varying)

ERROR: 0:219: 'viewdir' : undeclared identifier

ERROR: 0:219: 'assign' : cannot convert from '3-component vector of float' to 'float'

ERROR: 0:220: 'vl' : undeclared identifier

ERROR: 0:220: 'reflect' : no matching overloaded function found (using implicit conversion)

ERROR: 0:221: 's' : undeclared identifier

ERROR: 0:222: 'assign' : cannot convert from '4-component vector of float' to '3-component vector of float'

WARNING: 0:251: 'assigning' : implict conversion between types allowed from GLSL 1.20



. Its source code is:

/*=========================================================================


Program: Visualization Toolkit

Module: Quadrics_fs.glsl


Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen

All rights reserved.

See Copyright.txt or http://www.kitware.com/Copyright.htm for details.


This software is distributed WITHOUT ANY WARRANTY; without even

the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

PURPOSE. See the above copyright notice for more information.


=========================================================================*/


// .NAME Quadrics_fs.glsl

// .SECTION Thanks

// <verbatim>

//

// This file is part of the PointSprites plugin developed and contributed by

//

// Copyright (c) CSCS - Swiss National Supercomputing Centre

// EDF - Electricite de France

//

// John Biddiscombe, Ugo Varetto (CSCS)

// Stephane Ploix (EDF)

//

// </verbatim>


//

// IN:

// - vertex position

// - point size

// - ray origin

// - perspective flag

// - quadric equation coefficients

// - color

// - viewport (width and height only)

// - min point size (pointThreshold)

//

// OUT:

// - fragment color computed from point intersected by ray shot from

// viewpoint through point computed from current fragment coordinate

// - fragment depth computed by projecting the intersection point into screen

// coordinates



// OPTIMAL

#define ELLIPSOID

//#define CYLINDER

//#define CONE

//#define HYPERBOLOID1

//#define HYPERBOLOID2

//#define PARABOLOID


// SUB OPTIMAL

//#define HYPER_PARABOLOID


uniform vec2 viewport; // only width and height passed, no origin

uniform float pointSizeThreshold; // minimum point size


varying vec4 color;

varying float a;

varying float b;

varying float c;

varying float d;

varying float e;

varying float f;

varying float g;

varying float h;

varying float i;

varying float j;

varying float pointSize;

varying float perspective;


vec3 raydir; // ray direction in screen space

vec3 rayorigin; // ray origin in screen space


#ifndef ELLIPSOID

varying mat4 Ti;

#endif


const float FLAT_SHADE_POINT_SIZE = 1.0; //if point size < 1 use flat shading


const float FEPS = 0.0001;


const float BOUND = 1.0 + FEPS;


const vec3 MIN_BOUND = vec3(-BOUND);


const vec3 MAX_BOUND = vec3(BOUND);


//------------------------------------------------------------------------------

// BOUNDS CHECK

// in general it makes sense to check only along the z direction for:

// - paraboloids

// - hyperboloids of one sheet

// - cylinders

// - cones

// and no checking at all is required for ellipsoids

#ifndef ELLIPSOID

bool InBounds( vec3 P )

{

vec4 v = Ti * gl_ModelViewMatrixInverse * vec4( P, 1. );

#if defined( CYLINDER ) || defined( CONE ) || defined( HYPERBOLOID1 ) || defined( PARABOLOID )

return v.z >= -BOUND && v.z <= BOUND;

#else

return all( greaterThanEqual( v.xyz, MIN_BOUND ) ) &&

all( lessThanEqual( v.xyz, MAX_BOUND ) );

#endif

}

#endif

//------------------------------------------------------------------------------

// INTERSECTION

struct I

{

vec3 P;

vec3 N;

float t;

};


// compute unit normal from gradient

vec3 ComputeNormal(vec3 P)

{

return normalize(vec3(dot(vec4(a, d, e, 1.), vec4(P, g)), // should multiply by 2 for actual gradient

dot(vec4(d, b, f, 1.), vec4(P, h)), // should multiply by 2 for actual gradient

dot(vec4(e, f, c, 1.), vec4(P, i)) // should multiply by 2 for actual gradient

));

}


// compute ray quadric intersection; if no intersection occurs I.t is < 0

// main axis length and orientation are used to clip the quadric; not

// required for closed quadrics (ellipsoids)

// | a d e g |

// | d b f h |

// | e f c i |

// | g h i j |

// ax^2 + by^2 + cz^2 + 2dxy +2exz + 2fyz + 2gx + 2hy + 2iz + j = 0

/// @todo pass vec3(a, b, c), vec3( d, e, f ) and vec3( g, h, i ) instead of single coefficients

I ComputeRayQuadricIntersection()

{

I ip;

ip.t = -1.0;

vec3 P = rayorigin;

vec3 D = raydir;

float A = 0.0;

float B = 0.0;

float C = 0.0;

if (bool(perspective))

{

A = dot(vec3(a, b, c), D * D) + 2. * dot(vec3(d, e, f), D.xxy * D.yzz);

B = 2. * dot(vec3(g, h, i), D);

C = j;

}

else

{

A = c;

//B = -2. * dot( vec4( c, e, f, 1. ), vec4( P.zxy, 1. ) );

B = -2. * dot(vec4(d, e, f, i), vec4(P.zxy, 1.));

C = dot(vec3(a, b, c), P * P) + 2. * (dot(vec3(d, e, f), P.xxy * P.yzz)

+ dot(vec3(g, h, i), P)) + j;

}

float delta = B * B - 4. * A * C;

if (delta < 0.0)

return ip;

float d = sqrt(delta);

A = 1. / A;

A *= 0.5;

float t2 = A * (-B + d);

float t1 = A * (-B - d);

#ifdef ELLIPSOID

ip.P = rayorigin + D * min(t1, t2);

ip.N = ComputeNormal(ip.P);

ip.t = 0.;

#else

vec3 P1 = rayorigin + D * min( t1, t2 );

vec3 P2 = rayorigin + D * max( t1, t2 );

if( InBounds( P1 ) )

{

ip.P = P1;

ip.N = ComputeNormal( P1 );

ip.t = 0.;

}

else if( InBounds( P2 ) )

{

ip.P = P2;

ip.N = ComputeNormal( P2 );

ip.t = 0.;

}

#endif

return ip;

}


//------------------------------------------------------------------------------

// LIGHTING, standard phong lighting model

vec3 lightDir = normalize(vec3(0.1, 0.1, 1.));

float kd = 1.0;

float ka = 0.01;

float ks = .5;

float sh = 90.0;

vec4 refcolor = vec4(1., 1., 1., 1.);

vec4 ComputeColor(vec4 color, vec3 n, vec3 P)

{

if (pointSize < FLAT_SHADE_POINT_SIZE)

return color;


vec3 col = (0, 0, 0);

vec3 N;

float d;

vec3 viewdir;

float vl;

float s;


for (int li = 0; li < 4; li++)

{

lightDir = normalize(gl_LightSource[li].position);

N = faceforward(-n, lightDir, n);

d = dot(N, lightDir);

viewdir = normalize(-P);

vl = max(0., dot(reflect(-lightDir, N), viewdir));

s = pow(vl, gl_FrontMaterial.shininess);

col += gl_FrontMaterial.specular * s * gl_LightSource[li].specular.rgb + kd

* d * color.rgb * gl_LightSource[li].diffuse.rgb + ka * color.rgb

* gl_LightSource[li].ambient.rgb;

}


return vec4(col, color.a);


}


//------------------------------------------------------------------------------

// MAIN

void propFuncFS(void)

{

if (pointSize < pointSizeThreshold || color.a <= 0.0)

discard;

vec3 fc = gl_FragCoord.xyz;

fc.xy /= viewport;

fc *= 2.0;

fc -= 1.0;

vec4 p = gl_ProjectionMatrixInverse * vec4(fc, 1.);

if (bool(perspective))

{

// in perspective mode, rayorigin is always at (0, 0, 0)

rayorigin = vec3(0., 0., 0.);

raydir = vec3(p) / p.w;

}

else

{

// in orthographic mode, raydir is always ( 0., 0., -1. );

raydir = vec3(0., 0., -1.);

rayorigin = vec3(p.x / p.w, p.y / p.w, 0.);

}

// compute intersection

I i = ComputeRayQuadricIntersection();

if (i.t < 0.0)

discard;

// compute color

gl_FragColor = ComputeColor(color, i.N, i.P);

// update depth by projecting point and updating depth coordinate

// the transposed version of the projection matrix is used to

// perform vector, matrix row product in one line:

// M[2][*] x V = Vt x Mt[*][2] where:

// % V is a column vector

// % Vt is a row vector

// % M is a square matrix

// % Mt is the transpose of M

float z = dot(vec4(i.P, 1.), gl_ProjectionMatrixTranspose[2]);

float w = dot(vec4(i.P, 1.), gl_ProjectionMatrixTranspose[3]);

gl_FragDepth = 0.5 * (z / w + 1.0);

}





ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkOpenGLProperty.cxx, line 415

vtkPointSpriteProperty (000000001118DD20): Couldn't build the shader program. At this point , it can be an error in a shader or a driver bug.


Cheers,

Bruce


On Mon, Feb 10, 2014 at 11:51 AM, Aashish Chaudhary <aashish.chaudhary at kitware.com<mailto:aashish.chaudhary at kitware.com>> wrote:
Atleast, we need to know what shader its trying to use which is failing to compile on your system (TextureSprite, Quadrics (Attribute or Fixed Radius))


On Mon, Feb 10, 2014 at 11:44 AM, Aashish Chaudhary <aashish.chaudhary at kitware.com<mailto:aashish.chaudhary at kitware.com>> wrote:
Hi Bruce,

Sorry, I thought replied to your email. In the log you sent me, I do see that it is stating that point sprites are supported. If you can put a break point in vtkPointSpriteProperty (at the error line) then we can find out exactly where the error is coming from.

- Aashish



On Mon, Feb 10, 2014 at 11:14 AM, Bruce Jones <bruce.david.jones at gmail.com<mailto:bruce.david.jones at gmail.com>> wrote:
Is there anything else I can do to help debug this problem? It is quite frustrating to not have pointsprite working on this machine.

Cheers,
Bruce


On Sun, Jan 26, 2014 at 6:26 PM, Bruce Jones <bruce.david.jones at gmail.com<mailto:bruce.david.jones at gmail.com>> wrote:
Ok, I've attached the output from glview. Everything is supported for OpenGL <=4.2. versions 4.3 and 4.4 are partially supported.

Cheers,
Bruce


On Thu, Jan 23, 2014 at 11:51 AM, Aashish Chaudhary <aashish.chaudhary at kitware.com<mailto:aashish.chaudhary at kitware.com>> wrote:
http://www.realtech-vr.com/glview/


On Wed, Jan 22, 2014 at 9:35 AM, Bruce Jones <bruce.david.jones at gmail.com<mailto:bruce.david.jones at gmail.com>> wrote:
This is windows 8.1, is there a similar utility I can run on windows?

Cheers,
Bruce


On Wed, Jan 22, 2014 at 9:31 AM, Aashish Chaudhary <aashish.chaudhary at kitware.com<mailto:aashish.chaudhary at kitware.com>> wrote:
Is this a windows OS or Linux? If Linux can you send us the output of glxinfo (as a starting point to debug this).

Thanks,



On Wed, Jan 22, 2014 at 8:56 AM, Bruce Jones <bruce.david.jones at gmail.com<mailto:bruce.david.jones at gmail.com>> wrote:
When using the PointSprite plugin on a new laptop I found two options cause it to stop working.

When changing from "Sphere (texture)" to "Sphere"  get the following,


ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkOpenGLProperty.cxx, line 415

vtkPointSpriteProperty (000000000BD110B0): Couldn't build the shader program. At this point , it can be an error in a shader or a driver bug.


I thought this might be due to lack of opengl support for the graphics chip, which comes bundled with the I7-4600u I have. However intel claim it supports up to version 4.2 of OpenGL, so that should be fine...


Also, when i choose to scale the point sprite size by values in an array, I get the following error,


ERROR: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\OpenGL\vtkShaderProgram2.cxx, line 1084

vtkShaderProgram2 (0000000014D4A1A0): glGetAttribLocation 1 OpenGL errors detected

0 : (1281) Invalid value


Is there any solution for this?


Cheers,

Bruce

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview




--
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com<http://www.kitware.com>




--
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com<http://www.kitware.com>





--
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com<http://www.kitware.com>



--
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com<http://www.kitware.com>




--
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com<http://www.kitware.com>



--
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com<http://www.kitware.com>



--
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com<http://www.kitware.com>


More information about the ParaView mailing list