Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does OpenGL have preshaders?

My question is kinda simple but i cant find it in the web. Does OpenGL / OpenGL ES have preshaders like DirectX?

so that you can write things like

mat4 wvpMat = worldMat * viewMat * projMat;
gl_Position = wvpMat * position;

and it will compute the wvpMat only once in the preshader. Or is this not supported and you should make it on the CPU instead?

see Riemers example for XNA:

XNA with preshaders

like image 323
HellGate Avatar asked Dec 09 '25 05:12

HellGate


1 Answers

OpenGL defines several shader stages:

  1. vertex shader: runs first for all points you wish to draw

  2. optional tesselation with 2 shaders: a control shader to specify how to tesselate and a evaluation shader to do the actual tesselation

  3. optional geometry shader: emit a variable amount of primitive per drawn primitive

  4. fragment shader: runs per fragment

The driver is allowed to optimize each of these as needed when linking the program together, which may include generating a preshader. However, it is implementation-defined.

like image 157
ratchet freak Avatar answered Dec 11 '25 20:12

ratchet freak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!