Page 1 of 1

Light Sources

Posted: Tue Apr 09, 2019 4:15 pm
by Efriim

Re: Light Sources

Posted: Wed Apr 10, 2019 6:50 pm
by Knight Captain
Are you suggesting the palettes used in Exult do not match the original game?

What are you trying to do in ES? It can import PNGs and other formats. You may need to right-click on the right-side pane to create a new shape.

Re: Light Sources

Posted: Wed Apr 10, 2019 10:14 pm
by Efriim
In the link above for "Light source differences" is a screenshot containing examples of 'magic light sources', and 'natural light sources'.

The two screens that are of import; the bottom left with exult and the spell light is clearly lit like a torch (referencing palette #12), the bottom right with dosbox and the spell light is lighting the dimly lit dungeon (referencing palette #6).

What I'm trying to solve is where in the exult code has the magical light source been lost. The palette is there, it is used for different times of day and spells, visions. The spell "Light" was the first I have noticed that is not accurate to the original game. Additionally the Fountain of Light which uses the same effect as the spell also references the incorrect palette for light.

Re: Light Sources

Posted: Wed Apr 10, 2019 10:19 pm
by Efriim
Worth noting, the spell is not simply counted as a light source. As a single candle uses palette #11 for lighting and two sconces (for two light sources) will use palette #12 for lighting. I believe the spell skips number of light source checks and uses the incorrect palette #12 which makes sense, it is a spell after all and not a light source.

Re: Light Sources

Posted: Thu Apr 11, 2019 10:01 am
by Knight Captain
Can you give us what the correct list should be? I'm sure this is something in the Exult code that could be changed to match things up.

Re: Light Sources

Posted: Thu Apr 11, 2019 11:04 am
by Efriim
No I don't know about the code location in either exult or the ultima.
I was searching. Using U7Wizard, is what told me the references for the Palettes and other things.

From what I could infer and some of them are used in conjunction and may not be accurate for use but at the very least descriptive:
Palette0=Daylight
Palette1=Dusk
Palette2=Night
Palette3=Monochrome
Palette4=Morning
Palette5=Fog
Palette6=Soft Light (The Spell Light in conjunction with Night#2)
Palette7=Storm
Palette8=Red (flashes when injured I think)
Palette9=Red Again (I haven't the slightest)
Palette10=Bright (Crystal Ball vision)
Palette11=One Light Source (Single torch in conjunction with #2)
Palette12=Multiple Light Source (in conjunction with darkness)

Re: Light Sources

Posted: Fri Apr 12, 2019 3:51 am
by Efriim
Palette0=Daylight
Palette1=Dusk & Dawn
Palette2=Night (Cave)(Nighttime)
Palette3=Monochrome (invisibility effect)
Palette4=Weather (Storm)
Palette5=Fog
Palette6=Soft Light (The Spell Light)
Palette7=Candlelit (At night)
Palette8=Red (injury)
Palette9=Red2 (I dont know why there is two)
Palette10=Bright (Lightning Strike)(Ice Place?)(Magic Vision?)
Palette11=Torch ( night w/ lamp or torch)
Palette12=Well lit ( night w/ multiple lamps or torches)

Re: Light Sources

Posted: Fri Apr 12, 2019 12:25 pm
by agentorangeguy
Lighting is a bit buggy in Exult sometimes I think. Like it will be bright as day, and transition straight to night sometimes, or vice versa.

Re: Light Sources

Posted: Fri Apr 12, 2019 2:18 pm
by Dominus
I don't quite understand what the question or the problem is completely.

Re: Light Sources

Posted: Fri Apr 12, 2019 4:44 pm
by Knight Captain
Aren't the Generators in BG light emitters?

We'd have to compare location vs. location to be sure.

Re: Light Sources

Posted: Fri Apr 12, 2019 11:27 pm
by Efriim
Yeah sorry I wasn't being very concise.

In exult the spell "light" "glimmer" or "great light" all use the incorrect palette #12 for lighting. Being the same as having a couple Torches lit.

Whereas in actual dos the spell "light" uses the soft-light palette #6. This can be seen in dosbox, in the link I provided it is the lower right box with the gargoyle reading in the dark.

The generators do not emit light, I'm sure they are lit inside though.

Re: Light Sources

Posted: Fri Apr 12, 2019 11:54 pm
by Efriim
Nevermind it isn't lit in the cube generator, I was thinking it was like dreamworld in SI.

Re: Light Sources

Posted: Sat Apr 13, 2019 5:25 pm
by Dominus
ok, looking at https://github.com/exult/exult/blob/mas ... ette.h#L29 and other parts of the code, we are not using palette #6 or #7 at all, instead using #12 for spells.
I might be able to code that actually.

Re: Light Sources

Posted: Sat Apr 13, 2019 5:33 pm
by Knight Captain
That would be amazing. And if you can, I'd love to be able to use the Fog palette.

Re: Light Sources

Posted: Sat Apr 13, 2019 6:04 pm
by Dominus
I did restore the fog palette ages ago upon your request :)

https://github.com/exult/exult/commit/ff8315d

So, it is easy to modifiy the spell lighting to use the proper light palette. Not so sure whether I can fix the candles.

Re: Light Sources

Posted: Sat Apr 13, 2019 6:15 pm
by Knight Captain
I made a video of DOSbox in slow motion (lower CPU cycles via Shift+11).

For a non-fatal hit:
The Avatar's black outline flashes a magical or translucent light red. It is not the dark solid red that Exult uses.
1 The entire screen goes solid red.
2 Fade back is a very red palette, seems even redder than Palette 8.
3 Then what appears to be Palette 8. The lighter colors are more visible.
4 Then another lighter palette.
5 Then yet another.
6 Back to normal.

For a fatal hit:
1, 2, and 3 above.
4 Back to normal.
5 Then fade to black.

For a fatal hit in Exult, there is no red flash before death.

Re: Light Sources

Posted: Sat Apr 13, 2019 6:26 pm
by Knight Captain
Sorry, for both non-fatal and fatal hits to the Avatar there is a very brief flash of a single red palette, which appears to be Palette 8. There is no solid red and multiple fading as in the original.

My guess here is that the original engine had some of these palette colors hardcoded around hits.

Shall I file a bug report?

Re: Light Sources

Posted: Sat Apr 13, 2019 6:34 pm
by Dominus
Yes, please, this is too much for this thread

Re: Light Sources

Posted: Sun Apr 14, 2019 5:47 am
by Dominus
Correct palette for light spells is now committed.

Re: Light Sources

Posted: Sun Apr 14, 2019 3:10 pm
by Dominus
I'm not sure if I really want to fix the candle light because it only affects candles. anything that says light source or torch will use palette 11 or 12 if there are more than one light sources (candles don't seem to count in that regard).
Tested with the original game.
Not sure if it's really worth it. What do you think?

Re: Light Sources

Posted: Sun Apr 14, 2019 3:27 pm
by Efriim
Please share ideas and make full use of this thread to all ends. It only took me a fraction of time to catch up on the reading.

I gathered, moved, doused, and lit a great many a candle.

I eventually assumed these values.
candles=25
torches=125

Code: Select all

candles    torches    palette   values
1-3        0           6        25-75
4-9        0          11        100-175
0-3        1          11        125-200
10         0          12        250
4          1          12        225
0          2          12        250
I tried a lot to get the proximal light calculations.

I used ((Δ0.02)-1)(L/-1) to calculate the amount of light.

at distance 15 the light is reduced 30 percent

10-85(candle lit)
86-254(torch)
255+(well lit)

so in theory three torches at distance 16 will be well lit
|16*0.02 -1|375≥255

Distance is Pythagorean or probably a mix of math shortcuts.
These were rough estimates. I need to check my work, and reduce or refactor.

I rest now. Good job.

Re: Light Sources

Posted: Sun Apr 14, 2019 3:58 pm
by Dominus
Thanks Evan, that's extensive and if I can make it work that candles have that palette, I can make it work as you found out.

As for the thread I'd rather KC reports his other findings as a bug report than here. Forum is more forgetful than the bug tracker and this thread is more about lighting than the hit/combat palette.

Re: Light Sources

Posted: Sun Apr 14, 2019 4:11 pm
by Efriim
Maybe this

candles=20
torches=125

((Δ0.03)-1)(L/-1)

16-63(candle lit)
64-191(torch)
192+(well lit)


Here is a cheat file to use in the ULTIMA7 folder with DosBox, it is hexedited so if you edit then it it will no longer work.

Re: Light Sources

Posted: Sun Apr 14, 2019 5:18 pm
by Dominus
our code is simply counting light sources. 1 light source = palette 11, more than 1 = palette 12.
To make this work I'd have to count the number of candles in the lightsources, than how many non_candles there are and then make something like:
if (candles palette 6
if (candles palette 11
if (candles > 3 && !non_candles) -> palette 11
if (candles > 9 && !non_candles) -> palette 12
if (candles > 3 && non_candles = 1) -> palette 12
if (non_candles >1) -> palette 12

If I can differ between candles and the other lightsources is the big question... I'm really not good at this :)

Re: Light Sources

Posted: Mon Apr 15, 2019 5:05 am
by Dominus
it's too difficult for me.
We would need to redo the lighting code entirely. The light sources are more different in the amount of light they produce and how it adds up. The red candles give more light than the small candles etc...

Re: Light Sources

Posted: Mon Apr 15, 2019 7:56 am
by Efriim
Candles=1c
Torches=5c

((Δ0.03)-1)((C+T/-1)

The above is mostly accurate relative calculation, as long as the distance is modified -4 for x axis and +1 for y axis. This is different than the actual position relativity code it is too difficult to see the arithmetic simply by observing candles.

https://drive.google.com/file/d/134IftQ ... 9hM7y/view
x=torches
y=Candles
z=is the light factor, and maybe I should approach this differently.
omega is the distance modifier, -4.2

the left of the equation is the distance average of the candles and torches.
the right of the equation is the number of candles and torches used equalling the amount of light minimum to achieve a certain lumination.

I haven't wrote very much code. I'm still learning, maybe my imagination will take me through it but I'm really lacking the knowledge and references.

I got to play the exult snapshot, and the light is restored beautifully. It looks nice and thank you.

Re: Light Sources

Posted: Mon Apr 15, 2019 8:30 am
by Dominus
I'm preparing a savegame of the original game with all lightsources lined up for testing.
To me it seems we are not reading in some kind of data on the light sources frames (shapes 338) that give them the light factor. They do have four different ones.

Re: Light Sources

Posted: Mon Apr 15, 2019 9:51 am
by Dominus
see https://sourceforge.net/p/exult/bugs/2041/ for the bug report and the original savegame attached.

Re: Light Sources

Posted: Tue Apr 16, 2019 4:32 am
by Efriim
Indeed the blue candles, blue candle lamps and lamps have their own values at twice the value of a regular candle and 2/5 of a torch. The candelabras are as bright as a torch. While I think the rest of the candles all hold the same value. Except for the tall blue magic candle in the candle holder is also a torch.

Luckily I only had 1 lamp while testing the first time. The small tea lights with the handle are easiest to use.

I'm still not sure about the distance calculations. The math app I was using on my phone constantly resets on me losing my progress. Additionally it has an equation limit where if you enter the 21st equation it simply erases the first equation at the top without a trace and without asking.

With that consideration it hasn't been going well.

Also the firedoom staff and fire sword are as bright as a torch.

Re: Light Sources

Posted: Tue Apr 16, 2019 11:43 am
by Dominus
don't worry too much, I spoke to Marzo and he did already figure this out some time ago just not implemented it...

Re: Light Sources

Posted: Wed Apr 17, 2019 12:49 pm
by Efriim
It looks a lot like this

(Lux)-(Lux)[(3x-x/3),(4y)] = effective light

also that is 2.66¯x and 4y
also that is 1:1.5 ratio

37x distance was the maximum distance that a lightsource could contribute light. While 24y was the farthest that still gave light vertically.



maybe insignificantly I tried so many ways to figure out how to apply that number as a percentage of reduced light.

I think I will have the values for the effective light switches tomorrow.

Since we are writing our own code I feel like I should work from that direction.

Re: Light Sources

Posted: Wed Apr 17, 2019 12:56 pm
by Efriim
I think I may have typed both of these wrong, I never learned percentages; it is just a number over 100.
Lux - Lux%[(3x-x/3),(4y)] = effective light

Re: Light Sources

Posted: Thu Apr 18, 2019 8:10 am
by Efriim
candle=30
lamp=60
torch=150

ambient=0-12
candlit=13-89
torchlit=90-255
blazing=256+

before I go to sleep
[x,y][1,1.5]
[(3x-x/3),(4y)]/100 = %Δ
[(x/5)x,???y]/255 = %Δ

Re: Light Sources

Posted: Mon Apr 20, 2020 5:14 am
by Dominus
Marzo has done some work on this and it's already working way better!