1mjb – February 6, 2013Oregon State UniversityComputer GraphicsScientific and Engineering Visualization Using ShadersMike [email protected] State Universitymjb – February 6, 2013Oregon State UniversityComputer GraphicsCan Do Image Processing on Dynamic Scenes with a Two-pass ApproachPass #1Pass #2Render a 3D dynamic sceneTextureRender a quadrilateral FramebufferLightingShaderBlurShader2mjb – February 6, 2013Oregon State UniversityComputer GraphicsThe negative of a 3D object often reveals detailsmjb – February 6, 2013Oregon State UniversityComputer GraphicsEmbossingChanging the emboss angle is interesting.3mjb – February 6, 2013Oregon State UniversityComputer GraphicsVisualization Imaging -- Sharpeningmjb – February 6, 2013Oregon State UniversityComputer GraphicsVisualization Imaging – Edge Detection4mjb – February 6, 2013Oregon State UniversityComputer GraphicsNon-Photorealistic Rendering – Toon RenderingUse the GPU to enhance scientific and engineering illustrationmjb – February 6, 2013Oregon State UniversityComputer GraphicsImage Manipulation Example – Where is it Likely to Snow?Visible Infrared Water vaporif( have_clouds && have_a_low_temperature && have_water_vapor )color = green;elsecolor = from visible map5mjb – February 6, 2013Oregon State UniversityComputer GraphicsVisualization -- Polar Hyperbolic SpaceUse the GPU to perform nonlinear vertex transformations'Θ = Θ'RRR K=+mjb – February 6, 2013Oregon State UniversityComputer GraphicsDome Projection for Immersive VisualizationUse the GPU to perform nonlinear vertex transformations6mjb – February 6, 2013Oregon State UniversityComputer GraphicsPlacing 3D Point Cloud Data into a Floating-Point Texture for glmanfwrite( &nums, 4, 1, fp );fwrite( &numt, 4, 1, fp );fwrite( &nump, 4, 1, fp );for( int p = 0; p < nump; p++ ){for( int t = 0; t < numt; t++ ){for( int s = 0; s < nums; s++ ){float red, green, blue, alpha;<< assign red, green blue, alpha >>fwrite( &red, 4, 1, fp );fwrite( &green, 4, 1, fp );fwrite( &blue, 4, 1, fp );fwrite( &alpha, 4, 1, fp );}}}mjb – February 6, 2013Oregon State UniversityComputer GraphicsPoint Cloud from a 3D Texture DatasetFull dataLow values culled7mjb – February 6, 2013Oregon State UniversityComputer GraphicsWhere to Place the Geometry?I personally like thinking of the data as living in a cube that ranges from -1. to 1. in X, Y, and Z. It is easy to position geometry in this space and easy to view and transform it. This means that any 3D object in that space, not just a point cloud, can map itself to the 3D texture data space.So, because the s texture coordinate goes from 0. to 1., then the linear mapping from the physical x coordinate to the texture s coordinate is:The same mapping applies to y and z to create the t and p texture coordinates.In GLSL, this can be done in one line of code:vec3 stp = ( xyz + 1. ) / 2.;1.2.xs+=mjb – February 6, 2013Oregon State UniversityComputer GraphicsThe Vertex Shaderout vec3 vMC;voidmain( ){vMC = aVertex.xyz;gl_Position = uModelViewProjectionMatrix * aVertex;}8mjb – February 6, 2013Oregon State UniversityComputer GraphicsThe Fragment Shaderuniform float uMin, uMax;uniform sampler3D uTexUnit;in vec3 vMC;out vec4 fFragColor;const float SMIN = 0.;const float SMAX = 120.;voidmain( ){vec3 stp = ( vMC + 1. ) / 2.; // maps [-1.,1.] to [0.,1.]if( any( lessThan( stp, vec3(0.,0.,0.) ) ) )discard;if( any( greaterThan( stp, vec3(1.,1.,1.) ) ) )discard;float scalar = texture3D( uTexUnit, stp ).r; // data is in the red componentif( scalar < uMin || scalar > uMax )discard;float t = ( scalar - SMIN ) / ( SMAX - SMIN );vec3 rgb = Rainbow( t );fFragColor = vec4( rgb, 1. );}mjb – February 6, 2013Oregon State UniversityComputer GraphicsA Problem with Uniform Pointclouds:Row-of-Corn and Moire PatternsOrthographicPerspective9mjb – February 6, 2013Oregon State UniversityComputer GraphicsUniform Points vs. Jittered Points“Pointcloud”“Jittercloud”mjb – February 6, 2013Oregon State UniversityComputer GraphicsEnhanced Point CloudsThe shaders can potentially change:• Color• Alpha• Pointsize10mjb – February 6, 2013Oregon State UniversityComputer GraphicsNow, change the Point Cloud geometry to a quadrilateral geometry. If we keep the coordinate range from -1. to 1., then the same shader code will work, except that we now want to base the color assignment on Eye Coordinates instead of Model Coordinates:Color Cutting PlanesNote that the plane can be oriented at any angle because the s-t-p data lookup comes from the x-y-z coordinates of the cutting planein vec3 vEC;voidmain( ){vec3 stp = ( vEC + 1. ) / 2.;// maps [-1.,1.] to [0.,1.]. . .mjb – February 6, 2013Oregon State UniversityComputer GraphicsLet’s say that we want “contour gaps” at each 10 degrees of temperature. Then the main change to the shader will be that we need to find how close each fragment’s interpolated scalar data value is to an even multiple of 10. To do this, we add this code to the fragment shader:float scalar10 = float( 10*int( (scalar+5.)/10. ) );if( abs( scalar - scalar10 ) > uTol )discard;Notice that this uses a uniform variable called uTol, which is read from a slider and has a range of 0. to 5. uTol is used to determine how close to an even multiple of 10 degrees we will accept, and thus how thick we want the contour gaps to be.Contour Cutting Planes11mjb – February 6, 2013Oregon State UniversityComputer GraphicsNote that when uTol=5., the uTol if-statementfloat scalar10 = float( 10*int( (scalar+5.)/10. ) );if( abs( scalar - scalar10 ) > uTol )discard;always fails, and we end up with the same display as we had with the interpolated colors. Thus, we wouldn’t actually need a separate color cutting plane shader at all. Shaders that can do double duty are always appreciated!Contour Cutting Planes are Also Color Cutting Planesmjb – February 6, 2013Oregon State UniversityComputer Graphics3D Data Probe – Mapping the Data to Arbitrary GeometrySome shapes make better probes than other do…12mjb – February 6, 2013Oregon State UniversityComputer GraphicsAn ObservationNote that Point Clouds, Jitter Clouds, Colored Cutting Planes, Contour Cutting Planes, and 3D Data Probes are really all the same technique!They just vary in what type of geometry the data is mapped to. They use the same shader code, possibly with a switch between model and eye coordinates.How about something less obvious like a
View Full Document