• 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

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

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

However, the result is astonishingly good: Let’s expand the code a little bit:

According to OpenGL manual: fwidth means  abs(dFdx(p)) + abs(dFdy(p)) and fwidthFine is equivalent to abs(dFdxFine(p)) + abs(dFdyFine(p)). One can use a sigmoid function to increase the…


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 custom algorithms. We used to import <ctime> and measure time with:

However, clock() measures CPU time, not actual time elapsed (which may be much greater) according to this StackOverFlow. Hence, here provides my code snippets to measure execution time in C++ as a DebugTimer Class….


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

 


Quick Fix: PHP SSL certificate error: unable to get local issuer certificate

Steps: Go to https://github.com/bagder/ca-bundle/tree/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09 Fork or download the repository, put the file ca-bundle.crt in a certain place. Open php.ini, add two lines of code: curl.cainfo=“your-dir/ca-bundle.crt” openssl.cafile=“your-dir/ca-bundle.crt” Everything works fantastically now!   This is useful for your are scraping the Twitter.


Do We Really Need 24-bit Color? Floyd–Steinberg Dithering

Do We Really Need 24-bit Color? When I was paining in childhood, I only have 24 colors, and somethings I only buy 4 colors to use (i.e., red, green, blue and white). However, blending of all colors could create vivid pictures. (image from pininterest) On the other side, the storage of digital colors in computer…


ACM UIST 2015 Summary from AR / VR Perspective

It was a great pleasure to attend the ACM UIST 2015 conference at Charlotte, NC for the first time. First, let me explain my initial motivation to UIST (skip this if you felt boring 🙂 I just keep it as a memory. The first time I learnt about HCI is when I was conducting a student research project, EyeControl, in…