Jump to content

ClipDisplace Smoothing update 31/12/2015


Red ochre
 Share

Recommended Posts

MJW - I agree, but (if I'm correct) using getBilinear means it accesses a square of 4 pixels and creates values based on the float coordinates.
That means it doesn't have to cross the R.O.I.s, so can be multi-threaded... and quick... and started off in codelab too!

Now in 'Clipwarp' I access the pixels directly in a 3 by 3 square to get the tone gradient direction and magnitude. That means using another surface as it crosses the R.O.I.S.
In that I  have included a smoothing ability which basically averages the rectangle around the new pixel proportional to the displacement but being single threaded (I think) and checking loads of pixels makes it extrememely slow.

If you can explain (over on Dev central) a 'simple' way to access pixels across the R.O.I.s multi-threadedly it would be useful for many effects.
The ideas behind sampling (and anti-aliasing) seem quite logical but I just don't have the deep understanding of how modern computers works to get 'threading'.
You're version of 'Edge Shader' is blisteringly quick but I don't understand the code well enough to add any more to that version.
Edge shader is good for putting a tone gradient on objects before Clip Displace - but didn't want to publicize that as it isn't officially published.

For ClipDisplace the best thing I can suggest to get smoother images is to work on a larger Canvas and resize down and make the clipboard image have smooth gradients. (Bit of 'cop out',sorry :roll: )


----------------------------------------------------
Drew! - Great image, love the crystal/glassy texture. B) Thanks for posting! ;) (+1 later)

 

Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings

 

PdnForumSig2.jpg

Link to comment
Share on other sites

Assuming ClipDisplace works as I think it does, adding supersampling would be quite easy. I've been thinking about writing a plugin tutorial on the subject, and maybe I'll do so soon. Let me offer an abbreviated explanation here.

 

The usual processing for a plugin like this is to, one by one, take the destination pixel coordinates, transform them in some manner to get the appropriate source pixel coordinates, then use GetBilinearSample to index into the source (or clipboard) buffer and fetch the pixel. Though the destination pixels coordinates are integers, all the rest of the processing is normally floating point, and doesn't really depend on the "integerness" of the starting coordinates. Supersamping simply applies the same process, but for each destination pixel it takes multiple samples at evenly-spaced subpixel coordinates, then it averages the results to get the destination value. Each destination pixel is written only once, in the same order as it's written in the non-supersampled version. For each destination pixel, multiple pixels are fetched from the source or clipboard buffer, but that's not a problem for multiple threads.

 

By way of an edit, let me expand a bit on what I mean by "transform [the destination coordinates]  in some manner to get the appropriate source pixel coordinates."  An example might be to access the corresponding pixel in the clipboard image, scale the red and green components, and add them as offsets to the current X and Y coordinates to produce the desired source coordinates. I don't just mean to perform some arithmetical operation on them.

 

My Texture Shader plugin does something akin to ClipDisplace, and I assume works in a similar fashion. I was worried adding supersampling would be difficult, but I was able to add it (after the non-antialiased version was already written) in just a few hours. For the most part, it consisted of adding floating-point versions of several routines. The floating-point methods were almost functionally identical to the integer versions with just the variable types changed, and sometimes calls to GetBilinearSample in place of direct indexing.

Edited by MJW
  • Upvote 1
Link to comment
Share on other sites

Good Result Racerx - Dali would have been pleased! Thanks for posting the image. B)

MJW - fetching the multiple src pixels in different ROIs is the stumbling block for me. I think Rick mentioned it was possible in one of my first posts on this forum, but I've always found that problematic.
OK if I P.M. you and see if we can work together to make a quick high-quality option ?
(probably tomorrow ... better check there's nothing incriminating in the comments in the code first :D)

 

Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings

 

PdnForumSig2.jpg

Link to comment
Share on other sites

I look forward to your PM.

 

As far as I'm aware, there's never a problem with reading from the source buffer in whatever way, and as often as, one wishes. The ROIs limit which designation pixels can be written. They can't limit which source pixels can be read, since a rendering loop must often access source pixels outside its current ROI.

Edited by MJW
Link to comment
Share on other sites

I've been wanting to do one of these for a while now, this plugin makes it easy. I used TR's clock shape for this....

 

8aA1nyI.jpg

This would look really cool if the opacity of the clock was a little lower, still a neat image all the same, good work. By the way, where is TR's clock shape plugin ? I have tried to find it with no luck  :/

swIFX9v.png

 

 

 

Link to comment
Share on other sites

@Lloyd, Your image gave me an idea about a custom effect that I can use as an opening sequence for a car show production I'm working on. I used Red Ochre's clipdisplace and gears plugins. I think it looks good enough to make the cut.......

 

nVa0dpR.gif

  • Upvote 4

Plane_Sig2.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...