splitting frustum for shadowmaps

Started by
20 comments, last by AndyTX 16 years, 10 months ago
well that gets me into some problems.. if i project it that would mean

result = (vec4(vertex,1.0) * modelview * projection)
result /= result.w

however if i use the current projection matrix i get the values in the range of [-1,1] (i think) of the current projection... how do i calculate the new projection from that?

			for (int n = 0; n < 8; n++)			{				//RenderSphere(FurstumPoints[n], 5.0f, 10,10);				FurstumPoints[n] = FurstumPoints[n] * ModelView;					FurstumPoints[n] = FurstumPoints[n] * Projection;					FurstumPoints[n] /= FurstumPoints[n].w;				FurstumPoints[n] *= 200.0f; /7 some nice value to scale up with == WRONG			}
Advertisement
Quote:Original post by Dragon_Strike
result = (vec4(vertex,1.0) * modelview * projection)
result /= result.w

however if i use the current projection matrix i get the values in the range of [-1,1] (i think) of the current projection... how do i calculate the new projection from that?

Note that you need to check for clipping to the near frustum BEFORE DIVIDING BY W. This is all standard stuff that the hardware does so there's plenty of documentation.

You end up with bounds in the [-1, 1] range for X and Y, from which you can compute a scale an offset (relative to the full [-1, 1] range), then construct a scale/offset matrix and compose it with your current projection matrix.

Seriously this is all implemented in the PSSM demos, so I really suggest go taking a look at that code - it's fairly well documented.

This topic is closed to new replies.

Advertisement