Question

I would like to precalculate some values to be used each time the fragment shader is called. How/where do I do that? I am using a full screen quad, four vertices.

Was it helpful?

Solution

Some profiling might be required to see if you will really benefit from precalculating these values instead of doing the calculations in the fragment shader (usually it's a win, but sometimes not).

If you will benefit from this, values calculated once per frame can be passed in as uniforms. You can also calculate these in the vertex shader and pass them along as varyings (which won't really vary), due to the small number of vertices you're talking about here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top