I want to render the screen to just a portion of a render target.
The idea is to have the camera face one direction render everything scaled down to a portion of the rendertarget say the top left sixth of it.
Turn the camera 90 degrees in another direction with the same render target
Render to the top middle of it.
Id like to do this for all six sides of a cube, as im about to try to make a shadow cube map and im coding the cube atm… I did the regular shadow map before on a single plane but its not so great i’ve never tried to make a shadow cube yet.
is that not possible
or a bad idea
Really i have no idea how to do a shadow cube map skybox’s are pretty simple but the shadow cube to me seems fairly confusing especially the part of figuring out were on which texture a pixel equates to when actually drawing the shadows.
I keep imagining about 6 if’s in a shader to boot im sort of thinking that isn’t the way its done ? Or is it ?
You are probably better off just using a RenderTargetCube instead.
I don’t think so. You won’t save any memory and it will probably be slower, because figuring out the correct uv coordinates makes your shader more complicated. With cubemaps you can just pass a direction into the texture lookup.
It’s pretty branchy though, even with most of it just being tables.
An alternative to doing the branchy coordinate conversion in the shader is to prebuild two mip-less cubemaps, one for face selection and another for indirection (bitwise operators can make it one RGBA16 but that chops away alot of hardware). The face selection contains the multiplier to collapse the sampling vector on the axis, and the indirection is the coordinate remapping. A bit more branchiness can ditch the indirection cubemap (packing an index into the face-selection Alpha). altDevBlog article
Shipped that approach, worked fine even on toasters.