- Home /
Vignetting Image Effects
Hey guys, I'm basically making a Zoom-In Binocular script that when you zoom in, it enables the Vignetting Image effect which gives a nice black circle around the edges which gives it the effect of zooming in. However, I am not a coder and want this to happen. I want the Vignetting to have an amount of 8 so there is an integar.
I already have the script where you zoom in and the camera's FOV goes from 60(default) to 30. I just need the image effect to apply. Can somebody please help me!
This is the kind of example I want:
var VignettingAmount : int;
var CheckVignetting : boolean;
function Update(){
if(CheckVignetting == true)
GetComponentInChildren(Vignetting).enabled = true; (SOMEHOW APPLY THE AMOUNT OF 8)
}
Answer by robertbu · Jan 19, 2013 at 02:22 AM
Here is a method I think gives you what you want without a lot of code work.
Create an image in your photo editor that when placed on top of your image would give you the vignette look you want. Begin with a transparent image and darken the corners might be a place to start.
Import the image into Unity. Several import settings will work, but start with a) Texture type = advanced b) Generate Mip Maps=off c) Format=RGBA 32 bit)
Add the bit of code I have at the bottom to your script.
Drag the texture you imported to the texVignette variable. You can set FStartVig and FMaxVig as well. fStartVig is the field of view when the first hint of a vignette will appear. FMaxVig is the field of view where the vignette will be completely displayed.
var texVignette : Texture; var fStartVig : float = 40.0; var fMaxVig : float = 10.0;
function OnGUI() { var fAlpha : float; var fFOV = Camera.main.fieldOfView; if (fFOV < fStartVig) { if (fFOV < fMaxVig) { fAlpha = 1.0; } else { fAlpha = (fStartVig - fFOV) / (fStartVig - fMaxVig); } GUI.color = Color(1.0, 1.0, 1.0, fAlpha); GUI.DrawTexture (Rect (0, 0, Screen.width, Screen.height),texVignette); } }
Your answer
Follow this Question
Related Questions
how to know the relationship between zoom ratio and field of view 1 Answer
Animations are jerky? with FOV and aspect ratios 0 Answers
Camera's FOV is not changing 1 Answer
Android to iOS FieldOfView Difference 0 Answers
Field of view for an enemy 3 Answers