Research:Weather: Difference between revisions
Jump to navigation
Jump to search
(→Sun glare: Added sun glare rendering.) |
(→Sun glare: Various corrections.) |
||
Line 10: | Line 10: | ||
''Glare magnitude calculation'' | ''Glare magnitude calculation'' | ||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
theta = angleBetween(camera view vector, camera to sun vector) | theta = angleBetween(camera view vector, camera to sun vector) # in degrees | ||
peakHour = Weather.SunriseHour + (Weather.SunsetHour - Weather.SunriseHour) / 2 | peakHour = Weather.SunriseHour + (Weather.SunsetHour - Weather.SunriseHour) / 2 | ||
Line 20: | Line 20: | ||
a = 0 | a = 0 | ||
# Time of day | # Time of day, prevents glare interfering at sunrise/sunset | ||
if gameHour < Weather.SunriseHour or gameHour > Weather.SunsetHour: | if gameHour < Weather.SunriseHour or gameHour > Weather.SunsetHour: | ||
b = 0 | b = 0 | ||
Line 48: | Line 48: | ||
Blend mode: src=SRC_ALPHA, dest=ONE | Blend mode: src=SRC_ALPHA, dest=ONE | ||
Material colour = saturate( | Material colour = saturate(2 * Weather.SunGlareFaderColor) # design flaw | ||
Material alpha = a * b * c * d | Material alpha = a * b * c * d | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 54: | Line 54: | ||
====Comments==== | ====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 | 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 lighting for this effect (but no diffuse due to lack of normals). This essentially multiplies the colour by 2, which is then clamped by the fixed function pipeline, causing a final colour of light orange. |
Revision as of 23:28, 20 September 2015
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) # in degrees
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, prevents glare interfering at sunrise/sunset
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(2 * 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 lighting for this effect (but no diffuse due to lack of normals). This essentially multiplies the colour by 2, which is then clamped by the fixed function pipeline, causing a final colour of light orange.