still having a lot of view projection errors

This commit is contained in:
Peter Li 2025-04-18 22:34:12 -07:00
parent 4670f874f5
commit 72b97b3743
6 changed files with 9 additions and 7 deletions

View File

@ -26,15 +26,17 @@ StructuredBuffer<Scene> scene: register(t0, space0);
cbuffer Uniforms : register(b0, space1) cbuffer Uniforms : register(b0, space1)
{ {
float4x4 ViewProjection : packoffset(c0); float4x4 ViewProjection;
float time: packoffset(c16); float time;
}; };
#define IDENTITY_MATRIX float4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
Output main(Input input) Output main(Input input)
{ {
Output output; Output output;
output.TexCoord = input.UV; output.TexCoord = input.UV;
output.Position = mul(ViewProjection, mul(float4(input.Position, 1.0), scene[input.InstanceIndex].Model)); output.Position = mul(mul(float4(input.Position, 1.0), transpose(scene[input.InstanceIndex].Model)), transpose(ViewProjection));
return output; return output;
} }

View File

@ -48,7 +48,7 @@
{ {
"name" : "time", "name" : "time",
"type" : "float", "type" : "float",
"offset" : 256 "offset" : 64
} }
] ]
} }
@ -86,7 +86,7 @@
{ {
"type" : "_10", "type" : "_10",
"name" : "type.Uniforms", "name" : "type.Uniforms",
"block_size" : 260, "block_size" : 68,
"set" : 1, "set" : 1,
"binding" : 0 "binding" : 0
} }

View File

@ -66,6 +66,7 @@ pub fn resolve(self: *@This()) void {
self.transform = mul(zm.translationV(position.fmul(-1).toZm()), self.transform); self.transform = mul(zm.translationV(position.fmul(-1).toZm()), self.transform);
self.final = mul(self.transform, self.projection); self.final = mul(self.transform, self.projection);
core.engine_log("{any}", .{self.final});
self.finalAlt = mul(self.transform, self.projectionAlt); self.finalAlt = mul(self.transform, self.projectionAlt);
} }
} }

View File

@ -16,7 +16,6 @@ struct type_StructuredBuffer_Scene
struct type_Uniforms struct type_Uniforms
{ {
float4x4 ViewProjection; float4x4 ViewProjection;
char _m1_pad[192];
float time; float time;
}; };
@ -36,7 +35,7 @@ vertex main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniform
{ {
main0_out out = {}; main0_out out = {};
out.out_var_TEXCOORD0 = in.in_var_TEXCOORD3; out.out_var_TEXCOORD0 = in.in_var_TEXCOORD3;
out.gl_Position = Uniforms.ViewProjection * (float4(in.in_var_TEXCOORD0, 1.0) * scene._m0[gl_InstanceIndex].Model); out.gl_Position = transpose(transpose(Uniforms.ViewProjection)) * (transpose(transpose(scene._m0[gl_InstanceIndex].Model)) * float4(in.in_var_TEXCOORD0, 1.0));
return out; return out;
} }