mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-15 18:49:51 +01:00
DX9: Use 4x3 matrices for bones too. Compact shader constants.
This commit is contained in:
1 parent
6304d60b40
commit
9c625a79a1
3 files changed
+29
-29
No files matched your search
@@ -308,7 +308,7 @@ void ShaderManagerDX9::VSUpdateUniforms(int dirtyUniforms) {
|
||||
#else
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (dirtyUniforms & (DIRTY_BONEMATRIX0 << i)) {
|
||||
VSSetMatrix4x3(CONST_VS_BONE0 + 4 * i, gstate.boneMatrix + 12 * i);
|
||||
VSSetMatrix4x3_3(CONST_VS_BONE0 + 4 * i, gstate.boneMatrix + 12 * i);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -182,10 +182,10 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) {
|
||||
if (vertTypeIsSkinningEnabled(vertType)) {
|
||||
int numBones = TranslateNumBonesDX9(vertTypeGetNumBoneWeights(vertType));
|
||||
#ifdef USE_BONE_ARRAY
|
||||
WRITE(p, "float4x4 u_bone[%i] : register(c%i);\n", numBones, CONST_VS_BONE0);
|
||||
WRITE(p, "float4x3 u_bone[%i] : register(c%i);\n", numBones, CONST_VS_BONE0);
|
||||
#else
|
||||
for (int i = 0; i < numBones; i++) {
|
||||
WRITE(p, "float4x4 u_bone%i : register(c%i);\n", i, CONST_VS_BONE0 + i * 4);
|
||||
WRITE(p, "float4x3 u_bone%i : register(c%i);\n", i, CONST_VS_BONE0 + i * 4);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -343,9 +343,9 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) {
|
||||
|
||||
#ifdef USE_BONE_ARRAY
|
||||
if (numWeights == 1)
|
||||
WRITE(p, " mat4 skinMatrix = a_w1 * u_bone[0]");
|
||||
WRITE(p, " float4x3 skinMatrix = a_w1 * u_bone[0]");
|
||||
else
|
||||
WRITE(p, " mat4 skinMatrix = a_w1.x * u_bone[0]");
|
||||
WRITE(p, " float4x3 skinMatrix = a_w1.x * u_bone[0]");
|
||||
for (int i = 1; i < numWeights; i++) {
|
||||
const char *weightAttr = boneWeightAttr[i];
|
||||
// workaround for "cant do .x of scalar" issue
|
||||
@@ -357,9 +357,9 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) {
|
||||
// Uncomment this to screw up bone shaders to check the vertex shader software fallback
|
||||
// WRITE(p, "THIS SHOULD ERROR! #error");
|
||||
if (numWeights == 1)
|
||||
WRITE(p, " float4x4 skinMatrix = mul(In.a_w1, u_bone0)");
|
||||
WRITE(p, " float4x3 skinMatrix = mul(In.a_w1, u_bone0)");
|
||||
else
|
||||
WRITE(p, " float4x4 skinMatrix = mul(In.a_w1.x, u_bone0)");
|
||||
WRITE(p, " float4x3 skinMatrix = mul(In.a_w1.x, u_bone0)");
|
||||
for (int i = 1; i < numWeights; i++) {
|
||||
const char *weightAttr = boneWeightAttr[i];
|
||||
// workaround for "cant do .x of scalar" issue
|
||||
@@ -374,11 +374,11 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) {
|
||||
WRITE(p, ";\n");
|
||||
|
||||
// Trying to simplify this results in bugs in LBP...
|
||||
WRITE(p, " float3 skinnedpos = mul(float4(In.position.xyz, 1.0), skinMatrix).xyz;\n");
|
||||
WRITE(p, " float3 skinnedpos = mul(float4(In.position.xyz, 1.0), skinMatrix);\n");
|
||||
WRITE(p, " float3 worldpos = mul(float4(skinnedpos, 1.0), u_world);\n");
|
||||
|
||||
if (hasNormal) {
|
||||
WRITE(p, " float3 skinnednormal = mul(float4(%sIn.normal, 0.0), skinMatrix).xyz;\n", flipNormal ? "-" : "");
|
||||
WRITE(p, " float3 skinnednormal = mul(float4(%sIn.normal, 0.0), skinMatrix);\n", flipNormal ? "-" : "");
|
||||
WRITE(p, " float3 worldnormal = normalize(mul(float4(skinnednormal, 0.0), u_world));\n");
|
||||
} else {
|
||||
WRITE(p, " float3 worldnormal = mul( mul( float4(0.0, 0.0, 1.0, 0.0), skinMatrix), u_world);\n");
|
||||
|
||||
@@ -67,25 +67,25 @@ int TranslateNumBonesDX9(int bones);
|
||||
#define CONST_VS_FOGCOEF 18
|
||||
#define CONST_VS_AMBIENT 19
|
||||
#define CONST_VS_BONE0 20
|
||||
#define CONST_VS_BONE1 24
|
||||
#define CONST_VS_BONE2 28
|
||||
#define CONST_VS_BONE3 32
|
||||
#define CONST_VS_BONE4 36
|
||||
#define CONST_VS_BONE5 40
|
||||
#define CONST_VS_BONE6 44
|
||||
#define CONST_VS_BONE7 48
|
||||
#define CONST_VS_BONE8 52
|
||||
#define CONST_VS_MATAMBIENTALPHA 59
|
||||
#define CONST_VS_MATDIFFUSE 60
|
||||
#define CONST_VS_MATSPECULAR 61
|
||||
#define CONST_VS_MATEMISSIVE 62
|
||||
#define CONST_VS_LIGHTPOS 64
|
||||
#define CONST_VS_LIGHTDIR 68
|
||||
#define CONST_VS_LIGHTATT 72
|
||||
#define CONST_VS_LIGHTANGLE 76
|
||||
#define CONST_VS_LIGHTSPOTCOEF 80
|
||||
#define CONST_VS_LIGHTDIFFUSE 84
|
||||
#define CONST_VS_LIGHTSPECULAR 88
|
||||
#define CONST_VS_LIGHTAMBIENT 92
|
||||
#define CONST_VS_BONE1 23
|
||||
#define CONST_VS_BONE2 26
|
||||
#define CONST_VS_BONE3 29
|
||||
#define CONST_VS_BONE4 32
|
||||
#define CONST_VS_BONE5 35
|
||||
#define CONST_VS_BONE6 38
|
||||
#define CONST_VS_BONE7 41
|
||||
#define CONST_VS_BONE8 44
|
||||
#define CONST_VS_MATAMBIENTALPHA 47
|
||||
#define CONST_VS_MATDIFFUSE 48
|
||||
#define CONST_VS_MATSPECULAR 49
|
||||
#define CONST_VS_MATEMISSIVE 50
|
||||
#define CONST_VS_LIGHTPOS 51
|
||||
#define CONST_VS_LIGHTDIR 55
|
||||
#define CONST_VS_LIGHTATT 59
|
||||
#define CONST_VS_LIGHTANGLE 63
|
||||
#define CONST_VS_LIGHTSPOTCOEF 67
|
||||
#define CONST_VS_LIGHTDIFFUSE 71
|
||||
#define CONST_VS_LIGHTSPECULAR 75
|
||||
#define CONST_VS_LIGHTAMBIENT 79
|
||||
|
||||
};
|
||||
Reference in new issue
Block a user