Compiling 'texture arithmetic expressions'

Hi everyone,

I was wondering if anyone has pointers on some work about low level & minimal & practical & efficient ‘shader’
compilation.

What I was thinking about is to play with C++ feature to achieve some kind of neat & readable C++ writing of a
multitexture expression (only including unextended OpenGL (plus ARB_multitexture) features for the moment.

In my first toughts, it would have looked like

GLexpression e = color[ color_array ] * texture2d[ uv_id ] * texture2d[ uv_id2 ] + texture_2d[ texGen ];
	e->render(object);

The expression would be able to optimally assign multitexturing units according to the number available, and
eventually do multipass on the expression if there is not enough texture units.

I dropped that syntax because of the operator priorities (* > +) and the like. So I came to something like:

GLexpression e = color[ color_array ].mul( texture2d[ uv_id ]).mul( texture2d[ uv_id2 ] ).add( texture_2d[ texGen ] );
	e->render(object);

that takes into account the linear application of textures. However I’m not glad since if I run out of texture units,
I don’t have good means to apply the rest of my expression using multitexturing. It’s easy to apply the rest in multi-pass
with mono-texture. Multitexturing needs to take commutativity and the like in account!

So I’m finally wondering if all this if worth the effort !? Has anyone of you played with this kind of logic ?
What were your results ?

thanks
Nicolas.

What you want has already been done, to a greater extent, by a group at Stanford. Check out this link:
http://graphics.stanford.edu/projects/shading/

– Zeno

Thanx Zeno, I was aware of this project and of a few others (I can’t find the links here…).

But these projects are far too ambitious for my actual needs, and, moreover, I’m a kind of ‘make-it-yourself’ man. So I’m looking for technical data and experience more than for a pre-cooked lib to use

Any other pointer of experience ?