Render portal gun with smaller near clip plane.
This commit is contained in:
parent
f0be2b4048
commit
510623ca54
|
@ -140,6 +140,26 @@ error:
|
|||
return 0;
|
||||
}
|
||||
|
||||
void cameraModifyProjectionViewForPortalGun(struct Camera* camera, struct RenderState* renderState, float newNearPlane, float aspectRatio)
|
||||
{
|
||||
Mtx* portalGunProjectionView = renderStateRequestMatrices(renderState, 1);
|
||||
if(!portalGunProjectionView)
|
||||
return;
|
||||
|
||||
struct Camera portalCam = *camera;
|
||||
portalCam.nearPlane = newNearPlane;
|
||||
float view[4][4];
|
||||
float projectionView[4][4];
|
||||
unsigned short perspectiveNormalize;
|
||||
cameraBuildProjectionMatrix(&portalCam, projectionView, &perspectiveNormalize, aspectRatio);
|
||||
cameraBuildViewMatrix(&portalCam, view);
|
||||
guMtxCatF(view, projectionView, projectionView);
|
||||
|
||||
guMtxF2L(projectionView, portalGunProjectionView);
|
||||
gSPMatrix(renderState->dl++, osVirtualToPhysical(portalGunProjectionView), G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH);
|
||||
gSPPerspNormalize(renderState->dl++, perspectiveNormalize);
|
||||
}
|
||||
|
||||
int cameraApplyMatrices(struct RenderState* renderState, struct CameraMatrixInfo* matrixInfo) {
|
||||
Mtx* modelMatrix = renderStateRequestMatrices(renderState, 1);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ void cameraInit(struct Camera* camera, float fov, float near, float far);
|
|||
void cameraBuildViewMatrix(struct Camera* camera, float matrix[4][4]);
|
||||
void cameraBuildProjectionMatrix(struct Camera* camera, float matrix[4][4], u16* perspectiveNorm, float aspectRatio);
|
||||
int cameraSetupMatrices(struct Camera* camera, struct RenderState* renderState, float aspectRatio, Vp* viewport, int extractClippingPlanes, struct CameraMatrixInfo* output);
|
||||
void cameraModifyProjectionViewForPortalGun(struct Camera* camera, struct RenderState* renderState, float newNearPlane, float aspectRatio);
|
||||
|
||||
int cameraApplyMatrices(struct RenderState* renderState, struct CameraMatrixInfo* matrixInfo);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#define DEFAULT_FAR_PLANE 30.0f
|
||||
#define DEFAULT_NEAR_PLANE 0.125f
|
||||
#define PORTAL_GUN_NEAR_PLANE 0.05f
|
||||
|
||||
#define MAX_PORTAL_STEPS 6
|
||||
|
||||
|
|
|
@ -299,6 +299,7 @@ void sceneRender(struct Scene* scene, struct RenderState* renderState, struct Gr
|
|||
renderPlanBuild(&renderPlan, scene, renderState);
|
||||
renderPlanExecute(&renderPlan, scene, staticMatrices, renderState);
|
||||
|
||||
cameraModifyProjectionViewForPortalGun(&scene->camera, renderState, PORTAL_GUN_NEAR_PLANE * SCENE_SCALE, renderPlan.stageProps[0].aspectRatio);
|
||||
portalGunRenderReal(&scene->portalGun, renderState);
|
||||
|
||||
gDPPipeSync(renderState->dl++);
|
||||
|
|
Loading…
Reference in a new issue