just wanted to add env mapping to my project, when i noticed, that i use vp´s for everything. So no texcoord-generation
Well, now i´d like to do it myself in the vp, but i couldn´t find the equation for it in the spec. Can someone tell me the formula?
Thanks in advance,
Jan.[/b]
Hello! I know how to do that for cubic environment maps. To calculate, for instance, coords for reflection (environment mapping is a technique that simulates highly reflective surfaces without using ray tracing, you know) you should use following formula:
RefVec = 2*(E dot N)*N - E
where E - is vector from our eye position (defined in constant registers) to vertex (incoming in vertex program (vp)), transformed by a World matrix (also stored in const regs); and N - our normal, transformed by World matrix;
Transform vertex position and normal by World matrix and use this formula. Finally, put answer into texture coords register.
Sorry if I understand your question unproperly.
And one question for You.
Whether OpenGL has higher language for writing vertex and fragment programs in a C-like style?
OpenGL itself does not have a C-like language for writing vertex- or fragment-programs. At least not yet. But one can use CG instead (www.cgshaders.org).
Ati catalyst 3.9(+) has support for Glslang… not all aspects of the language, but enough to do that, and many other things… ( it doenst support loops, even if they are of know length, and it fallsback, correctly, into software when using the noise functions)