Here is some sample OpenCL code to show just how simple it is: float alpha = read_imagef(tex3dIn, g_textureSampler, textureCoords).w įloat3 color = (alpha < 0.5f) ? (float3)(1.0f) : (float3)(0.0f) īoth of these techniques are super fast, and blur the line between vector and rasterized graphics a bit. I also wrote some stuff about it on my blog: To give you an idea of how well the second technique works, this 1024x768 mustache image was generated from a 64x32 source image that had a single color channel! (aka 2KB uncompressed) The decoding is so simple, it could be implemented even on fixed function hardware using only an alpha test! You can see a faux implementation of it on shadertoy here:Īs for the second method, here's a method from Valve, where distances to a shape are stored in a texture, instead of pixel data, allowing vector graphics to be drawn by using texture sampling. In your shader, if the interpolated texture coordinate (x*x-y) is < 0, the pixel is underneath the curve, else it's above the curve. The basic idea is that you set your triangle corner positions to be the 3 control point positions, and you set the texture coordinates at each corner to be (0,0), (0.5,0) and (1,1) respectively. Loop and Blinn show how to render a vector graphics quadratic bezier curve by rendering a single triangle, and using the texture coordinates in a pixel shader to say whether a pixel is above or below the curve: ![]() Here are some high performance vector graphics methods that are rendered using traditionally rasterization methods. ![]() As TheBuzzSaw said, it does depend on lots of things, including implementations of the rasterized graphics vs the vector graphics.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |