CCubeMaterial: implement final TCG

GX: add ability to view normals (disabled)
This commit is contained in:
Phillip Stephens 2022-03-26 19:21:55 -07:00
parent 07b4208c42
commit 7461188a43
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
2 changed files with 23 additions and 7 deletions

View File

@ -434,10 +434,23 @@ u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PT
return 1; return 1;
} }
case 7: { case 7: {
// TODO zeus::CTransform mtx = CGraphics::g_ViewMatrix.inverse().multiplyIgnoreTranslation(CGraphics::g_GXModelMatrix);
zeus::CTransform xf; mtx.origin.zeroOut();
GXLoadTexMtxImm(&xf, texMtx, GX::MTX3x4); float xy = SBig(params[1]) * (CGraphics::g_ViewMatrix.origin.x() + CGraphics::g_ViewMatrix.origin.y()) * 0.025f;
GXLoadTexMtxImm(&xf, pttTexMtx, GX::MTX3x4); xy = (xy - static_cast<int>(xy));
float z = SBig(params[1]) * CGraphics::g_ViewMatrix.origin.z() * 0.05f;
z = (z - static_cast<int>(z));
float halfA = SBig(params[0]) * 0.5f;
zeus::CTransform postMtx{
{
zeus::CVector3f{halfA, 0.f, 0.f},
zeus::CVector3f{0.f, 0.f, 0.f},
zeus::CVector3f{0.f, halfA, 0.f},
},
zeus::CVector3f{xy, z, 1.f},
};
GXLoadTexMtxImm(&mtx, texMtx, GX::MTX3x4);
GXLoadTexMtxImm(&postMtx, pttTexMtx, GX::MTX3x4);
return 3; return 3;
} }
default: default:

View File

@ -498,7 +498,7 @@ std::pair<wgpu::ShaderModule, ShaderInfo> build_shader(const ShaderConfig& confi
std::string vtxXfrAttrsPre; std::string vtxXfrAttrsPre;
std::string vtxXfrAttrs; std::string vtxXfrAttrs;
size_t locIdx = 0; size_t locIdx = 0;
size_t vtxOutIdx = 0; size_t vtxOutIdx = 1;
size_t uniBindingIdx = 1; size_t uniBindingIdx = 1;
if (config.indexedAttributeCount > 0) { if (config.indexedAttributeCount > 0) {
// Display list attributes // Display list attributes
@ -583,7 +583,8 @@ std::pair<wgpu::ShaderModule, ShaderInfo> build_shader(const ShaderConfig& confi
} }
vtxXfrAttrsPre += fmt::format(FMT_STRING("\n var mv_pos = ubuf.pos_mtx * vec4<f32>({}, 1.0);" vtxXfrAttrsPre += fmt::format(FMT_STRING("\n var mv_pos = ubuf.pos_mtx * vec4<f32>({}, 1.0);"
"\n var mv_nrm = ubuf.nrm_mtx * vec4<f32>({}, 0.0);" "\n var mv_nrm = ubuf.nrm_mtx * vec4<f32>({}, 0.0);"
"\n out.pos = ubuf.proj * vec4<f32>(mv_pos, 1.0);"), "\n out.pos = ubuf.proj * vec4<f32>(mv_pos, 1.0);"
"\n out.norm = vec4<f32>(mv_nrm, 0.0);"),
vtx_attr(config, GX::VA_POS), vtx_attr(config, GX::VA_NRM)); vtx_attr(config, GX::VA_POS), vtx_attr(config, GX::VA_NRM));
std::string fragmentFnPre; std::string fragmentFnPre;
@ -902,7 +903,8 @@ struct Uniform {{
var<uniform> ubuf: Uniform;{uniformBindings}{sampBindings}{texBindings} var<uniform> ubuf: Uniform;{uniformBindings}{sampBindings}{texBindings}
struct VertexOutput {{ struct VertexOutput {{
@builtin(position) pos: vec4<f32>;{vtxOutAttrs} @builtin(position) pos: vec4<f32>;
@location(0) norm: vec4<f32>;{vtxOutAttrs}
}}; }};
@stage(vertex) @stage(vertex)
@ -915,6 +917,7 @@ fn vs_main({vtxInAttrs}
@stage(fragment) @stage(fragment)
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {{ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {{
var prev: vec4<f32>;{fragmentFnPre}{fragmentFn} var prev: vec4<f32>;{fragmentFnPre}{fragmentFn}
//prev = vec4<f32>(in.norm.xyz, prev.a);
return prev; return prev;
}} }}
)"""), )"""),