mirror of
https://github.com/xemu-project/nxdk_pgraph_tests.git
synced 2025-02-17 00:27:44 +00:00
Adds more fog component tests.
This commit is contained in:
parent
a904ebded0
commit
3c23adb4fc
@ -6,6 +6,7 @@ struct vIn {
|
||||
struct vOut {
|
||||
float4 pos : POSITION;
|
||||
float4 col0 : COLOR0;
|
||||
float4 fog : FOG;
|
||||
};
|
||||
|
||||
vOut main(vIn I, uniform float4x4 model_matrix, uniform float4x4 view_matrix, uniform float4x4 projection_matrix,
|
||||
|
@ -26,7 +26,10 @@ vOut main(vIn I, uniform float4x4 model_matrix, uniform float4x4 view_matrix, un
|
||||
result.pos = pos;
|
||||
result.col0 = I.diffuse;
|
||||
|
||||
result.fog.w = fog_values.w;
|
||||
// Note: Compiler warnings about unused components are expected, this is intentionally part of the test.
|
||||
// Force all the correct components of fog_values to be referenced via `clamp`. Failure to do this results in
|
||||
// Cg generating code that copies the entire vector, causing values to be set erroneously.
|
||||
result.fog.w = clamp(fog_values.w, 0.0f, 1.0f);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -26,8 +26,11 @@ vOut main(vIn I, uniform float4x4 model_matrix, uniform float4x4 view_matrix, un
|
||||
result.pos = pos;
|
||||
result.col0 = I.diffuse;
|
||||
|
||||
result.fog.w = fog_values.w;
|
||||
result.fog.x = fog_values.x;
|
||||
// Note: Compiler warnings about unused components are expected, this is intentionally part of the test.
|
||||
// Force all the correct components of fog_values to be referenced via `clamp`. Failure to do this results in
|
||||
// Cg generating code that copies the entire vector, causing values to be set erroneously.
|
||||
result.fog.w = clamp(fog_values.w, 0.0f, 1.0f);
|
||||
result.fog.x = clamp(fog_values.x, 0.0f, 1.0f);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -26,8 +26,11 @@ vOut main(vIn I, uniform float4x4 model_matrix, uniform float4x4 view_matrix, un
|
||||
result.pos = pos;
|
||||
result.col0 = I.diffuse;
|
||||
|
||||
result.fog.w = fog_values.w;
|
||||
result.fog.y = fog_values.y;
|
||||
// Note: Compiler warnings about unused components are expected, this is intentionally part of the test.
|
||||
// Force all the correct components of fog_values to be referenced via `clamp`. Failure to do this results in
|
||||
// Cg generating code that copies the entire vector, causing values to be set erroneously.
|
||||
result.fog.w = clamp(fog_values.w, 0.0f, 1.0f);
|
||||
result.fog.y = clamp(fog_values.y, 0.0f, 1.0f);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -26,10 +26,13 @@ vOut main(vIn I, uniform float4x4 model_matrix, uniform float4x4 view_matrix, un
|
||||
result.pos = pos;
|
||||
result.col0 = I.diffuse;
|
||||
|
||||
result.fog.w = fog_values.w;
|
||||
result.fog.z = fog_values.z;
|
||||
result.fog.y = fog_values.y;
|
||||
result.fog.x = fog_values.x;
|
||||
// Note: Compiler warnings about unused components are expected, this is intentionally part of the test.
|
||||
// Force all the correct components of fog_values to be referenced via `clamp`. Failure to do this results in
|
||||
// Cg generating code that copies the entire vector, causing values to be set erroneously.
|
||||
result.fog.w = clamp(fog_values.w, 0.0f, 1.0f);
|
||||
result.fog.z = clamp(fog_values.z, 0.0f, 1.0f);
|
||||
result.fog.y = clamp(fog_values.y, 0.0f, 1.0f);
|
||||
result.fog.x = clamp(fog_values.x, 0.0f, 1.0f);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -26,7 +26,10 @@ vOut main(vIn I, uniform float4x4 model_matrix, uniform float4x4 view_matrix, un
|
||||
result.pos = pos;
|
||||
result.col0 = I.diffuse;
|
||||
|
||||
result.fog.x = fog_values.x;
|
||||
// Note: Compiler warnings about unused components are expected, this is intentionally part of the test.
|
||||
// Force all the correct components of fog_values to be referenced via `clamp`. Failure to do this results in
|
||||
// Cg generating code that copies the entire vector, causing values to be set erroneously.
|
||||
result.fog.x = clamp(fog_values.x, 0.0f, 1.0f);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -26,10 +26,13 @@ vOut main(vIn I, uniform float4x4 model_matrix, uniform float4x4 view_matrix, un
|
||||
result.pos = pos;
|
||||
result.col0 = I.diffuse;
|
||||
|
||||
result.fog.x = fog_values.x;
|
||||
result.fog.y = fog_values.y;
|
||||
result.fog.z = fog_values.z;
|
||||
result.fog.w = fog_values.w;
|
||||
// Note: Compiler warnings about unused components are expected, this is intentionally part of the test.
|
||||
// Force all the correct components of fog_values to be referenced via `clamp`. Failure to do this results in
|
||||
// Cg generating code that copies the entire vector, causing values to be set erroneously.
|
||||
result.fog.x = clamp(fog_values.x, 0.0f, 1.0f);
|
||||
result.fog.y = clamp(fog_values.y, 0.0f, 1.0f);
|
||||
result.fog.z = clamp(fog_values.z, 0.0f, 1.0f);
|
||||
result.fog.w = clamp(fog_values.w, 0.0f, 1.0f);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -6,13 +6,14 @@ struct vIn {
|
||||
struct vOut {
|
||||
float4 pos : POSITION;
|
||||
float4 col0 : COLOR0;
|
||||
float4 col1 : COLOR1;
|
||||
// cg expects this to be a single value, but will generate the correct code to manipulate a vector anyway.
|
||||
// Certain games (e.g., NFS Underground) treat oFog as a vec4, and that behavior is tested here.
|
||||
float4 fog : FOG;
|
||||
};
|
||||
|
||||
vOut main(vIn I, uniform float4x4 model_matrix, uniform float4x4 view_matrix, uniform float4x4 projection_matrix,
|
||||
uniform float4 fog_values) {
|
||||
uniform float4 fog_values, uniform float4 clamp_values, uniform float y_value_hack) {
|
||||
vOut result;
|
||||
|
||||
// Transform position and normal
|
||||
@ -26,7 +27,18 @@ vOut main(vIn I, uniform float4x4 model_matrix, uniform float4x4 view_matrix, un
|
||||
result.pos = pos;
|
||||
result.col0 = I.diffuse;
|
||||
|
||||
result.fog.y = fog_values.y;
|
||||
// Note: Compiler warnings about unused components are expected, this is intentionally part of the test.
|
||||
// Force all the correct components of fog_values to be referenced via `clamp`. Failure to do this results in
|
||||
// Cg generating code that copies the entire vector, causing values to be set erroneously.
|
||||
|
||||
// Unfortunately in the Y case, the clamp generates
|
||||
// MAX(oFog,y, R0.x, c[109]);
|
||||
// which ends up using c[109].x instead of c[109].y (c[109] = [1.0, 0.0, ...]) forcing y to always be 1.0.
|
||||
// To work around this, the y_value is passed in through an additional uniform.
|
||||
// Unfortunately we still need to use fog_values so it keeps its place in the transform constants, so it is assigned
|
||||
// to specular output.
|
||||
result.col1.r = clamp(fog_values.y, clamp_values.x, clamp_values.y);
|
||||
result.fog.y = y_value_hack;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -26,7 +26,10 @@ vOut main(vIn I, uniform float4x4 model_matrix, uniform float4x4 view_matrix, un
|
||||
result.pos = pos;
|
||||
result.col0 = I.diffuse;
|
||||
|
||||
result.fog.z = fog_values.z;
|
||||
// Note: Compiler warnings about unused components are expected, this is intentionally part of the test.
|
||||
// Force all the correct components of fog_values to be referenced via `clamp`. Failure to do this results in
|
||||
// Cg generating code that copies the entire vector, causing values to be set erroneously.
|
||||
result.fog.z = clamp(fog_values.z, 0.0f, 1.0f);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -327,16 +327,19 @@ static constexpr uint32_t kFogVec4Z[] = {
|
||||
|
||||
// clang format off
|
||||
static const FogVec4CoordTests::TestConfig kFogWTests[] = {
|
||||
{"None", DEF_SHADER(kFogVec4Unset), {0.0f, 0.0f, 0.0f, 0.0f}},
|
||||
// None just carries over the last set value.
|
||||
// {"None", DEF_SHADER(kFogVec4Unset), {0.0f, 0.0f, 0.0f, 0.0f}},
|
||||
|
||||
{"W", DEF_SHADER(kFogVec4W), {0.0f, 0.0f, 0.0f, 0.0f}},
|
||||
{"W", DEF_SHADER(kFogVec4W), {0.0f, 0.0f, 0.0f, 1.0f}},
|
||||
{"W", DEF_SHADER(kFogVec4W), {0.0f, 0.25f, 0.0f, 0.0f}},
|
||||
{"W", DEF_SHADER(kFogVec4W), {0.5f, 0.5f, 0.0f, 0.0f}},
|
||||
{"W", DEF_SHADER(kFogVec4W), {1.0f, 0.0f, 0.0f, 0.5f}},
|
||||
{"W", DEF_SHADER(kFogVec4W), {0.3f, 0.3f, 0.3f, 1.0f}},
|
||||
|
||||
{"WX", DEF_SHADER(kFogVec4WX), {0.25f, 0.0f, 0.0f, 0.5f}},
|
||||
{"WX", DEF_SHADER(kFogVec4WX), {0.65f, 0.0f, 0.0f, 0.0f}},
|
||||
|
||||
{"WY", DEF_SHADER(kFogVec4WY), {0.0f, 0.0f, 0.25f, 0.75f}},
|
||||
{"WY", DEF_SHADER(kFogVec4WY), {0.0f, 0.0f, 0.75f, 0.25f}},
|
||||
{"WY", DEF_SHADER(kFogVec4WY), {1.0f, 0.0f, 1.00f, 0.75f}},
|
||||
{"WY", DEF_SHADER(kFogVec4WY), {0.0f, 0.75f, 0.75f, 0.25f}},
|
||||
|
||||
{"WZYX", DEF_SHADER(kFogVec4WZYX), {0.25f, 0.5f, 0.75f, 1.0f}},
|
||||
{"WZYX", DEF_SHADER(kFogVec4WZYX), {1.0f, 0.75f, 0.5f, 0.25f}},
|
||||
@ -347,9 +350,11 @@ static const FogVec4CoordTests::TestConfig kFogWTests[] = {
|
||||
{"XYZW", DEF_SHADER(kFogVec4XYZW), {1.0f, 0.25f, 0.75f, 0.5f}},
|
||||
{"XYZW", DEF_SHADER(kFogVec4XYZW), {0.0f, 0.33f, 0.66f, 0.9f}},
|
||||
|
||||
{"Y", DEF_SHADER(kFogVec4Y), {0.0f, 4.0f, 0.0f, 0.0f}},
|
||||
{"Y", DEF_SHADER(kFogVec4Y), {0.0f, 6.0f, 0.0f, 0.0f}},
|
||||
{"Y", DEF_SHADER(kFogVec4Y), {0.0f, 0.0f, 0.0f, 0.0f}},
|
||||
{"Y", DEF_SHADER(kFogVec4Y), {0.0f, 0.1f, 0.0f, 0.0f}},
|
||||
{"Y", DEF_SHADER(kFogVec4Y), {0.0f, 0.6f, 0.0f, 0.0f}},
|
||||
|
||||
{"Z", DEF_SHADER(kFogVec4Z), {0.0f, 0.0f, 0.0f, 0.0f}},
|
||||
{"Z", DEF_SHADER(kFogVec4Z), {0.0f, 0.0f, 0.2f, 0.0f}},
|
||||
{"Z", DEF_SHADER(kFogVec4Z), {0.0f, 0.0f, 0.8f, 0.0f}},
|
||||
};
|
||||
@ -392,6 +397,10 @@ void FogVec4CoordTests::Test(const TestConfig& config) {
|
||||
auto shader = host_.GetShaderProgram();
|
||||
shader->SetShaderOverride(config.shader, config.shader_size);
|
||||
shader->SetUniformF(12, config.fog[0], config.fog[1], config.fog[2], config.fog[3]);
|
||||
// const c[13] = 1 0
|
||||
shader->SetUniformF(13, 1.0f, 0.0f);
|
||||
// Hack for bug in Cg/vpcompiler wrt. clamp on the y-value. See fog_vec4_y.vs.cg.
|
||||
shader->SetUniformF(14, config.fog[1]);
|
||||
host_.SetShaderProgram(shader);
|
||||
|
||||
static constexpr uint32_t kBackgroundColor = 0xFF303030;
|
||||
|
Loading…
x
Reference in New Issue
Block a user