Opened 14 years ago

Closed 14 years ago

Last modified 8 years ago

#557 closed enhancement (fixed)

review: Minor improvements to non-fancy water fresnel effect

Reported by: Robin Lee Owned by:
Priority: Nice to Have Milestone:
Component: Core engine Keywords:
Cc: Patch:

Description

This patch pertains to the water rendering when 'fancy' mode is not enabled, and is purely aesthetic.

Currently, in non-fancy water mode a single fresnel value approximation is being calculated based on camera orientation and applied to the whole map. This is incorrect behaviour, as at low angles near water should be largely transparent (low fresnel) while distant water should appear opaque (high fresnel). Attached is a replacement that calculates fresnel per-vertex and addresses other water lighting issues in low-detail mode.

Thank-you for your time,

Robin

Attachments (1)

patch.diff (4.4 KB ) - added by Robin Lee 14 years ago.
diff for these changes

Download all attachments as: .zip

Change History (9)

by Robin Lee, 14 years ago

Attachment: patch.diff added

diff for these changes

comment:1 by Jay Weisskopf, 14 years ago

What is the performance impact of this change? It sounds like something worth doing for fancy water, but I'm not sure I see the point of doing it for low-detail water.

comment:2 by Robin Lee, 14 years ago

The performance impact is roughly 4 square-root operations per visible water tile. This is already done per-fragment with fancy water, and I think it would be a nice little touch (albeit a subtle one) to have more realistic water in non-fancy mode. To me, it looks slightly less like an alpha-mapped plane and more volume-like when this is applied.

To tell the truth, though, this is just a warmup patch to familiarize myself with the game's code; in my own branch I am working on capping the water volume at the sides (done) and using the skybox cubemaps to approximate water reflections for non-fancy water- these cost practically nothing, even on Geforce2-class hardware.

comment:3 by Philip Taylor, 14 years ago

Thanks, I think this does look a tiny bit better.

If we were worried about performance here then I expect there's ways we could optimise it (like using vertex arrays), but it doesn't seem a major bottleneck yet - I think it's fine to make it a little bit more expensive if it'll look less ugly.

-    FresnelScalar = (1 - FresnelScalar) * 0.4f + 0.6f;
...
+    FresnelScalar = 1.f - (FresnelScalar * 0.6);

Was this meant to be just rearranging the equation, or were you intentionally changing the factor? (I'll assume it's intentional, but better to check just in case.)

comment:4 by philip, 14 years ago

Resolution: fixed
Status: newclosed

(In [8046]) Fix #557 (Minor improvements to non-fancy water fresnel effect), based on patch from hex539

comment:5 by Robin Lee, 14 years ago

Glad you agree with me about performance, I don't think it'll be much of an issue either.

About the section you quoted: Actually, it was both reasons. I increased the effect of fresnel from 0.4f to 0.6f to make it appear more similar to the 'fancy' fragment shader,

but rearranged the equation for clarity. Since the fresnel value is just the proportion of light transmitted (and hence opacity=1.0f-fresnel), I'm not sure that it makes sense to lay it out the way the original author did (unless I'm missing something, I haven't really done much CG in the last 6 months).

comment:6 by (none), 14 years ago

Milestone: Unclassified

Milestone Unclassified deleted

comment:7 by Jan Wassenberg, 13 years ago

(In [9087]) fix insidious OpenAL issue: the spec doesn't guarantee 0 isn't a valid source name => we need to use an out-of-band mechanism for specifying whether the source is valid. refs #557

comment:8 by sanderd17, 8 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.