Jump to content

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

Go out there and be amazing. Have Fun, TR
TRsSig.png?raw=1
Some Pretty Pictures Some Cool Plugins

Link to comment
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
Link to comment
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

Go out there and be amazing. Have Fun, TR
TRsSig.png?raw=1
Some Pretty Pictures Some Cool Plugins

Link to comment
Share on other sites

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

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
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

30b8T8B.gif

How I made Jennifer & Halle in Paint.net

My Gallery | My Deviant Art

"Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon.

 
Link to comment
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

Go out there and be amazing. Have Fun, TR
TRsSig.png?raw=1
Some Pretty Pictures Some Cool Plugins

Link to comment
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? ;-)

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
Share on other sites

Hey, that is one classy piece of artwork. ;)

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

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...