Having two floats affect another

So I’m afraid this is more of a “basic maths question” than a scripting question, but I’ve got no better place to ask.

I have three floats, exposureValue01, exposure01, aperture01. As the names imply, they’re all values from 0 to 1. I’d like to make it so that as I increase exposure01, exposureValue01 increases. At the same time however, I’d like to make it so that increasing aperture01 decreases the value of exposureValue01. I’m sure there’s a simple solution for this but the entire method is escaping me. Any help would be great, thanks.

Something like this?

// Depending on where these values changes I would either use OnValidate or a property.

// This triggers when a value in the inspector has changed
private void OnValidate(){
    // Example.
    // Exposure of 0.71 means that Aperture is (1 - 0.71) which equals 0.29
    exposureValue01 = (1 - aperture01);
}

That just takes one of the variables I’m working with into account though. I need to make it so that both aperture01 and exposure01 are doing something.

Right now I have exposureValue01 = (exposure01 + aperture01) / 2f;, but this gives an “incomplete” value.

That’s why its an example, I dont know your specific code.

Looks fine to me.

Using quotes on a word doesnt help me at all, what do you mean by ‘incomplete’, spell it out for me, it will be easier to understand.

Whoops, looks like the rest of my post got cut off for some reason.

Basically, I always want the key value to be able to move between its set values of 0.1f and 5f. By using the average, there are configurations where the key value will only make it to 2.55f, which is a problem. Here’s the relevant code in Update:

    private void Update()
    {
        cam.fieldOfView = Mathf.Rad2Deg * 2.0f * Mathf.Atan(filmHeight / (2.0f * focalLength));
        motionBlurModel.shutterAngle = Remap(exposureTimeDelta, 1f, 100f, 1f, 360f);

        grainModel.intensity = Remap(exposureTimeDelta, 1f, 100f, maxNoise, minNoise);

        exposure01 = Remap(exposureTimeDelta, 1f, 100f, 0f, 1f);
        aperture01 = Remap(aperture, 0.1f, 32f, 0f, 1f);

        exposureValue01 = (exposure01 + aperture01) / 2f;
        Debug.Log (exposureValue01);

        eyeAdaptationModel.keyValue = Mathf.Lerp(minBrightness, maxBrightness, exposureValue01);

        depthOfFieldModel.aperture = aperture;

        postProcessingProfile.grain.settings = grainModel;
        postProcessingProfile.motionBlur.settings = motionBlurModel;
        postProcessingProfile.eyeAdaptation.settings = eyeAdaptationModel;
        postProcessingProfile.depthOfField.settings = depthOfFieldModel;
    }

The Remap function is just the following:

    float Remap(float input, float min1, float max1, float min2, float max2)
    {
        return min2 + (input - min1) * (max2 - min2) / (max1 - min1);
    }

This sounds like plain game design to me. What is your goal? Do you have fixed numbers as examples? For instance if exposure = 0.2 and apeture = 0.3 then exposureValue = ?
There are many solutions but the rules are the important thing and we can’t answer that for you.

But here is another random example that does what you want: exposureValue = exposure - apeture; Now you could scale the values or add limitations to adjust it the way you want.

How about exposureValue01 = exposure01 * (1f - aperature01) ?