lazy shading

Started by
4 comments, last by fir 9 years, 10 months ago

When working on my home rasterizer i noticed that i shade

all the triangles then later clip it (so i do a lot of unnecessary shading)

This is becouse shading is done in world space (when i move models

relative to the lights - all this is done in world space)

.. but as i said it seem to by unnecessary to shade all the triangles tahat

goes dead (filteres out) later - so maybe i could revrite it to do lazy shading

(count only alive set of triangles then back and shade them)

I m curious if modern engines (like ogl etc) use this concept or they

shade everything in brute force before the clipping tests?

Advertisement

Why do you open a new thread for this? Check your other thread where I wrote about tiled rendering, which is a solution for this problem.

Shading is done after clipping. There is literally no point in shading pixels [that the player is supposed to see] which will not be drawn on screen, so they aren't. This is done automatically by the GPU hardware. It should not be too hard to modify your rasterizer to take this into account when shading, I think, it's a fairly basic (and natural) optimization.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Shading is done after clipping. There is literally no point in shading pixels [that the player is supposed to see] which will not be drawn on screen, so they aren't. This is done automatically by the GPU hardware. It should not be too hard to modify your rasterizer to take this into account when shading, I think, it's a fairly basic (and natural) optimization.

alright,

possibly, but it was not the feerst seen of this as this is not 100% strightforward (after clipping you have a transformed coordinates and you return to old ones 4 steps back in the pipeline to shade it there

Shading is done after clipping. There is literally no point in shading pixels [that the player is supposed to see] which will not be drawn on screen, so they aren't. This is done automatically by the GPU hardware. It should not be too hard to modify your rasterizer to take this into account when shading, I think, it's a fairly basic (and natural) optimization.

alright,

possibly, but it was not the feerst seen of this as this is not 100% strightforward (after clipping you have a transformed coordinates and you return to old ones 4 steps back in the pipeline to shade it there

After clipping you do your pixel rasterization, which is the step in which you interpolate all the vertex attributes that you transformed/passed through the vertex transform stage. People often do lighting in view space, and for that all you need is a view space normal to be interpolated for each pixel in order to do lighting. You don't need to go back in the pipeline to get any data.

Shading is done after clipping. There is literally no point in shading pixels [that the player is supposed to see] which will not be drawn on screen, so they aren't. This is done automatically by the GPU hardware. It should not be too hard to modify your rasterizer to take this into account when shading, I think, it's a fairly basic (and natural) optimization.

alright,

possibly, but it was not the feerst seen of this as this is not 100% strightforward (after clipping you have a transformed coordinates and you return to old ones 4 steps back in the pipeline to shade it there

After clipping you do your pixel rasterization, which is the step in which you interpolate all the vertex attributes that you transformed/passed through the vertex transform stage. People often do lighting in view space, and for that all you need is a view space normal to be interpolated for each pixel in order to do lighting. You don't need to go back in the pipeline to get any data.

you need 'get back' to count a normal there on demand - for clipping I dont need a normal so i must get back for it only to use it for shading at a very later stage (even after 'vertex depth' test (i do such depth clipping on vertexes before rasterisation for speed )) - but dont matter, now im more confuzed by the making light less plastic, see the other thread maybe you could help?

(this could be closed as everything's clear)

This topic is closed to new replies.

Advertisement