• Interactive Poisson Blending on GPU
    Interactive Poisson Blending on GPU
  • 404 Not Found In Two Triangles
    404 Not Found In Two Triangles
  • Simplest and Fastest GLSL Edge Detection using Fwidth
    Simplest and Fastest GLSL Edge Detection using Fwidth

Category: Code

Interactive Poisson Blending on GPU

Recently, I have implemented two fragment shaders for interactive Poisson Blending (seamless blending).  Here is my real-time demo and code on ShaderToy: Press 1 for normal mode, press 2 for mixed gradients, press space to clear the canvas. Technical Brief I followed a simplified routine of the Poisson Image Editing paper [P. Pérez, M. Gangnet,…


C++ Code Backup for Render-To-Texture (Mult-pass Rendering)

I have found that many code for multipass rendering is complex and redundant to understand, so I would like to write a post for further reference. The key to multi-pass rendering is, instead of rendering to screen (frame buffer 0), reorient the rendering target to a framebuffer (e.g. frame buffer 1), bind the output of the…


Fisher-Yates Shuffle

The correct way to do a shuffle is to choose a random other index to fill in the current index, which is uniform:

  Also, you may need a uniform random generator in C++:

 


Protected: Optimization Using Sum-to-Product Identities

There is no excerpt because this is a protected post.


N Queens Problem Revisit using Bit Operations

Finally, I have some time to revisit the N queens problem using bit operations. The following functions could solve 11 queens in 1 second:

So far to me, this is the most efficient algorithm for N queens. The code is mostly self-explenary. Please comment if anything cannot be understood.

 


Simplest and Fatest GLSL Edge Detection using Fwidth

GLSL Edge Detection Yesterday, I read 834144373’s ShaderToy code which did GLSL Edge Detection in 97 chars, it was really simple and fast:

Meanwhile, the rendering result is astonishingly awesome: However, there are some noise from the GLSL edge detection. Thus, I have made a little improvement on this algorithm and produced cleaner edges in this ShaderToy…


Testing GPUs Computational Power

Have you think of how many summation & multiply operations can you do within for-loops in GPU fragment shader? I irrigorously tested the following fragment shader on ShaderToy, which gives me 100,000 operations at 22 FPS on a GTX 1080, for 25, 000 operations, it runs smoothly at 60 FPS. So, what’s the limitation of…


Timer: How to Measure Execution Time in C++ 11

Timer is important for measuring speed-ups, or elapsed time for comparing different algorithms. We used to import <ctime> and measure the elapsed time with the following code:

However, the clock() function measures the CPU time, not actual time elapsed (which may be much greater), according to this StackOverFlow thread. Hence, here I share my code…


404 Not Found in Two Triangles

Inspred by 104 from ShaderToy, I made a new 404 Not Found page with two triangles in GLSL using calligraphic strokes. Live Demo Please visit: http://duruofei.com/404 or   Code

 


Output M Numbers from [0, N-1], N >> M