Sign in to follow this  
TechnoRobbo

TR's Glass Vignette

Recommended Posts

TechnoRobbo's Glass Vignette v1.1


 


A Refraction-like distortion with an un-distorted center.


v1.1 - Alpha-friendly


 


Menu: Effect -> Distort


 



TRsGlassVignette.png?raw=1


 


GlassVignette.png?raw=1


 


GlassVignette2.png?raw=1


 


Source Code


Hidden Content:


// Submenu: Distort
// Name: TR's Glass Vignette
// Title: TR's Glass Vignette
// Author: TechnoRobbo
// URL: http://www.technorobbo.com

#region UICode
double Amount1 = 0.761; // [0.001,1] Refraction
Pair<double, double> Amount2 = Pair.Create( 0.0 , 0.0 ); // Control Description
double Amount3 = 1.01; // [1.01,1.2] Chromatic Aberration
double Amount4 = 1; // [1,100] Zoom
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
// Delete any of these lines you don't need
Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
int CenterX = ((selection.Right - selection.Left) / 2)+selection.Left;
int CenterY = ((selection.Bottom - selection.Top) / 2)+selection.Top;
double aberate = (Amount1 - .001)/.999;
aberate = 1 * aberate + Amount3 * (1-aberate);
aberate *= aberate;

Surface tmp = src.Clone();
tmp.Clear(ColorBgra.Transparent);
tmp.CopySurface(src,new System.Drawing.Point((int)(-Amount2.First * CenterX),
(int)(-Amount2.Second * CenterY)));

double CenterMax =Math.Sqrt(CenterX * CenterX + CenterY * CenterY);
double zoom =(101 - Amount4)/100;

for (int y = rect.Top; y < rect.Bottom; y++)
{
if (IsCancelRequested) return;
for (int x = rect.Left; x < rect.Right; x++)
{ double maxx =(x-CenterX);
double maxy =(y-CenterY);
double far = Math.Sqrt(maxx * maxx + maxy * maxy );
double rad = Math.Atan2(maxy ,maxx + .0001 );

double effect = far/CenterMax;

double refractR = Math.Pow(far,Amount1) * aberate ;
double refractB = Math.Pow(far,Amount1);


double offxS = Math.Cos(rad) * far * zoom + CenterX;
double offxR = Math.Cos(rad) * refractR * zoom + CenterX;
double offxB = Math.Cos(rad) * refractB * zoom + CenterX;
double offyS = Math.Sin(rad) * far * zoom + CenterY;
double offyR = Math.Sin(rad) * refractR * zoom + CenterY;
double offyB = Math.Sin(rad) * refractB * zoom + CenterY;

offxR = offxS * (1- effect) + offxR * effect;
offyR = offyS * (1- effect) + offyR * effect;
offxB = offxS * (1- effect) + offxB * effect;
offyB = offyS * (1- effect) + offyB * effect;

ColorBgra CPR = tmp.GetBilinearSample((float)offxR,(float)offyR);
ColorBgra CPB = tmp.GetBilinearSample((float)offxB,(float)offyB);
ColorBgra CP = ColorBgra.FromBgra(CPB.B,(byte)((CPR.G + CPB.G)/2),CPR.R,(byte)((CPR.A + CPB.A)/2));

dst[x,y] = CP;

}
}
tmp.Dispose();

}



TRsGlassVignette.zip

Edited by TechnoRobbo
  • Upvote 8

Share this post


Link to post
Share on other sites

Gosh.  That's a nice effect for such a (relatively) simple source.  I think I actually understand some of it :lol:

 

Many thanks for both the effect and the source TechnoRobbo!

  • Upvote 1

Share this post


Link to post
Share on other sites

That is such a cool plugin. Thank yo so much TechnoRobbo. 

 

syg5cmj2.png

 

ob8vm9xe.png

 

Germany/Berlin

  • Upvote 2

Share this post


Link to post
Share on other sites

EER - Thanks -the code is actually some unused routines from developing PasteWarp. It takes a warped mind to make a warped plugin. 

 

CC4FH,DD and Seerose - Thank you, your kind. Nice examples too.

 

DD -It does look liike Darth Vader. I should have published it on May the 4th  not May the 5th. May the 4th be with you.

 

(OK, OK, I sense a disturbance in the force, like millions of voices groaning over a bad joke).

Edited by TechnoRobbo
  • Upvote 2

Share this post


Link to post
Share on other sites

Ooooh - yet another really cool Plugin @TR - Many thanks.  So many possibilities - could play all day.
 
And .......... I get to sit on the Loch Ness Monster and be wiped out by a Tsunami at the same time :D

DxI1gVT.png

  • Upvote 2

Share this post


Link to post
Share on other sites

Fun plugin TR - thanks!

Very creative examples from everyone too. :)

Indeed yes. Thanks for the creation TechnoRobbo. Fun to be had. 

Share this post


Link to post
Share on other sites

 

 

Oooh.  Now you can move the bean anywhere in the world you want to!  Like.

Honestly , I think that bean is weird. A city with architecture by Mies van der Rohe ,Frank LLoyd Wright and the Columbian Exposition legacy has a bean?

 

 

Many thanks to david. pixey , doughty, lloyd, treveroutla and especially to Mottoman for the turkey homage.

 

Red has pointed out that Alpha channel should be taken into consideration and I agree. I will publish have published an Alpha-friendly revision - Thanks Red (reps from me)

 

GlassVignette2.png?raw=1

Edited by TechnoRobbo

Share this post


Link to post
Share on other sites

Honestly , I think that bean is weird. A city with architecture by Mies van der Rohe ,Frank LLoyd Wright and the Columbian Exposition legacy has a bean?

The bean is weird.  But being close to it is a fascinating experience.

 

Does calling it "cloud gate" make it better? ;-)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this