Ticket #557 (closed enhancement: fixed)

Opened 18 months ago

Last modified 11 months ago

review: Minor improvements to non-fancy water fresnel effect

Reported by: hex539 Owned by:
Priority: Nice to Have Milestone:
Component: Game engine Keywords: review
Cc:

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

patch.diff Download (4.4 KB) - added by hex539 18 months ago.
diff for these changes

Change History

Changed 18 months ago by hex539

diff for these changes

comment:1 Changed 18 months ago by Jayschwa

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 Changed 18 months ago by hex539

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 Changed 17 months ago by Philip

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 Changed 17 months ago by philip

  • Status changed from new to closed
  • Resolution set to fixed

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

comment:5 Changed 17 months ago by hex539

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 Changed 16 months ago by anonymous

  • Milestone Unclassified deleted

Milestone Unclassified deleted

comment:7 Changed 11 months ago by jan

(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

Note: See TracTickets for help on using tickets.