Research:Weather

From OpenMW Wiki
Revision as of 22:26, 20 September 2015 by Hrnchamd (talk | contribs) (→‎Sun glare: Added sun glare rendering.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Sun glare

Actions affected During day hours
Description Rendering the sun glare overlay
Implementation status
Analysis status Needs verification

TitleCaps variables indicate values taken from the morrowind.ini section related to that object.


Glare magnitude calculation

theta = angleBetween(camera view vector, camera to sun vector)
peakHour = Weather.SunriseHour + (Weather.SunsetHour - Weather.SunriseHour) / 2


# Angular proximity
if theta <= Weather.SunGlareFaderAngleMax:
    a = 1 - theta / Weather.SunGlareFaderAngleMax
else:
    a = 0

# Time of day
if gameHour < Weather.SunriseHour or gameHour > Weather.SunsetHour:
    b = 0
elif gameHour < peakHour:
    b = 1 - (peakHour - gameHour) / (peakHour - Weather.SunriseHour)
else:
    b = 1 - (gameHour - peakHour) / (Weather.SunsetHour - peakHour)

b *= Weather.SunGlareFaderMax

# Specific weather variables

# transition is 0 at the start of a weather change and 1.0 at the end
# note that CloudsMaximumPercent is not actually a percentage
if weather is changing and transition < nextWeather.CloudsMaximumPercent:
    t = transition / nextWeather.CloudsMaximumPercent
    c = (1-t) * currentWeather.GlareView + t * nextWeather.GlareView
else:
    c = currentWeather.GlareView

# Occlusion
d = time-averaged visibility of sun via raycast [range: 0-1]

Rendering

Blend mode: src=SRC_ALPHA, dest=ONE

Material colour = saturate(3 * Weather.SunGlareFaderColor)    # design flaw
Material alpha = a * b * c * d


Comments

There is an issue with the colour specification. The default SunGlareFaderColor is sRGB [222,095,039], which is very red compared to the actual rendering. This is due to the game setting the ambient, diffuse and emissive materials to the SunGlareFaderColor, in combination with pure white ambient and diffuse lighting for this effect. This essentially multiplies the colour by 3, which is then clamped by the fixed function pipeline, causing a final colour of pale yellow.