## Copyright (c) 2021, NVIDIA CORPORATION.  All rights reserved.
##
## NVIDIA CORPORATION and its licensors retain all intellectual property
## and proprietary rights in and to this software, related documentation
## and any modifications thereto.  Any use, reproduction, disclosure or
## distribution of this software and related documentation without an express
## license agreement from NVIDIA CORPORATION is strictly prohibited.
##
from sys import path
import omni.kit.app
import omni.kit.commands
import omni.kit.undo
import omni.kit.test
import omni.timeline
import carb.settings
from .test_hydra_common import RtxHydraTest
from .test_common import testSettings, postLoadTestSettings, wait_for_update
from pxr import Gf, UsdShade
import shutil, os, pathlib


class TestRtxHydraSceneDelegateOmniImagingSetEmissionColor(RtxHydraTest):
    # OM-73180
    # Prior to the update in this ticket the OmniImagingDelegate ignored
    # certain parameters, "emission_color" being one of them.  This test 
    # validates that is no longer the case.
    
    async def setUp(self):
        await super().setUp()
        self.set_settings(testSettings)
        super().open_usd("hydra/scene_delegate/emission_color/test.usda")
        await omni.kit.app.get_app().next_update_async()
        self.set_settings(postLoadTestSettings)

    async def test_set_emission_color(self):
        ''' 
        Test OmniImagingDelegate don't ignore 'emission_color'
        '''
        await wait_for_update(wait_frames=10)
        
        prim = self.ctx.get_stage().GetPrimAtPath("/World/Looks/mtl_emission/emission")
        shader_prim = UsdShade.Shader(prim)
        shader_prim.GetInput("emission_color").Set(Gf.Vec3f(1.0, 0.0, 0.0))
        await wait_for_update(wait_frames=10)        
        await self.capture_and_compare("hydra/scene_delegate", "set_emission_color.png")