2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali/devel-api/actors/actor-devel.h>
24 #include <dali-scene3d/public-api/controls/model/model.h>
25 #include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
26 #include <dali-scene3d/public-api/light/light.h>
27 #include <dali/public-api/object/property.h>
28 #include <toolkit-event-thread-callback.h>
31 using namespace Dali::Toolkit;
33 void light_startup(void)
35 test_return_value = TET_UNDEF;
38 void light_cleanup(void)
40 test_return_value = TET_PASS;
45 const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/BoxAnimated.gltf";
48 // Negative test case for a method
49 int UtcDaliLightUninitialized(void)
51 ToolkitTestApplication application;
52 tet_infoline("UtcDaliLightUninitialized");
58 // New() must be called to create a Model or it wont be valid.
59 Actor a = Actor::New();
61 DALI_TEST_CHECK(false);
63 catch(Dali::DaliException& e)
65 // Tests that a negative test of an assertion succeeds
66 DALI_TEST_PRINT_ASSERT(e);
67 DALI_TEST_CHECK(!light);
72 // Positive test case for a method
73 int UtcDaliLightNew(void)
75 ToolkitTestApplication application;
76 tet_infoline("UtcDaliLightNew");
78 Scene3D::Light light = Scene3D::Light::New();
79 DALI_TEST_CHECK(light);
83 // Positive test case for a method
84 int UtcDaliLightDownCast(void)
86 ToolkitTestApplication application;
87 tet_infoline("UtcDaliLightDownCast");
89 Scene3D::Light light = Scene3D::Light::New();
90 BaseHandle handle(light);
92 Scene3D::Light light2 = Scene3D::Light::DownCast(handle);
93 DALI_TEST_CHECK(light);
94 DALI_TEST_CHECK(light2);
95 DALI_TEST_CHECK(light == light2);
99 // Positive test case for a method
100 int UtcDaliLightCopyAndAssignment(void)
102 ToolkitTestApplication application;
104 Scene3D::Light light = Scene3D::Light::New();
105 DALI_TEST_CHECK(light);
107 Scene3D::Light copy(light);
108 DALI_TEST_CHECK(light == copy);
110 Scene3D::Light assign;
111 DALI_TEST_CHECK(!assign);
114 DALI_TEST_CHECK(assign == light);
119 int UtcDaliLightMoveConstructor(void)
121 ToolkitTestApplication application;
123 Scene3D::Light light = Scene3D::Light::New();
124 DALI_TEST_EQUALS(1, light.GetBaseObject().ReferenceCount(), TEST_LOCATION);
125 light.SetProperty(Actor::Property::SENSITIVE, false);
126 DALI_TEST_CHECK(false == light.GetProperty<bool>(Actor::Property::SENSITIVE));
128 Scene3D::Light moved = std::move(light);
129 DALI_TEST_CHECK(moved);
130 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
131 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
132 DALI_TEST_CHECK(!light);
137 int UtcDaliLightMoveAssignment(void)
139 ToolkitTestApplication application;
141 Scene3D::Light light = Scene3D::Light::New();
142 DALI_TEST_EQUALS(1, light.GetBaseObject().ReferenceCount(), TEST_LOCATION);
143 light.SetProperty(Actor::Property::SENSITIVE, false);
144 DALI_TEST_CHECK(false == light.GetProperty<bool>(Actor::Property::SENSITIVE));
146 Scene3D::Light moved;
147 moved = std::move(light);
148 DALI_TEST_CHECK(moved);
149 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
150 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
151 DALI_TEST_CHECK(!light);
157 int UtcDaliLightSize(void)
159 ToolkitTestApplication application;
161 Scene3D::Light light = Scene3D::Light::New();
162 application.GetScene().Add(light);
164 application.SendNotification();
165 application.Render();
167 light.SetProperty(Dali::Actor::Property::SIZE, Vector3::ONE);
168 DALI_TEST_EQUALS(Vector3::ONE, light.GetProperty<Vector3>(Dali::Actor::Property::SIZE), 0.01f, TEST_LOCATION);
169 DALI_TEST_EQUALS(Vector3::ZERO, light.GetNaturalSize(), 0.01f, TEST_LOCATION);
171 application.SendNotification();
172 application.Render();
174 light.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FIXED);
175 DALI_TEST_EQUALS(ResizePolicy::FIXED, light.GetProperty<ResizePolicy::Type>(Dali::Actor::Property::WIDTH_RESIZE_POLICY), TEST_LOCATION);
177 application.SendNotification();
178 application.Render();
180 float widthForHeight = light.GetWidthForHeight(light.GetProperty<float>(Dali::Actor::Property::SIZE_HEIGHT));
181 float heightForWidth = light.GetHeightForWidth(light.GetProperty<float>(Dali::Actor::Property::SIZE_WIDTH));
182 DALI_TEST_EQUALS(0.0f, widthForHeight, 0.01f, TEST_LOCATION);
183 DALI_TEST_EQUALS(0.0f, heightForWidth, 0.01f, TEST_LOCATION);
188 int UtcDaliLightOnScene01(void)
190 ToolkitTestApplication application;
192 Scene3D::Light light = Scene3D::Light::New();
193 application.GetScene().Add(light);
195 application.SendNotification();
196 application.Render();
198 // Light is added on layer when on scene
199 DALI_TEST_EQUALS(true, light.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
201 application.GetScene().Remove(light);
203 application.SendNotification();
204 application.Render();
206 // Light is removed from layer when on scene
207 DALI_TEST_EQUALS(false, light.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
212 // Add a light on SceneView directly
213 int UtcDaliLightAdd01(void)
215 ToolkitTestApplication application;
216 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
217 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
218 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
219 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
220 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
221 application.GetScene().Add(sceneView);
223 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
224 sceneView.Add(model);
226 application.SendNotification();
227 application.Render();
228 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
229 application.SendNotification();
230 application.Render();
232 Scene3D::Light light = Scene3D::Light::New();
233 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
234 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
235 sceneView.Add(light);
237 application.SendNotification();
238 application.Render();
240 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
241 DALI_TEST_CHECK(renderer);
242 Shader shader = renderer.GetShader();
243 DALI_TEST_CHECK(shader);
245 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
246 auto countPropertyIndex = shader.GetPropertyIndex("uLightCount");
247 DALI_TEST_CHECK(countPropertyIndex != Dali::Property::INVALID_INDEX);
248 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
249 auto colorPropertyIndex = shader.GetPropertyIndex("uLightColor[0]");
250 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), shader.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
251 auto directionPropertyIndex = shader.GetPropertyIndex("uLightDirection[0]");
252 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), shader.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
256 DALI_TEST_EQUALS(0u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
257 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
262 // Add a light on an Actor that is child of SceneView.
263 int UtcDaliLightAdd02(void)
265 ToolkitTestApplication application;
267 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
268 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
269 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
270 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
271 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
272 application.GetScene().Add(sceneView);
274 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
275 sceneView.Add(model);
277 application.SendNotification();
278 application.Render();
279 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
280 application.SendNotification();
281 application.Render();
283 Actor actor = Actor::New();
284 sceneView.Add(actor);
286 Scene3D::Light light = Scene3D::Light::New();
287 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
288 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
291 application.SendNotification();
292 application.Render();
294 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
295 DALI_TEST_CHECK(renderer);
296 Shader shader = renderer.GetShader();
297 DALI_TEST_CHECK(shader);
299 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
300 auto countPropertyIndex = shader.GetPropertyIndex("uLightCount");
301 DALI_TEST_CHECK(countPropertyIndex != DALI_KEY_INVALID);
302 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
303 auto colorPropertyIndex = shader.GetPropertyIndex("uLightColor[0]");
304 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), shader.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
305 auto directionPropertyIndex = shader.GetPropertyIndex("uLightDirection[0]");
306 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), shader.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
310 DALI_TEST_EQUALS(0u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
311 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
316 // Enable a light after it is added on SceneView.
317 int UtcDaliLightAdd03(void)
319 ToolkitTestApplication application;
321 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
322 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
323 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
324 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
325 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
326 application.GetScene().Add(sceneView);
328 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
329 sceneView.Add(model);
331 application.SendNotification();
332 application.Render();
333 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
334 application.SendNotification();
335 application.Render();
337 Scene3D::Light light = Scene3D::Light::New();
338 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
339 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
341 sceneView.Add(light);
343 application.SendNotification();
344 application.Render();
346 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
347 DALI_TEST_CHECK(renderer);
348 Shader shader = renderer.GetShader();
349 DALI_TEST_CHECK(shader);
351 DALI_TEST_EQUALS(0u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
352 auto countPropertyIndex = shader.GetPropertyIndex("uLightCount");
353 DALI_TEST_CHECK(countPropertyIndex != DALI_KEY_INVALID);
354 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
358 application.SendNotification();
359 application.Render();
361 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
362 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
363 auto colorPropertyIndex = shader.GetPropertyIndex("uLightColor[0]");
364 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), shader.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
365 auto directionPropertyIndex = shader.GetPropertyIndex("uLightDirection[0]");
366 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), shader.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
370 application.SendNotification();
371 application.Render();
373 DALI_TEST_EQUALS(0u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
374 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
379 int UtcDaliLightAdd04(void)
381 ToolkitTestApplication application;
383 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
384 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
385 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
386 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
387 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
388 application.GetScene().Add(sceneView);
390 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
391 sceneView.Add(model);
393 application.SendNotification();
394 application.Render();
395 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
396 application.SendNotification();
397 application.Render();
399 Scene3D::Light light1 = Scene3D::Light::New();
400 light1.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
401 Dali::DevelActor::LookAt(light1, Vector3(1.0f, 0.0f, 0.0f));
402 sceneView.Add(light1);
404 Scene3D::Light light2 = Scene3D::Light::New();
405 light2.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
406 Dali::DevelActor::LookAt(light2, Vector3(0.0f, 0.0f, -1.0f));
407 sceneView.Add(light2);
409 application.SendNotification();
410 application.Render();
412 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
413 DALI_TEST_CHECK(renderer);
414 Shader shader = renderer.GetShader();
415 DALI_TEST_CHECK(shader);
417 DALI_TEST_EQUALS(2u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
418 auto countPropertyIndex = shader.GetPropertyIndex("uLightCount");
419 DALI_TEST_CHECK(countPropertyIndex != DALI_KEY_INVALID);
420 DALI_TEST_EQUALS(2, shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
421 auto colorPropertyIndex1 = shader.GetPropertyIndex("uLightColor[0]");
422 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), shader.GetCurrentProperty<Vector3>(colorPropertyIndex1), 0.01f, TEST_LOCATION);
423 auto directionPropertyIndex1 = shader.GetPropertyIndex("uLightDirection[0]");
424 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), shader.GetCurrentProperty<Vector3>(directionPropertyIndex1), 0.01f, TEST_LOCATION);
425 auto colorPropertyIndex2 = shader.GetPropertyIndex("uLightColor[1]");
426 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), shader.GetCurrentProperty<Vector3>(colorPropertyIndex2), 0.01f, TEST_LOCATION);
427 auto directionPropertyIndex2 = shader.GetPropertyIndex("uLightDirection[1]");
428 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, -1.0f), shader.GetCurrentProperty<Vector3>(directionPropertyIndex2), 0.01f, TEST_LOCATION);
430 light1.Enable(false);
432 application.SendNotification();
433 application.Render();
435 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
436 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
438 // After light1 is disable, shader uniforms of lights are reordered.
439 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), shader.GetCurrentProperty<Vector3>(colorPropertyIndex1), 0.01f, TEST_LOCATION);
440 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, -1.0f), shader.GetCurrentProperty<Vector3>(directionPropertyIndex1), 0.01f, TEST_LOCATION);
445 // Check unactivated light in SceneView becomes activated when a light become disabled.
446 int UtcDaliLightAdd05(void)
448 ToolkitTestApplication application;
450 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
451 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
452 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
453 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
454 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
455 application.GetScene().Add(sceneView);
457 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
458 sceneView.Add(model);
460 application.SendNotification();
461 application.Render();
462 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
463 application.SendNotification();
464 application.Render();
466 uint32_t maxLightCount = Scene3D::Light::GetMaximumEnabledLightCount();
467 std::vector<Scene3D::Light> lightList;
468 for(uint32_t i = 0; i < maxLightCount; ++i)
470 Scene3D::Light light = Scene3D::Light::New();
471 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
472 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
473 sceneView.Add(light);
474 lightList.push_back(light);
477 Scene3D::Light light2 = Scene3D::Light::New();
478 light2.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
479 Dali::DevelActor::LookAt(light2, Vector3(0.0f, 0.0f, -1.0f));
480 sceneView.Add(light2);
481 lightList.push_back(light2);
483 application.SendNotification();
484 application.Render();
486 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
487 DALI_TEST_CHECK(renderer);
488 Shader shader = renderer.GetShader();
489 DALI_TEST_CHECK(shader);
491 DALI_TEST_EQUALS(maxLightCount, sceneView.GetActivatedLightCount(), TEST_LOCATION);
492 auto countPropertyIndex = shader.GetPropertyIndex("uLightCount");
493 DALI_TEST_CHECK(countPropertyIndex != DALI_KEY_INVALID);
494 DALI_TEST_EQUALS(static_cast<int32_t>(maxLightCount), shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
495 for(uint32_t i = 0; i < maxLightCount; ++i)
497 std::string colorStringKey = std::string("uLightColor[") + std::to_string(i) + "]";
498 auto colorPropertyIndex = shader.GetPropertyIndex(colorStringKey);
499 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), shader.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
501 std::string directionStringKey = std::string("uLightDirection[") + std::to_string(i) + "]";
502 auto directionPropertyIndex = shader.GetPropertyIndex(directionStringKey);
503 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), shader.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
506 lightList[2].Enable(false);
508 application.SendNotification();
509 application.Render();
511 DALI_TEST_EQUALS(maxLightCount, sceneView.GetActivatedLightCount(), TEST_LOCATION);
512 DALI_TEST_EQUALS(static_cast<int32_t>(maxLightCount), shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
513 for(uint32_t i = 0; i < maxLightCount; ++i)
515 tet_printf("i : %d\n", i);
516 Vector3 color, direction;
517 if(i == maxLightCount - 1)
519 color = Vector3(1.0f, 0.0f, 0.0f);
520 direction = Vector3(0.0f, 0.0f, -1.0f);
524 color = Vector3(0.0f, 0.0f, 1.0f);
525 direction = Vector3(1.0f, 0.0f, 0.0f);
527 std::string colorStringKey = std::string("uLightColor[") + std::to_string(i) + "]";
528 auto colorPropertyIndex = shader.GetPropertyIndex(colorStringKey);
529 DALI_TEST_EQUALS(color, shader.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
531 std::string directionStringKey = std::string("uLightDirection[") + std::to_string(i) + "]";
532 auto directionPropertyIndex = shader.GetPropertyIndex(directionStringKey);
533 DALI_TEST_EQUALS(direction, shader.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
536 for(uint32_t i = 0; i < lightList.size(); ++i)
540 DALI_TEST_EQUALS(false, lightList[i].IsEnabled(), TEST_LOCATION);
544 DALI_TEST_EQUALS(true, lightList[i].IsEnabled(), TEST_LOCATION);
551 int UtcDaliLightModelAddAndRemove(void)
553 ToolkitTestApplication application;
555 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
556 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
557 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
558 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
559 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
560 application.GetScene().Add(sceneView);
562 Scene3D::Light light = Scene3D::Light::New();
563 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
564 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
565 sceneView.Add(light);
567 application.SendNotification();
568 application.Render();
570 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
571 sceneView.Add(model);
573 application.SendNotification();
574 application.Render();
575 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
576 application.SendNotification();
577 application.Render();
579 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
580 DALI_TEST_CHECK(renderer);
581 Shader shader = renderer.GetShader();
582 DALI_TEST_CHECK(shader);
584 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
585 auto countPropertyIndex = shader.GetPropertyIndex("uLightCount");
586 DALI_TEST_CHECK(countPropertyIndex != DALI_KEY_INVALID);
587 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
589 auto colorPropertyIndex = shader.GetPropertyIndex("uLightColor[0]");
590 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), shader.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
591 auto directionPropertyIndex = shader.GetPropertyIndex("uLightDirection[0]");
592 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), shader.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
594 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
598 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
603 // Enable Shadow and add the light to SceneView.
604 int UtcDaliLightEnableShadowOnScene01(void)
606 ToolkitTestApplication application;
608 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
609 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
610 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
611 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
612 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
613 application.GetScene().Add(sceneView);
615 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
616 sceneView.Add(model);
618 application.SendNotification();
619 application.Render();
620 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
621 application.SendNotification();
622 application.Render();
624 // Light is added on layer when on scene
625 DALI_TEST_EQUALS(true, model.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
627 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
628 DALI_TEST_CHECK(renderer);
629 Shader shader = renderer.GetShader();
630 DALI_TEST_CHECK(shader);
632 auto shadowEnabledIndex = shader.GetPropertyIndex("uIsShadowEnabled");
633 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
634 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
636 Scene3D::Light light = Scene3D::Light::New();
637 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
638 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
639 light.EnableShadow(true);
641 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
642 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
644 sceneView.Add(light);
646 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
647 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
652 // Add the light to SceneView and Enable Shadow.
653 int UtcDaliLightEnableShadowOnScene02(void)
655 ToolkitTestApplication application;
657 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
658 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
659 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
660 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
661 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
662 application.GetScene().Add(sceneView);
664 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
665 sceneView.Add(model);
667 application.SendNotification();
668 application.Render();
669 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
670 application.SendNotification();
671 application.Render();
673 // Light is added on layer when on scene
674 DALI_TEST_EQUALS(true, model.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
676 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
677 DALI_TEST_CHECK(renderer);
678 Shader shader = renderer.GetShader();
679 DALI_TEST_CHECK(shader);
681 auto shadowEnabledIndex = shader.GetPropertyIndex("uIsShadowEnabled");
682 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
683 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
685 Scene3D::Light light = Scene3D::Light::New();
686 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
687 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
688 sceneView.Add(light);
690 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
691 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
693 light.EnableShadow(true);
695 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
696 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
698 light.EnableShadow(true);
700 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
701 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
706 // Add the light to SceneView and Add Model.
707 int UtcDaliLightEnableShadowOnScene03(void)
709 ToolkitTestApplication application;
711 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
712 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
713 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
714 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
715 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
716 application.GetScene().Add(sceneView);
718 Scene3D::Light light = Scene3D::Light::New();
719 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
720 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
721 light.EnableShadow(true);
722 sceneView.Add(light);
724 application.SendNotification();
725 application.Render();
727 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
728 sceneView.Add(model);
730 application.SendNotification();
731 application.Render();
732 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
733 application.SendNotification();
734 application.Render();
736 // Light is added on layer when on scene
737 DALI_TEST_EQUALS(true, model.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
739 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
740 DALI_TEST_CHECK(renderer);
741 Shader shader = renderer.GetShader();
742 DALI_TEST_CHECK(shader);
744 auto shadowEnabledIndex = shader.GetPropertyIndex("uIsShadowEnabled");
745 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
746 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
752 int UtcDaliLightDisableShadow01(void)
754 ToolkitTestApplication application;
756 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
757 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
758 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
759 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
760 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
761 application.GetScene().Add(sceneView);
763 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
764 sceneView.Add(model);
766 Scene3D::Light light = Scene3D::Light::New();
767 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
768 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
769 light.EnableShadow(true);
770 sceneView.Add(light);
772 application.SendNotification();
773 application.Render();
774 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
775 application.SendNotification();
776 application.Render();
778 // Light is added on layer when on scene
779 DALI_TEST_EQUALS(true, model.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
781 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
782 DALI_TEST_CHECK(renderer);
783 Shader shader = renderer.GetShader();
784 DALI_TEST_CHECK(shader);
786 auto shadowEnabledIndex = shader.GetPropertyIndex("uIsShadowEnabled");
787 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
788 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
790 light.EnableShadow(false);
792 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
793 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
795 light.EnableShadow(true);
797 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
798 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
802 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
803 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
809 int UtcDaliLightDisableShadow02(void)
811 ToolkitTestApplication application;
813 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
814 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
815 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
816 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
817 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
818 application.GetScene().Add(sceneView);
820 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
821 sceneView.Add(model);
823 Scene3D::Light light = Scene3D::Light::New();
824 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
825 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
826 light.EnableShadow(true);
827 sceneView.Add(light);
829 application.SendNotification();
830 application.Render();
831 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
832 application.SendNotification();
833 application.Render();
835 // Light is added on layer when on scene
836 DALI_TEST_EQUALS(true, model.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
838 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
839 DALI_TEST_CHECK(renderer);
840 Shader shader = renderer.GetShader();
841 DALI_TEST_CHECK(shader);
843 auto shadowEnabledIndex = shader.GetPropertyIndex("uIsShadowEnabled");
844 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
845 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
847 light.EnableShadow(false);
849 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
850 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
852 light.EnableShadow(true);
854 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
855 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
857 Scene3D::Light newLight = Scene3D::Light::New();
858 newLight.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
859 Dali::DevelActor::LookAt(newLight, Vector3(1.0f, 0.0f, 0.0f));
860 newLight.EnableShadow(true);
861 sceneView.Add(newLight);
863 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
864 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
866 // Disable light's shadow, the shadow of newLight is rendered
867 light.EnableShadow(false);
869 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
870 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
872 // Enable light's shadow, but newLight's shadow is rendered.
873 light.EnableShadow(true);
875 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
876 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
878 // Disable newLight's shadow, light's shadow is rendered.
881 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
882 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
884 // Every shadow is disabled.
887 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
888 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
893 // Make a light EnableShadow that is not enabled on scene
894 int UtcDaliLightEnableShadowOfNotEnabledLight(void)
896 ToolkitTestApplication application;
898 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
899 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
900 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
901 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
902 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
903 application.GetScene().Add(sceneView);
905 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
906 sceneView.Add(model);
908 uint32_t maxLightCount = Scene3D::Light::GetMaximumEnabledLightCount();
909 std::vector<Scene3D::Light> lights;
910 for(uint32_t i = 0; i < maxLightCount; ++i)
912 Scene3D::Light light = Scene3D::Light::New();
913 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
914 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
915 sceneView.Add(light);
916 lights.push_back(light);
919 Scene3D::Light shadowLight = Scene3D::Light::New();
920 shadowLight.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
921 Dali::DevelActor::LookAt(shadowLight, Vector3(1.0f, 0.0f, 0.0f));
922 sceneView.Add(shadowLight);
924 application.SendNotification();
925 application.Render();
926 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
927 application.SendNotification();
928 application.Render();
930 // Light is added on layer when on scene
931 DALI_TEST_EQUALS(true, model.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
933 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
934 DALI_TEST_CHECK(renderer);
935 Shader shader = renderer.GetShader();
936 DALI_TEST_CHECK(shader);
938 auto shadowEnabledIndex = shader.GetPropertyIndex("uIsShadowEnabled");
939 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
940 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
942 shadowLight.EnableShadow(true);
944 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
945 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
947 lights[0].Enable(false);
949 DALI_TEST_CHECK(shadowEnabledIndex != DALI_KEY_INVALID);
950 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowEnabledIndex), TEST_LOCATION);
955 // Set/Get Shadow Properties
956 int UtcDaliLightSetGetProperty(void)
958 ToolkitTestApplication application;
960 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
961 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
962 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
963 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
964 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
965 application.GetScene().Add(sceneView);
967 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
968 sceneView.Add(model);
970 Scene3D::Light light = Scene3D::Light::New();
971 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
972 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
973 light.EnableShadow(true);
974 sceneView.Add(light);
976 application.SendNotification();
977 application.Render();
978 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
979 application.SendNotification();
980 application.Render();
982 // Light is added on layer when on scene
983 DALI_TEST_EQUALS(true, model.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
985 DALI_TEST_EQUALS(0.001f, light.GetShadowBias(), TEST_LOCATION);
986 light.SetShadowBias(0.1f);
987 DALI_TEST_EQUALS(0.1f, light.GetShadowBias(), TEST_LOCATION);
989 DALI_TEST_EQUALS(0.5f, light.GetShadowIntensity(), TEST_LOCATION);
990 light.SetShadowIntensity(0.1f);
991 DALI_TEST_EQUALS(0.1f, light.GetShadowIntensity(), TEST_LOCATION);
996 // Enable PCF for soft shadow edge.
997 int UtcDaliLightShadowSoftFiltering(void)
999 ToolkitTestApplication application;
1001 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
1002 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1003 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1004 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
1005 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
1006 application.GetScene().Add(sceneView);
1008 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1009 sceneView.Add(model);
1011 Scene3D::Light light = Scene3D::Light::New();
1012 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
1013 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
1014 light.EnableShadow(true);
1015 sceneView.Add(light);
1017 application.SendNotification();
1018 application.Render();
1019 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1020 application.SendNotification();
1021 application.Render();
1023 // Light is added on layer when on scene
1024 DALI_TEST_EQUALS(true, model.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
1026 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
1027 DALI_TEST_CHECK(renderer);
1028 Shader shader = renderer.GetShader();
1029 DALI_TEST_CHECK(shader);
1031 DALI_TEST_EQUALS(false, light.IsShadowSoftFilteringEnabled(), TEST_LOCATION);
1032 auto shadowFilteringEnabledIndex = shader.GetPropertyIndex("uEnableShadowSoftFiltering");
1033 DALI_TEST_CHECK(shadowFilteringEnabledIndex != DALI_KEY_INVALID);
1034 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowFilteringEnabledIndex), TEST_LOCATION);
1036 light.EnableShadowSoftFiltering(true);
1037 DALI_TEST_EQUALS(true, light.IsShadowSoftFilteringEnabled(), TEST_LOCATION);
1039 DALI_TEST_CHECK(shadowFilteringEnabledIndex != DALI_KEY_INVALID);
1040 DALI_TEST_EQUALS(1, shader.GetProperty<int32_t>(shadowFilteringEnabledIndex), TEST_LOCATION);
1042 light.EnableShadowSoftFiltering(false);
1043 DALI_TEST_EQUALS(false, light.IsShadowSoftFilteringEnabled(), TEST_LOCATION);
1044 DALI_TEST_CHECK(shadowFilteringEnabledIndex != DALI_KEY_INVALID);
1045 DALI_TEST_EQUALS(0, shader.GetProperty<int32_t>(shadowFilteringEnabledIndex), TEST_LOCATION);