Page 2 of 3

Re: Logarithmic Sun Intensity

Posted: Thu Jan 14, 2021 12:13 pm
by King of Worms
Interkarma wrote: Tue Jan 05, 2021 11:35 am DFU's daylight curve is not linear. It's a hand-tuned curve to try and match classic's brightness peaks in morning and afternoon as closely as possible. Below is the curve used ingame. It has a sharper ramp up and down in morning and afternoon, and a more gradual curve during middle of day. This curve is found in SunlightManager component on Exterior/SunlightRig/SunLight object.

It would be a rather easy curve to change by a mod if anyone wants to. :)


daylight-curve.jpg
Hi Interkarma, thanks for the info on the curve location and that its possible to mod it.
Id really like to try to mod that curve and have it in the DREAM, but I have 2 problems:

1) I Cant really find it
2) No idea on how to export it to the DFMOD

ad 1)This is as far as I was able to go, I found SunLightRig, but it might be something completely different than what you actually mean :D Where should I look for that curve pls?
02.jpg
02.jpg (161.93 KiB) Viewed 1160 times

Re: Logarithmic Sun Intensity

Posted: Thu Jan 14, 2021 9:40 pm
by Interkarma
It's on Exterior/SunlightRig/SunLight inspector. Then look for SunlightManager.LightCurve property. Screenshot below should help locate.

light-curve.png
light-curve.png (595.29 KiB) Viewed 1132 times

The LightCurve property is of type AnimationCurve. To mod, have a script find the SunlightRig post game startup, then grab the SunLight GameObject and set your custom curve over this property. Some info here on setting curve by script.

Re: Logarithmic Sun Intensity

Posted: Fri Jan 15, 2021 1:44 pm
by King of Worms
Thanks a lot,

when I open the Hierarchy window its empty. I guess I need to direct Unity to read the daggerfall data somehow? But I dont have a clue how or where... Im sorry Im just utter noob at this part.

Re: Logarithmic Sun Intensity

Posted: Fri Jan 15, 2021 1:57 pm
by BadLuckBurt
King of Worms wrote: Fri Jan 15, 2021 1:44 pm Thanks a lot,

when I open the Hierarchy window its empty. I guess I need to direct Unity to read the daggerfall data somehow? But I dont have a clue how or where... Im sorry Im just utter noob at this part.
First, click on File > Open Scene and then open the DaggerfallUnityGame scene under Assets / Scenes in the DFU source code folder. That will populate the hierarchy and you can follow IK's instructions from there.

Re: Logarithmic Sun Intensity

Posted: Fri Jan 15, 2021 7:01 pm
by King of Worms
Thanks mate :)

Re: Logarithmic Sun Intensity

Posted: Fri Jan 15, 2021 8:13 pm
by King of Worms
Ok I can see it, but not chance in hell I can put that in the mod... "To mod, have a script find the SunlightRig post game startup, then grab the SunLight GameObject and set your custom curve over this property." is like speaking chineese. Thats my issue, not the fault of explanation ofc

I can alter the curve, than save it to the "Sunlight rig" prefab.

Than I guess I need to put this new prefab and the script in one dfmod and that will be it?

Re: Logarithmic Sun Intensity

Posted: Sat Jan 16, 2021 1:43 am
by Interkarma
What you need to do is create a custom LightCurve in some other object in scene, then assign that over the top of the standard light curve at game startup. Here's an example:
  • Create an empty GameObject in game scene (right-click Hierarchy > Create Empty). Let's call it "CustomLightCurve".
  • Save the following script to your project as "CustomLightCurve.cs" then attach it to your new CustomLightCurve GameObject in scene.

Code: Select all

using UnityEngine;
using DaggerfallWorkshop.Game;

public class CustomLightCurve : MonoBehaviour
{
    public AnimationCurve myLightCurve;

    void Start()
    {
        SunlightManager sunlightManager = GameManager.Instance.SunlightManager;
        sunlightManager.LightCurve = myLightCurve;
    }
}
  • Design your new light curve in MyLightCurve property of CustomLightCurve in editor. I quickly made one like screenshot below.
  • Save CustomLightCurve along with your changes to a prefab.
light-curve.jpg
light-curve.jpg (129.15 KiB) Viewed 1053 times

When you run the game with this prefab in scene, the attached script will assign your custom MyLightCurve properties to sunlightManager.LightCurve so it's used by the game. It's only a couple lines of code.

To distribute, you'd need to include the prefab and script with your mod build, and will need to inject it into scene at startup (e.g. Instantiate() the CustomLightCurve prefab in your mod startup script).

Re: Logarithmic Sun Intensity

Posted: Sat Jan 16, 2021 6:08 pm
by BadLuckBurt
I really need to learn how to instantiate a prefab from my mod loader :D

I got it working by just assigning keyframes to a new curve through script and assigning that as my mod loads:

https://mega.nz/file/UR8QBSRY#z_vLDLtFj ... r0VeXZv19A

I used less than half the value of the original curve for noon and that definitely toned down the brightness by a lot. This could be tweaked per season I suppose. The best way to see the effect is to make a save during mid-day with the vanilla setting then activate the mod, load the savegame and save it again to a new slot. Alternate between the savegame thumbnails to compare.

I put this half-assed attempt on Github as well: https://github.com/BadLuckBurt/blb-lightcurve-changer/, the only script used atm is
DFULightCurve.cs.

Re: Logarithmic Sun Intensity

Posted: Sat Jan 16, 2021 8:08 pm
by King of Worms
This is great, I will test it tomorrow. I will also experiment with other settings of the curve, this way with the script you provided I can actually do it I believe. Thanks a lot :)

Re: Logarithmic Sun Intensity

Posted: Sat Jan 16, 2021 9:31 pm
by BadLuckBurt
King of Worms wrote: Sat Jan 16, 2021 8:08 pm This is great, I will test it tomorrow. I will also experiment with other settings of the curve, this way with the script you provided I can actually do it I believe. Thanks a lot :)
You're welcome, hit me up if you have any questions