Sign in to follow this  
TechnoRobbo

TR's Tilt-Shift Plugin

Recommended Posts

TechnoRobbo's Tilt-Shift 


Another Classic photographic simulation.


 


https://en.wikipedia.org/wiki/Tilt%E2%80%93shift_photography


 


Tilt Shift Photography is created by misaligning the lens with the film or image sensor.


This misalignment actually shifts the depth of field.


 


TR's Tilt-Shift is a directional gradient blur tool designed to easily achieve the effect.


 


TiltShift.png?raw=1


 


Menu: Effects - > Blurs


 


TiltShiftMenu.png?raw=1


 


 


Video Tutorial for image plane image


 



 


music by TechnoRobbo


 


Vanishing Point


VP.png?raw=1


 


The Code


Hidden Content:


// Submenu: Blurs
// Name: TR's TiltShift
// Title: TR's TiltShift - v1.0
// Author: TechnoRobbo
// URL: http://www.technorobbo

#region UICode
int Amount1 = 15; // [1,100] Blur Amount
double Amount2 = 45; // [-180,180] Tilt
double Amount3 = .5; // [0,1] Length
#endregion

public struct PointD
{
public double x, y;

public PointD(double p1, double p2)
{
x = p1;
y = p2;
}
}

void Render(Surface dst, Surface src, Rectangle rect)
{

Rectangle sel = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
int CenterX = ((sel .Right - sel .Left) / 2)+sel .Left;
int CenterY = ((sel .Bottom - sel .Top) / 2)+sel .Top;
double rad = Amount2 * Math.PI/180;
double diag = Math.Sqrt(sel.Width * sel.Width + sel.Height + sel.Height);
ColorBgra CP = new ColorBgra();

//Test varaibles
//Amount1 = 20;
//Amount2 = -90;
//Amount3 = .85;


for (int y = rect.Top; y < rect.Bottom; y++)
{
for (int x = rect.Left; x < rect.Right; x++)
{

//========================================
PointD position = new PointD(x-CenterX,y-CenterY);

double oldx = position.x ;
position.x =(float)Math.Cos(rad) * (float)position.x - Math.Sin(rad) * position.y + CenterX;
double length =diag * Amount3 + 1;
double val =1 - Math.Min(1,position.x /length);
//quadratics
val *=val;

int Amount =(int)((double)Amount1 * val);
//===========================================================
if (Amount>0){
int y1= y - Amount;
int y2 = y + Amount;
int x1= x - Amount;
int x2 = x + Amount;
int A=0,R=0,G=0,B=0,D=0;
for (int j=y1;j<y2;j++){
for (int i=x1;i<x2;i++){
CP = src.GetBilinearSampleClamped(i,j);
A += CP.A;
R += CP.R;
G += CP.G;
B += CP.B;
D++;
}
}
if (D==0){D=1;}
CP.A = Int32Util.ClampToByte(A/D);
CP.R = Int32Util.ClampToByte(R/D);
CP.G = Int32Util.ClampToByte(G/D);
CP.B = Int32Util.ClampToByte(B/D);
}else{
CP=src[x,y];
}

dst[x,y] = CP;
}
}

}



TRsTiltShift.zip

Edited by TechnoRobbo
  • Upvote 5

Share this post


Link to post
Share on other sites

   dude,,, you're a madman,,, i mostly make wallpapers for phones, pc & tablets & this stuff you're doing is awesome!!! i've downloaded 6 or 7 of yours already & still lookin',,, great work,,, if i wasn't broke i'd send you a hundy,,, tyvm!!!  B)

Share this post


Link to post
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.

Sign in to follow this