GPU down sampling for Point Based Rendering

Source: Internet
Author: User

Abstract: Can the Ewa Rendering Method of dot rendering have the graphic effects produced by real-time GPU oversampling of our workers? Certainly not.
Abstract: Is the Ewa splatting will be better than my GPU multipass supersampling method? Of course not!
Zusammemfasloud: ist die Ewa splatting so besser als meine GPU multipass supersampling methode? Naturlich nicht!

After careful tests and trade-offs, I decided to discard the Ewa Filtering Technology and turn to the GPU supersampling method to filter Image Based on dot rendering.

During careful benchmark and balancing, I decide to abandon the Ewa filter, turn to use GPU supersampling filter method in offline rendering, did as the same as NVIDIA gelato.

The specific method is the same as that of gelato. Raster ultra-high-resolution images with hardware capabilities, and then use the filters used by offline Renderer (Catmull-Rom, Gaussian, sinc, etc) perform convolution filtering in the X and Y directions in the frame buffer. The image quality of the result is much higher than that obtained by the Ewa filter, which is almost the level of offline rendering, performance is almost zero, avoiding the use of hardware-provided poor msaa.

We will render the whole scene into a big enough RT (render target) not beyond the capability of hardware, filter this RT by Catmull-Rom, Gaussian, sinc filters etc. it divides into x and y pass, results nearly as the same result as offline render for preview relighting result, its quality is much better than Ewa, avoid to using msaa supplied by poor hardware.

The procedure is simple. The image is rendered to the RT (render target, the same below) based on the user-defined supersampling rate. Then the sampling filter generates a search table and calculates the actual filter radius. Set the texture addressing mode of the original RT to gl_clamp_to_edge, instead of gl_clamp or gl_repeat. Create FBO and create two temporary rt. The first temporary RT stores the filtered results in the X direction, and the second stores the results completely filtered, if needed, the output is an image in the specified format. Below are some trivialCodeBlock and graph, for reference only. The filter code comes from renderman interface specfication.

Int Ssrate = Rt. Width () / Dstsizex; // Calculate the supersampling rate. In order to save trouble, the supersampling rate in the XY direction is the same.
Int Realradius = Filterradius * Ssrate;
Float Weightsum =   0.0f ;
For ( Int I =- Realradius; I < Realradius; I ++ )
{
Float W = Ricatmullromfilter (I + 0.5 ) / ( Float ) Realradius, 0 , Filterradius, filterradius );
Weightsum + = W;
Weights. push_back (w );
}
Float * Weightptr =   New   Float [Weights. Size ()];
For (Size_t I = 0 ; I < Weights. Size (); I ++ )
{
Weightptr [I]=Weights [I]/Weightsum;
Printf ("% F \ n", Weightptr [I]);
}
Glgentextures ( 1 , & Filtertex ); // Filter texture
Glbindtexture (gl_texture_rectangle_arb, filtertex );
Glteximage2d (gl_texture_rectangle_arb, 0 , Gl_alpha32f_arb, weights. Size (), 1 , 0 , Gl_alpha, gl_float, weightptr );
Gltexparameterf (gl_texture_rectangle_arb, gl_texture_min_filter, gl_nearest );
Gltexparameterf (gl_texture_rectangle_arb, gl_texture_mag_filter, gl_nearest );
Gltexparameterf (gl_texture_rectangle_arb, gl_texture_wrap_s, gl_clamp_to_edge );
Gltexparameterf (gl_texture_rectangle_arb, gl_texture_wrap_t, gl_clamp_to_edge );
Delete [] weightptr;
Weights. Clear ();


// Copyright Bo schwarzstein (BO [Dot] schwarzstein [at] Gmail [Dot] com) 2008
// Filter on X | y direction, Y is in comment.
// Tex0 binds the origin Sampler
// Tex1 binds the filter weights
// Weightnum is used for Loop
// Ssrate is used to calculate the correct pixel offset on orgin Sampler

Uniform samplerrect tex0;
Uniform samplerrect tex1;
Uniform Int Weightnum;
Uniform Int Ssrate;

Void Main ()
{
Vec4 wpos = Gl_fragcoord;

Vec2 Center = Vec2 (wpos. x + 0.5 ) * Float (Ssrate), wpos. y ); // Vec2 center = vec2 (wpos. X, (Ceil (wpos. Y) + 0.5) * float (ssrate ));
For ( Int I = 0 ; I < Weightnum; I ++ )
{
Float Weight = Texturerect (tex1, vec2 ( Float (I) + 0.5 , 0.0 ).;
Gl_fragcolor + = Weight * Texturerect (tex0, center + Vec2 ( Float (I - Weightnum ), 0.0 ));
}
}

One local area (click to view the larger image)
Local Area (click to view large picture)



The filter radius is 2X2, the super sampling rate is 4x4, the Gaussian filter is on the left, and the Catmull-Rom filter is on the right (click to view the large image)
Filter radius 2X2, supersampling rate 4x4, left is using Gaussian filter, right is using Catmull-Rom filter (click to view large picture)

Some friends may say, "You don't know how to divide tile ?", Yes, I tried it, but if tile is used for rendering, the dot-based rendering technology will all be overturned, as shown in that the vertices obtained using the modified perspective transform matrix are incorrect, in this case, the calculation of the size of the correct point cannot be performed ". In addition, multiple tile will inevitably waste a lot of pixel filling rate. It is better to render a super-large RT quickly.

maybe some guy will say, "you big shit why not render tile by tile? ", Yes, I tried, if did that, the All GPU Point Based Rendering Method will become" shit ". because if we rendering tile with modified perspective matrix, it will be wrong, it's not Perspective correct result.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.