Unity post processing stack (V1 version) script control

Source: Internet
Author: User

Environment: Unity5.6.2,post Processing Stack

Note: The post-processing stack is a V1 version that is downloaded from Assetstore, not the Stack2 version, and the Stack2 version is available for download and installation directly in unity2018 Packagemanager

First, postprocessingbehaviour the script on the camera.


Right-->create->post-processing profile in Project view

and assign it to the profile on post processing behaviour.

Select the newly created post-processing profile

It can be set in the Inspector panel.

How do you control it with code?
There's a hole here, and it's different from the old imageeffects.

First of all, of course, to get this postprocessingbehaviour

PostProcessingBehaviour ppb=GetComponent<PostProcessingBehaviour>();

Then to get the profile object that was created

var profile = ppb.profile;

Get this color grading effect again

var colorGrading = profile.colorGrading;

Get the settings above it

var settings = colorGrading.settings;

And then the pit is coming, look first.
Take the effect of color grading as an example:

It's actually got a couple of points in the panel.
Tonmapping and Trackballs can ignore
There's basic, Chanel Mixer and grading Curves.

According to normal thinking, in the settings behind the direct point, OK is yes
In this example we set the value of the post Exposure (EV) in the basic section to be modified.
Can directly point out basic, and then directly point out the postexposure are no problem, even can be directly assigned to the value

settings.basic.postExposure = -1.2f;

No problem, no error, but run the program without any effect, the value of post exposure in the Panel has not changed.
This is where the pit is.

The right thing to do is to change the post exposure value in the new settings, and then assign it to the Colorgrading component.

var settings = new ColorGradingModel.Settings() ;colorGrading.settings=settings;

And new A settings only modifies the exposure value inside, there is still a pit

As shown in the previous figure, the Color grading panel is divided into several sections, with basic, Chanel mixer and grading Curves
But new out of the settings inside is basically empty, so all of this must be assigned, or will be error
The assignment was made at the time of new.
And since the rest of the part is not changed, then use the point of the previous way to obtain, and assign to the new settings, and finally settings the entire assignment back

var scurves = ppb.profile.colorGrading.settings.curves;var schannelMixer = ppb.profile.colorGrading.settings.channelMixer;
var settings = new ColorGradingModel.Settings() {    basic = {postExposure = -1.2f, contrast = 1, saturation = 1, hueShift = 0, tint = 0, temperature = 0 }  ,    curves = scurves,    channelMixer = schannelMixer}

So new comes out and a settings is finally assigned back.

ppb.colorGrading.settings = settings;

This modification to take effect, and then to modify the value, directly on the new settings on the property, directly assigned to the value, and then the settings assignment back

settings.basic.postExposure = 10f;ppb.colorGrading.settings = settings;

That is, every time you modify, you can change the new settings, but in the end, you have to assign the entire settings back to take effect.

Above

Unity post processing stack (V1 version) script control

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.