CMZTECH.NET
  • Blog
  • Graphics
  • Virtual Reality
  • 3D Printing
  • Fun Stuff
  • Contact

non-linear lerp in unity

3/30/2015

0 Comments

 
A LERP (linear interpolation) returns you a value based on start and end key values and a fraction of the interpolation. 
E.g:
  • When the fraction is 0 you are at the start
  • When the fraction is at 1 you are at the end
  • When the fraction is at 0.5 you are halfway


But if we replace the fraction with something non linear as long as its a function that returns a result in the range 0..1 we can get some more interesting results.   Trig curves like Sine are a good candidate and allow the creation of movement that has smooth acceleration and deceleration.

Picture
For my example I wanted to interpolate from key A to key B and then back to key A, so the part of the sin curve I should use goes from 0..PI.  So I take my input fraction, scale it by PI and then generate the Sin and I get a lovely smooth interpolation and back again.  If you simply wanted to go from Key A to Key B you would use 0..1/2PI.


//When something scary happens momentarily zoom the camera
float inter = (1.0f*fearCounter)/FEARCOUNTER;  //linear
inter*= 3.1415f; 
inter = Mathf.Sin(inter);
float fov = Mathf.Lerp(cameraFOV,cameraFOV/2.0f, inter);
localCamera.fieldOfView =fov;
0 Comments

Asset importing, lightmaps and prefabs in unity

3/30/2015

0 Comments

 
Picture
Picture
Yesterday I imported some new assets, then created a giant level with several mazes using them and then when I came to light mapping I found out that I didn't have any UVs suitable for lightmapping and so I had the throw the entire level away and start from scratch. Which SUCKED.

Lesson:
On asset import, check the option for Generate Lightmaps.  This dialog on appears once and you only get one chance




Lesson:
This is meant to be fun right? :-(  Well at least it looks KINDA AWESOME!

Lesson:
Use prefabs properly.  Prefabs allow you to change every instance of an object in the scene in a single location.  However the UI is different to most other packages I've used.  In MOST packages when you make a change to an instanced object you are asked if you making a change to only that instance or all of them.  In Unity it works the other way around, the changes are always local unless you apply them using the prefab dialog:

Picture
0 Comments

turning fog off in the unity scene editor

3/30/2015

4 Comments

 
Picture
This is something that has been bugging me for a while.  My game has heavy fog in it, which is fine through the game camera but means that when you zoom out in the Scene Editor everything is fogged in and you can't see anything.  I've been turning the fog off in Edit->Render Settings and often I forget to turn it back on.  Its an annoying workflow.  Turns out you can toggle a variety of effects on and off for the scene editor and fog is one of these.  Lighting is another, which will be useful for sinister night levels, I'm sure.

4 Comments

GDC, Here we come!

3/1/2015

0 Comments

 
Picture
Its been a long crazy slog toward GDC this year at NVIDIA, but I think we are going to show some stuff that will blow people away so it should be worth it.

Check out my review of the Zeiss VR ONE here.
 

0 Comments

    David Coombes

    Making stuff

    Categories

    All
    3D Graphics
    3D Printing
    3D Scanning
    AI
    Blender
    Cycling
    Development
    Environment
    Futurism

    Archives

    February 2023
    November 2022
    April 2022
    February 2022
    January 2022
    February 2021
    January 2021
    November 2020
    May 2020
    April 2020
    March 2020
    February 2020
    December 2019
    November 2019
    September 2019
    August 2019
    July 2019
    January 2019
    December 2018
    October 2018
    August 2018
    June 2018
    April 2018
    March 2018
    February 2018
    January 2018
    July 2017
    June 2017
    May 2017
    April 2017
    March 2017
    January 2017
    September 2016
    August 2016
    July 2016
    May 2016
    April 2016
    March 2016
    December 2015
    November 2015
    August 2015
    July 2015
    June 2015
    April 2015
    March 2015
    February 2015
    January 2015
    December 2014
    November 2014
    October 2014

    RSS Feed