AVA2 cross-platform client parity baseline
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
#include "eter_render/EnvironmentData.h"
|
||||
#include "eter_render/SkyBox.h"
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
void TestEnvironmentPresets() {
|
||||
std::cout << "[Test] Environment Presets..." << std::endl;
|
||||
|
||||
auto day = ava2::EnvironmentData::CreateDayPreset();
|
||||
assert(day.name == "day");
|
||||
assert(day.fog.enable == true);
|
||||
assert(day.fog.near_dist > 0.0f);
|
||||
assert(day.skybox.gradient_level_upper == 4);
|
||||
assert(day.skybox.gradient_level_lower == 1);
|
||||
assert(day.skybox.gradients.size() == 5);
|
||||
assert(day.lens_flare.main_flare_enable == true);
|
||||
|
||||
auto sunset = ava2::EnvironmentData::CreateSunsetPreset();
|
||||
assert(sunset.name == "sunset");
|
||||
assert(sunset.dir_light.bg_diffuse[1] < 0.8f); // Warm reddish
|
||||
assert(sunset.skybox.gradients.size() == 5);
|
||||
|
||||
auto night = ava2::EnvironmentData::CreateNightPreset();
|
||||
assert(night.name == "night");
|
||||
assert(night.dir_light.bg_diffuse[2] > night.dir_light.bg_diffuse[0]); // Bluish moonlight
|
||||
assert(night.lens_flare.enable == false);
|
||||
|
||||
auto snow = ava2::EnvironmentData::CreateSnowPreset();
|
||||
assert(snow.name == "snow");
|
||||
assert(snow.fog.near_dist < 2000.0f); // Dense snow fog
|
||||
|
||||
std::cout << " -> Presets verified successfully!" << std::endl;
|
||||
}
|
||||
|
||||
void TestEnvironmentParsing() {
|
||||
std::cout << "[Test] Parsing .msenv data..." << std::endl;
|
||||
|
||||
const std::string sample_msenv = R"(
|
||||
ScriptType EnvrionmentData
|
||||
ScriptVersion 1.0000
|
||||
|
||||
Group DirectionalLight
|
||||
{
|
||||
Direction 0.350156 0.562609 -0.748907
|
||||
|
||||
Group Background
|
||||
{
|
||||
Enable 1
|
||||
Diffuse 1.000000 0.972549 0.972549 1.000000
|
||||
Ambient 0.000000 0.000000 0.000000 1.000000
|
||||
}
|
||||
|
||||
Group Character
|
||||
{
|
||||
Enable 1
|
||||
Diffuse 1.000000 0.972549 0.972549 1.000000
|
||||
Ambient 0.150000 0.150000 0.150000 1.000000
|
||||
}
|
||||
}
|
||||
Group Material
|
||||
{
|
||||
Diffuse 1.000000 1.000000 1.000000 1.000000
|
||||
Ambient 0.882353 0.854902 0.784314 1.000000
|
||||
Emissive 0.321569 0.321569 0.411765 1.000000
|
||||
}
|
||||
|
||||
Group Fog
|
||||
{
|
||||
Enable 1
|
||||
NearDistance 5000.000000
|
||||
FarDistance 20000.000000
|
||||
Color 0.847059 0.901961 1.000000 1.000000
|
||||
}
|
||||
|
||||
Group SkyBox
|
||||
{
|
||||
bTextureRenderMode 0
|
||||
Scale 3500.000000 3500.000000 3500.000000
|
||||
GradientLevelUpper 4
|
||||
GradientLevelLower 1
|
||||
|
||||
CloudScale 200000.000000 200000.000000
|
||||
CloudHeight 30000.000000
|
||||
CloudTextureScale 4.000000 4.000000
|
||||
CloudSpeed 0.004000 0.004000
|
||||
CloudTextureFileName "d:/ymir work/environment/clouds_zone01.tga"
|
||||
List CloudColor
|
||||
{
|
||||
0.000000 0.000000 0.000000 0.000000
|
||||
0.000000 0.000000 0.000000 0.000000
|
||||
}
|
||||
List Gradient
|
||||
{
|
||||
0.094118 0.286275 0.658824 0.000000
|
||||
0.231373 0.403922 0.729412 0.000000
|
||||
|
||||
0.231373 0.403922 0.729412 0.000000
|
||||
0.376471 0.498039 0.729412 0.000000
|
||||
|
||||
0.376471 0.498039 0.729412 0.000000
|
||||
0.568627 0.678431 0.882353 0.000000
|
||||
|
||||
0.568627 0.678431 0.882353 0.000000
|
||||
0.850980 0.901961 1.000000 0.000000
|
||||
|
||||
0.847059 0.901961 1.000000 0.000000
|
||||
0.529412 0.564706 0.619608 0.000000
|
||||
}
|
||||
}
|
||||
|
||||
Group LensFlare
|
||||
{
|
||||
Enable 0
|
||||
BrightnessColor 1.000000 0.886275 0.886275 1.000000
|
||||
MaxBrightness 0.740000
|
||||
MainFlareEnable 1
|
||||
MainFlareTextureFileName "D:\Ymir Work\environment\sunflare.dds"
|
||||
MainFlareSize 0.350000
|
||||
}
|
||||
)";
|
||||
|
||||
ava2::EnvironmentData env;
|
||||
bool ok = env.LoadFromString(sample_msenv);
|
||||
assert(ok);
|
||||
|
||||
// Validate Directional Light
|
||||
assert(std::abs(env.dir_light.direction[0] - 0.350156f) < 1e-4f);
|
||||
assert(env.dir_light.bg_enable == true);
|
||||
assert(env.dir_light.chr_enable == true);
|
||||
|
||||
// Validate Fog
|
||||
assert(env.fog.enable == true);
|
||||
assert(std::abs(env.fog.near_dist - 5000.0f) < 1.0f);
|
||||
assert(std::abs(env.fog.far_dist - 20000.0f) < 1.0f);
|
||||
|
||||
// Validate SkyBox
|
||||
assert(env.skybox.texture_render_mode == false);
|
||||
assert(env.skybox.gradient_level_upper == 4);
|
||||
assert(env.skybox.gradient_level_lower == 1);
|
||||
assert(env.skybox.gradients.size() == 5);
|
||||
assert(env.skybox.cloud_texture_file_name == "ymir work/environment/clouds_zone01.tga");
|
||||
assert(std::abs(env.skybox.cloud_speed[0] - 0.004f) < 1e-5f);
|
||||
|
||||
// Validate LensFlare
|
||||
assert(env.lens_flare.main_flare_enable == true);
|
||||
assert(env.lens_flare.main_flare_file_name == "Ymir Work/environment/sunflare.dds" ||
|
||||
env.lens_flare.main_flare_file_name == "ymir work/environment/sunflare.dds");
|
||||
assert(std::abs(env.lens_flare.main_flare_size - 0.35f) < 1e-4f);
|
||||
|
||||
std::cout << " -> Parsing verified successfully!" << std::endl;
|
||||
}
|
||||
|
||||
void TestSkyBoxRendering() {
|
||||
std::cout << "[Test] SkyBox Draw Commands Generation..." << std::endl;
|
||||
|
||||
ava2::SkyBox sky;
|
||||
auto day = ava2::EnvironmentData::CreateDayPreset();
|
||||
sky.SetEnvironment(day);
|
||||
|
||||
// Simulate update
|
||||
sky.Update(0.5f);
|
||||
|
||||
float view[16] = {
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
};
|
||||
float proj[16] = {
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
};
|
||||
|
||||
float eyeX = 100.0f, eyeY = 50.0f, eyeZ = -200.0f;
|
||||
auto draws = sky.BuildDrawCommands(view, proj, eyeX, eyeY, eyeZ);
|
||||
|
||||
// Expect at least 3 draws: SkyDome, CloudPlane, SunFlare
|
||||
assert(draws.size() >= 3);
|
||||
|
||||
// 1. SkyDome
|
||||
const auto& skydome = draws[0];
|
||||
assert(!skydome.positions.empty());
|
||||
assert(!skydome.indices.empty());
|
||||
assert(!skydome.diffuse.empty());
|
||||
assert(skydome.lighting == false);
|
||||
assert(skydome.fog == false);
|
||||
assert(skydome.z_write == false);
|
||||
assert(skydome.z_enable == false);
|
||||
|
||||
// 2. CloudPlane
|
||||
const auto& clouds = draws[1];
|
||||
assert(!clouds.positions.empty());
|
||||
assert(!clouds.indices.empty());
|
||||
assert(clouds.alpha_blend == true);
|
||||
assert(clouds.fog == false);
|
||||
assert(clouds.z_write == false);
|
||||
assert(clouds.texture0 == "ymir work/environment/clouds_zone01.tga");
|
||||
|
||||
// 3. SunFlare
|
||||
const auto& sun = draws[2];
|
||||
assert(!sun.positions.empty());
|
||||
assert(sun.indices.size() == 6);
|
||||
assert(sun.blend_mode == 1); // Additive blend D3DBLEND_ONE
|
||||
assert(sun.fog == false);
|
||||
assert(sun.z_write == false);
|
||||
assert(sun.texture0 == "ymir work/environment/sunflare.dds");
|
||||
|
||||
std::cout << " -> SkyBox draw commands verified successfully!" << std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::cout << "=== Running Environment & SkyBox Engine Tests ===" << std::endl;
|
||||
TestEnvironmentPresets();
|
||||
TestEnvironmentParsing();
|
||||
TestSkyBoxRendering();
|
||||
std::cout << "=== ALL Environment & SkyBox Tests PASSED (100%) ===" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user