>> So in my mind the combination of (1) and (2) together are flexible and
>> the "standard" way of doing things
> To rephrase it a bit, I think we have two options:Agreed. (2) alone may be problematic: maybe in some situations, we
>
> * Use functions, try to anticipate many use cases and try to keep function
> bodies small so that they can be replaced without copying too much code.
> (GLSL compilers do inline functions, don't they?)
> * Use a string-manipulating service to provide a very high degree of
> flexibility for the users and use textual hooks to make things more
> explicit/stable for internal use.
>
> I think I like the first better, indeed :)
don't want to include a code snippet in the shader.. Think about
panning/zooming: if you want to add a static visual, you should just
be able to remove the lines of code that do that. If you copy and
paste this every time, what will happen when we'll change the
implementation of this feature later?
// overridable function prototypes
vec4 get_position();
vec4 map_local_to_dev(vec4);
void main(void){vec4 local_position = get_position();vec4 dev_position = map_local_to_dev(local_position);gl_Position = dev_position;}
I think the system I described can work with either strings or
functions. In the first case, you have a system that concatenates
strings with code snippets. In the second case, each snippet is
encapsulated in automatically-generated functions (like Luke described
a few months ago IIRC). The problem with functions it that I'm not
sure how you can return more than 2 variables? Maybe a solution is to
use GLSL "out" or "inout" keywords? I don't know how well this is
supported.
The big problem with strings is that local variables can have
conflicting names between snippets. So functions should be fine if we
can find how to return several values.
The problem with functions it that I'm not
sure how you can return more than 2 variables? Maybe a solution is to
use GLSL "out" or "inout" keywords? I don't know how well this is
supported.