Friday, March 2, 2018

post processing - Rorschach ink blot (aka Psychology test pictures) shader


enter image description here


enter image description here enter image description here
(source: bonnefil.com)


I want this magnificent pattern to be in my game. So far I have figured out...



  1. Draw one side, then render it twice left and right.

  2. How do I render this pattern on one side? hmm...


  3. I need help.


I need some insight on writing shader for this.


If you think is not shader fitting task, then let me know, hopefully with an alternative solution!


However I see no possible approach to achieve this without gpu. (unless you suggest to store bunch of prepared pictures of rorscach pic)



Answer



To get that authentic inky look, your best bet is probably to assemble a library of images of ink splats, streaks, and dribbles.


Then you can randomly select some number of them to position & rotate randomly over one-half the image. (With a bias toward the seam edge so the middle of the Rorschach test is densest. You might be able to use a particle system to do this scattering)


Render that to a texture with wrap-mode set to mirror, and now you have a symmetrical ink blot you can display without any custom shaders.


Here's an example of the kind of result you can get doing it this way:



Inkblot assembled from library of splat images


If you don't care about those signature inky shapes, you can also do this with a shader that thresholds two noise patterns scrolling past each other. That gets a symmetrical irregular shape, which can be made to change continuously over time if you like, but it won't look quite like ink.


This is the method that dnk drone.vs.drones suggests in another answer, and it can give results similar to this:


Inkblot thresholded from noise


Edit: here's a breakdown of how the noise-based approach works...


First we start with some noise. 1/f noise, often called turbulence, works pretty well. You can bake tiling noise into a texture and then sum one or more samples from it, changing their offsets/rotations to vary the shapes you get.


Turbulence Thresholded


If we threshold this directly, we get an image like the one at the right. The shapes are about correct, but to look like a Rorschach test it should be densest near the middle and thin out toward the edges.


We can make this work by adding a gradient over top (contrast exaggerated here for clarity)


Edge mask Mask added to noise



Then threshold it by taking (sum - blackLevel) * contrast


(Here blackLevel is a parameter that controls how speckly vs blobby the result is - higher values mean more solid black - and contrast controls how sharp the edges are)


Thresholded


Mirroring this image will give you the Rorschach example above.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...