• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Uninity · Jan 18, 2013 at 10:39 AM · fovfield of viewimage effect

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)

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

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.

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

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

  3. Add the bit of code I have at the bottom to your script.

  4. 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);
         
                 }
         
         }
    
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges