0.2.0-dev Download ZIP
68 lines ·3.4 KB Raw
| 1 | /**************************************************************************/ |
| 2 | /* test_gltf_emissive.h */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #pragma once |
| 32 | |
| 33 | #include "test_gltf.h" |
| 34 | |
| 35 | #ifdef TOOLS_ENABLED |
| 36 | |
| 37 | namespace TestGltf { |
| 38 | |
| 39 | TEST_CASE("[SceneTree][Node] GLTF emissiveTexture without emissiveFactor uses white emission") { |
| 40 | init("gltf_emissive_no_factor", "res://"); |
| 41 | |
| 42 | Node *loaded = gltf_import("res://emissive_no_factor.gltf"); |
| 43 | CHECK_MESSAGE(loaded != nullptr, "Failed to load GLB."); |
| 44 | |
| 45 | MeshInstance3D *mesh = Object::cast_to<MeshInstance3D>(loaded->find_child("Cube", true, true)); |
| 46 | CHECK_MESSAGE(mesh != nullptr, "Mesh not found."); |
| 47 | |
| 48 | Ref<StandardMaterial3D> mat = mesh->get_active_material(0); |
| 49 | CHECK_MESSAGE(mat.is_valid(), "Material not found."); |
| 50 | |
| 51 | // Emission should be enabled. |
| 52 | CHECK(mat->get_feature(BaseMaterial3D::FEATURE_EMISSION)); |
| 53 | |
| 54 | // Emission operator should be MULTIPLY per glTF spec. |
| 55 | CHECK(mat->get_emission_operator() == BaseMaterial3D::EMISSION_OP_MULTIPLY); |
| 56 | |
| 57 | // Without emissiveFactor, emission color should be WHITE, not BLACK. |
| 58 | Color c = mat->get_emission(); |
| 59 | CHECK_MESSAGE(c.r > 0.9f, "Emission red should be ~1.0 when emissiveFactor is absent."); |
| 60 | CHECK_MESSAGE(c.g > 0.9f, "Emission green should be ~1.0 when emissiveFactor is absent."); |
| 61 | CHECK_MESSAGE(c.b > 0.9f, "Emission blue should be ~1.0 when emissiveFactor is absent."); |
| 62 | |
| 63 | memdelete(loaded); |
| 64 | } |
| 65 | |
| 66 | } // namespace TestGltf |
| 67 | |
| 68 | #endif // TOOLS_ENABLED |