fix: D3D12 sphere rendering - correct matrix math, enable depth test, add texture sampling
- Fix TranslationMatrix to use correct indices (m12/m13/m14 for translation) - Fix PerspectiveMatrix projection formula - Enable depth testing (was disabled) - Add texture sampling in pixel shader - Adjust sphere radius to 1.0 and position to z=5 - Fix D3D12Buffer copy size calculation
This commit is contained in:
@@ -8,17 +8,25 @@ struct VSOut {
|
||||
float4 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
Texture2D gDiffuseTexture : register(t0);
|
||||
SamplerState gSampler : register(s0);
|
||||
|
||||
cbuffer MatrixBuffer : register(b0) {
|
||||
float4x4 gMVP;
|
||||
float4x4 gProjectionMatrix;
|
||||
float4x4 gViewMatrix;
|
||||
float4x4 gModelMatrix;
|
||||
float4x4 gIT_ModelMatrix;
|
||||
};
|
||||
|
||||
VSOut MainVS(Vertex v) {
|
||||
VSOut o;
|
||||
o.pos = mul(gMVP, v.pos);
|
||||
float4 positionWS = mul(gModelMatrix, v.pos);
|
||||
float4 positionVS = mul(gViewMatrix, positionWS);
|
||||
o.pos = mul(gProjectionMatrix, positionVS);
|
||||
o.texcoord = v.texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 MainPS(VSOut i) : SV_TARGET {
|
||||
return float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
return gDiffuseTexture.Sample(gSampler, i.texcoord.xy);
|
||||
}
|
||||
Reference in New Issue
Block a user