static void begin_depthmap_pass(Shader *self) { // 描画先を影用深度記録画像にする SetDrawScreen(self->depthmap_screen); // 影用深度記録画像を真っ白にクリア SetBackgroundColor(255, 255, 255); ClearDrawScreen(); SetBackgroundColor(0, 0, 0); // カメラのタイプを正射影タイプにセット、描画範囲も指定 SetupCamera_Ortho(13250.0f); // 描画する奥行き範囲をセット SetCameraNearFar(10.0f, 13050.0f); // カメラの位置と注視点はステージ全体が見渡せる位置 VECTOR LightTarget = VGet(3620.0f, 0.0f, 3830.0f); // カメラの向きはライトの向き VECTOR LightDirection = VScale(GetLightDirection(), -12400.0f); // カメラの位置と注視点はステージ全体が見渡せる位置 VECTOR LightPosition = VAdd(LightTarget, LightDirection); SetCameraPositionAndTarget_UpVecY(LightPosition, LightTarget); self->light_camera_view_matrix = GetCameraViewMatrix(); self->light_camera_projection_matrix = GetCameraProjectionMatrix(); SetUseVertexShader(self->depthmap_vs); SetUsePixelShader(self->depthmap_ps); }
Vector3 Mouse::ScreenPointToWorld(float z) { Matrix view = GetCameraViewMatrix(); Matrix projection = GetCameraProjectionMatrix(); Matrix viewport = GetCameraViewportMatrix(); Matrix inverse = (view * projection * viewport).inversed(); Point2 pos = Position(); Vector4 v = Vector4(static_cast<float>(pos.x), static_cast<float>(pos.y), z, 1.0f) * inverse; v.x /= v.w; v.y /= v.w; v.z /= v.w; return Vector3(v); }
void Effekseer_Sync3DSetting() { if(g_renderer3d == nullptr) return; MATRIX proj = GetCameraProjectionMatrix(); MATRIX view = GetCameraViewMatrix(); Effekseer::Matrix44 efproj, efview; for(int i=0;i<4;++i){ for(int j=0;j<4;++j){ efproj.Values[j][i] = proj.m[j][i]; efview.Values[j][i] = view.m[j][i]; } } g_renderer3d->SetProjectionMatrix(efproj); g_renderer3d->SetCameraMatrix(efview); }
// 影用の深度記録画像の準備を行う void SetupDepthImage( void ) { int i ; VECTOR LightDirection ; VECTOR LightPosition ; VECTOR LightTarget ; // 描画先を影用深度記録画像にする SetDrawScreen( DepthBufferGraphHandle ) ; // 影用深度記録画像を真っ白にクリア SetBackgroundColor( 255, 255, 255 ) ; ClearDrawScreen() ; SetBackgroundColor( 0, 0, 0 ) ; // カメラのタイプを正射影タイプにセット、描画範囲も指定 SetupCamera_Ortho( 13250.0f ) ; // 描画する奥行き範囲をセット SetCameraNearFar( 10.0f, 13050.0f ) ; // カメラの向きはライトの向き LightDirection = GetLightDirection() ; // カメラの位置と注視点はステージ全体が見渡せる位置 LightTarget.x = 3620.0f ; LightTarget.y = 0.0f ; LightTarget.z = 3830.0f ; LightPosition = VAdd( LightTarget, VScale( LightDirection, -12400.0f ) ) ; SetCameraPositionAndTarget_UpVecY( LightPosition, LightTarget ) ; // 設定したカメラのビュー行列と射影行列を取得しておく LightCamera_ViewMatrix = GetCameraViewMatrix() ; LightCamera_ProjectionMatrix = GetCameraProjectionMatrix() ; // モデルの描画にオリジナルのシェーダーを使用するように設定する MV1SetUseOrigShader( TRUE ) ; // 深度記録画像への描画用のピクセルシェーダーをセット SetUsePixelShader( DepthShadow_Step1_PixelShader ) ; // 深度記録画像への剛体メッシュ描画用の頂点シェーダーをセット SetUseVertexShader( Normal_DepthShadow_Step1_VertexShader ) ; // ステージを描画 MV1DrawModel( stg.ModelHandle ) ; // 深度記録画像へのスキニングメッシュ描画用の頂点シェーダーをセット SetUseVertexShader( Skin4_DepthShadow_Step1_VertexShader ) ; // プレイヤーモデルの描画 MV1DrawModel( pl.CharaInfo.ModelHandle ) ; // プレイヤー以外キャラモデルの描画 for( i = 0 ; i < NOTPLAYER_NUM ; i ++ ) { MV1DrawModel( npl[ i ].CharaInfo.ModelHandle ) ; } // モデルの描画にオリジナルのシェーダーを使用するようにした設定を解除 MV1SetUseOrigShader( FALSE ) ; // 描画先を裏画面に戻す SetDrawScreen( DX_SCREEN_BACK ) ; }