>>The downside is that I think it would require adding
>> an if()
>> test to the vertex shader, something I've been avoiding due to
>> (unfounded?)
>> concerns about performance.
> General advice that I can find is that GLSL is designed as a linear
> program:
> conditionals and loops are best avoided:
>From my own experience:
* conditionals on flags (say uniform int) are in general unproblematic and work
as intended
* conditionals on a varying are dangerous and only worth trying if you have an
expensive operation which you can avoid - but then they help.
Say, replacing
expensive = some_expensive_operation();
mix(cheap, expensive, x) ;
by
if (x>0.0)
{
expensive = some_expensive_operation();
mix(cheap, expensive, x) ;
}
usually does help if x is zero for enough pixels/vertices. The exception to
this are texture lookups which are expensive, but must be evaluated outside of
a branch if the condition involves a varying
* nested conditionals might work for performance gain up to a depth of 2, never
any deeper - then you end up evaluating every branch
* conditionals of the form
if (x>0) {do stuff();}
(...)
if (x>0) {do_other_stuff();}
don't seem to be recognized as referring to the same condition - they need to
be merged into a single block to be effective for performance.
In general, I think one should stay clear of conditionals, but they have their
use for optimization as well.
* Thorsten
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel