Logarithmic Sun Intensity

Talk about the mods you'd like to see in Daggerfall Unity. Give mod creators some ideas!
User avatar
King of Worms
Posts: 4752
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Logarithmic Sun Intensity

Post 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 1151 times

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Logarithmic Sun Intensity

Post 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 1123 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.

User avatar
King of Worms
Posts: 4752
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Logarithmic Sun Intensity

Post 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.
Attachments
02.jpg
02.jpg (52.87 KiB) Viewed 1097 times

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Logarithmic Sun Intensity

Post 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.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
King of Worms
Posts: 4752
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Logarithmic Sun Intensity

Post by King of Worms »

Thanks mate :)

User avatar
King of Worms
Posts: 4752
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Logarithmic Sun Intensity

Post 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?

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Logarithmic Sun Intensity

Post 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 1044 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).

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Logarithmic Sun Intensity

Post 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.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
King of Worms
Posts: 4752
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Logarithmic Sun Intensity

Post 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 :)

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Logarithmic Sun Intensity

Post 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
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

Post Reply