このページでは、Stingray エディタで、あるいはゲームのランタイムで直接、シェーディング環境のプロパティを変更するオプションについて説明します。
Explorer パネルでシェーディング環境のエンティティを選択し、Property Editor でプロパティを変更します。変更はエディタ内で即座に適用され、レベルを保存するときに保存されます。
Story Editor を使用して、レベルのシェーディング環境のプロパティをアニメートするストーリーを作成できます。さまざまなシナリオやエフェクトをシミュレートするために(時間の変更、位置の変更など)、時間の経過とともにさまざまなプロパティにキーを設定できます。フローまたは Lua ゲームプレイ コードでトリガしてランタイムでストーリーを再生するときに、シェーディング環境がそれ相応に調整されたことを確認できます。
「Story Editor を使用してシェーディング環境をアニメートする」を参照してください。
注: これらのオプションを調整しても、Asset Preview ウィンドウのレンダリングは変更されません。
レベルのシェーディング環境のエンティティを取得して、ランタイムの Lua コードでプロパティを変更することができます。たとえば、次のコードは、露出プロパティに新しい値を設定する方法を示します。
local data_component_manager = stingray.EntityManager.render_data_component(SimpleProject.world) local all_entity_handles = stingray.World.entities(SimpleProject.world) -- iterate through all entities in the world. for _, entity_handle in ipairs(all_entity_handles) do -- the shading environment is a render data component, so we retrieve all render data components -- owned by this entity and iterate through them. -- instances() returns the values on the stack, so we wrap the call in {} to get an array. local all_data_component_handles = {stingray.RenderDataComponent.instances(data_component_manager, entity_handle)} for _, data_component_handle in ipairs(all_data_component_handles) do -- Test whether or not this data component is the shading environment component -- that we want to modify. -- Missing properties return nil, so this is "safe". local shading_environment_mapping_resource_name = stingray.RenderDataComponent.get_property(data_component_manager, data_component_handle, {"shading_environment_mapping"}) if shading_environment_mapping_resource_name == "core/stingray_renderer/shading_environment_components/exposure" then if (shading_env_entity == nil) then -- remember the shading environment entity. shading_env_entity = entity_handle end exposure_component = data_component_handle; -- now we have the shading environment entity and the component, we can set the -- value we want for the property. stingray.RenderDataComponent.set_property(data_component_manager, exposure_component, {"exposure"}, exposure_val) end end end
さまざまなプロパティへのアクセスに使用する名前は、リソース マッピング ファイルで決定されます。これは、core リソース フォルダ内の core/stingray_renderer/shading_environment_components にあります。シェーディング環境のコンポーネントに対応するマッピング ファイルを開いて、設定するプロパティに対応するキーの名前を探します。