mirror of
https://github.com/encounter/aurora.git
synced 2025-07-05 12:46:00 +00:00
Fix projection depth adjustment (I guess?)
This commit is contained in:
parent
f0c6a1666b
commit
d9de6603c7
@ -1,25 +1,18 @@
|
|||||||
#include "gx.hpp"
|
#include "gx.hpp"
|
||||||
|
|
||||||
#include <cfloat>
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
constexpr aurora::Mat4x4<float> DepthCorrect{
|
|
||||||
{1.f, 0.f, 0.f, 0.f},
|
|
||||||
{0.f, 1.f, 0.f, 0.f},
|
|
||||||
{0.f, 0.f, 1.f + FLT_EPSILON, 0.f},
|
|
||||||
{0.f, 0.f, 1.f, 1.f},
|
|
||||||
};
|
|
||||||
|
|
||||||
void GXSetProjection(const void* mtx_, GXProjectionType type) {
|
void GXSetProjection(const void* mtx_, GXProjectionType type) {
|
||||||
const auto& mtx = *reinterpret_cast<const aurora::Mat4x4<float>*>(mtx_);
|
const auto& mtx = *reinterpret_cast<const aurora::Mat4x4<float>*>(mtx_);
|
||||||
g_gxState.origProj = mtx;
|
g_gxState.origProj = mtx;
|
||||||
g_gxState.projType = type;
|
g_gxState.projType = type;
|
||||||
|
update_gx_state(g_gxState.proj,
|
||||||
#ifdef AURORA_NATIVE_MATRIX
|
#ifdef AURORA_NATIVE_MATRIX
|
||||||
update_gx_state(g_gxState.proj, DepthCorrect * mtx);
|
mtx
|
||||||
#else
|
#else
|
||||||
update_gx_state(g_gxState.proj, DepthCorrect * mtx.transpose());
|
mtx.transpose()
|
||||||
#endif
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO GXSetProjectionv
|
// TODO GXSetProjectionv
|
||||||
|
@ -803,7 +803,8 @@ wgpu::ShaderModule build_shader(const ShaderConfig& config, const ShaderInfo& in
|
|||||||
vtxXfrAttrsPre += fmt::format(
|
vtxXfrAttrsPre += fmt::format(
|
||||||
"\n var mv_pos = mul4x3(ubuf.pos_mtx, vec4<f32>({}, 1.0));"
|
"\n var mv_pos = mul4x3(ubuf.pos_mtx, vec4<f32>({}, 1.0));"
|
||||||
"\n var mv_nrm = normalize(mul4x3(ubuf.nrm_mtx, vec4<f32>({}, 0.0)));"
|
"\n var mv_nrm = normalize(mul4x3(ubuf.nrm_mtx, vec4<f32>({}, 0.0)));"
|
||||||
"\n out.pos = mul4x4(ubuf.proj, vec4<f32>(mv_pos, 1.0));",
|
"\n out.pos = mul4x4(ubuf.proj, vec4<f32>(mv_pos, 1.0));"
|
||||||
|
"\n out.pos.z += out.pos.w;",
|
||||||
vtx_attr(config, GX_VA_POS), vtx_attr(config, GX_VA_NRM));
|
vtx_attr(config, GX_VA_POS), vtx_attr(config, GX_VA_NRM));
|
||||||
if constexpr (EnableNormalVisualization) {
|
if constexpr (EnableNormalVisualization) {
|
||||||
vtxOutAttrs += fmt::format("\n @location({}) nrm: vec3<f32>,", vtxOutIdx++);
|
vtxOutAttrs += fmt::format("\n @location({}) nrm: vec3<f32>,", vtxOutIdx++);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user