• 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

Exploration of the IEEE-754 Floating Point Standard

IEEE-754 Question: Execute the following while loops (modifying the code to add a counter). Explain the reasons these loops for the observed count value.

  Solution The counter is 53, 1024, 1075 for the above three for loops. The code is attatched in 4.2. According to IEEE-754 (double precision), the machine epsilon is $2^{-52}$….


My CUDA Helper for Visual Studio

CUDA Helper for Visual Studio

My CUDA Helper for Visual Studio  

 


Implementing Instagram Filters: Brannan, Earlybird

This series illustrate my shaders on Shadertoy.com, which renders Instagram filters in real time. Brannan Filter Brannan filter emphasizes the grey and green colors, and paints a metallic tint upon the photos. Click the mouse for comparison. I write this shader to stylize your photos in batch on my own ShaderToy renderer 🙂 (To be…


[Solution] Leetcode 719. Find K-th Smallest Pair Distance

Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pair (A, B) is defined as the absolute difference between A and B. Input: nums = [1,3,1] k = 1 Output: 0 Explanation: Here are all the pairs: (1,3) -> 2 (1,1) -> 0 (3,1) -> 2 Then the 1st…


PostProcessing: Brightness, Contrast, Hue, Saturation, and Vibrance

Real-time image manipulation is always fascinating. With the power of the modern GPU, it is possible to achieve the postprocessing effects all in a single shader. Remember that in GLSL, matrix are column major. Brightness is a float between [-1, 1], directly adding to the RGB Contrast is a float between [0, 1, ∞], directly…


[Leetcode] 691. Stickers to Spell Word

Leetcode 691 is an interesting problem, I didn’t notice that T <= 15. BFS is good enough (and even faster) for this, but dynamic programming with bit compression is the ultimate solution with more words.

   


Code Golf: Halftone Image

 This is a code golf with the help of Dr. Neyret and coyote. Demo   Code

 


Dotted Drawing / Sketch Effect

After lunch, I want to replicate the sketch shader I wrote for the Pencil-vs-Camera project. Additionally, I wrote a one-pass shader for dotted drawing / sketch post processing effect, which I think is more aesthetically pleasing. Dotted Drawing Demo Click on the play button in the left bottom corner of the embedded ShaderToy window below, to…


Unified Gnomonic and Stereographic Projections

Gnomonic projection, or rectilinear projection, together with stereographic projection, are two most commonly used projection in rendering 360 degree videos, or other VR applications. Recently, I found the inverse converting function from screen coordinates to the two projections can be unified within a single function. It’s not really surprising since both projection uses spherical lens,…


Equirectangular Projection, Gnomonic Projection, and Cubemaps

Gnomonic Projection Background According to MathWorld, the gnomonic projection is a nonconformal map projection obtained by projecting points (or ) on the surface of sphere from a sphere’s center O to point P in a plane that is tangent to a point S (Coxeter 1969, p. 93). In a gnomonic projection, great circles are mapped…