PDA

View Full Version : Compiling 'texture arithmetic expressions'



Nicolas Lelong
01-04-2002, 08:48 AM
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.

Zeno
01-04-2002, 08:56 AM
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

Nicolas Lelong
01-05-2002, 04:48 AM
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 http://www.opengl.org/discussion_boards/ubb/smile.gif

Any other pointer of experience ?