and pass what is required to fragment to lit the surface properly. Works great.

What i would like to do is to [u]pass a light position as a mat4x4 [/u]- to have all my transformations in engine stored as matrices.

Of course i would need to forget about gl_LightSource[xxx] and put my own structure into shader, what i already have prepared.
I also have my lights positions stored in matrices, so all is really required is to rewrite the above to run calcs on mat4x4 instead of vec3.

The calculations are the thing here, is it possible to pass mat4x4 instead of vec3 for light position and have the calcs done?

If not, how can i achieve a vec3 out of a mat4x4 ?

Thanks!

0

Share this post

Link to post

Share on other sites

well as far as I know what you want to do is completely unwanted. The CPU can do far less work than the GPU. To add you'd need to calculate the light direction for every vertex that you render, and for a very large mesh (1 million polygons) the CPU wouldn't process it that fast so that it'd be real-time. On the other side the GPU has like ~1000 shader processors (or more) and each can process 4 operations / cycle (or something like that), and each is going with 1300-1400MHz, so the GPU would process it in no time due to it processes data massively parallelly. So you definitely don't want to compute things for each vertex (or each fragment) on the CPU.