您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

天空反射Sky reflections

在 Azure 远程渲染中,天空纹理用于真实地照亮物体。In Azure Remote Rendering, a sky texture is used to light objects realistically. 在增强现实应用程序中,此纹理应类似于真实的周边环境,使物体显得更生动。For augmented reality applications, this texture should resemble your real-world surroundings, to make objects appear convincing. 本文介绍了如何更改天空纹理。This article describes how to change the sky texture.

备注

天空纹理也称为环境地图。The sky texture is also referred to as an environment map. 这两个术语可以互换使用。These terms are used interchangeably.

物体照明Object lighting

Azure 远程渲染运用基于物理学的渲染 (PBR) 来计算现实照明。Azure Remote Rendering employs physically based rendering (PBR) for realistic lighting computations. 尽管你可以向场景中添加光源,但使用合适的天空纹理可以产生最棒的效果。Although you can add light sources to your scene, using a good sky texture has the greatest impact.

下面的图像显示了仅使用天空纹理来照亮各种表面的效果:The images below show results of lighting different surfaces only with a sky texture:

粗糙度Roughness 00 0.250.25 0.50.5 0.750.75 11
非金属Non-Metal Dielectric,粗糙度 = 0 Dielectric,粗糙度 = 0.25 Dielectric,粗糙度 = 0。5 Dielectric,粗糙度 = 0.75 Dielectric,粗糙度 = 1
金属Metal 金属,粗糙度 = 0 金属,粗糙度 = 0.25 金属,粗糙度 = 0。5 金属,粗糙度 = 0.75 金属,粗糙度 = 1

有关照明模型的详细信息,请参阅材料一章。For more information on the lighting model, see the materials chapter.

重要

Azure 远程渲染仅将天空纹理用于照明模型。Azure Remote Rendering uses the sky texture only for lighting models. 它不会将天空渲染为背景,因为增强现实应用程序已有适当的背景 - 真实世界。It does not render the sky as a background, since Augmented Reality applications already have a proper background - the real world.

更改天空纹理Changing the sky texture

若要更改环境地图,只需加载纹理并更改会话的 SkyReflectionSettingsTo change the environment map, all you need to do is load a texture and change the session's SkyReflectionSettings:

LoadTextureAsync _skyTextureLoad = null;
void ChangeEnvironmentMap(AzureSession session)
{
    _skyTextureLoad = session.Actions.LoadTextureFromSASAsync(new LoadTextureFromSASParams("builtin://VeniceSunset", TextureType.CubeMap));

    _skyTextureLoad.Completed += (LoadTextureAsync res) =>
        {
            if (res.IsRanToCompletion)
            {
                try
                {
                    session.Actions.SkyReflectionSettings.SkyReflectionTexture = res.Result;
                }
                catch (RRException exception)
                {
                    System.Console.WriteLine($"Setting sky reflection failed: {exception.Message}");
                }
            }
            else
            {
                System.Console.WriteLine("Texture loading failed!");
            }
        };
}
void ChangeEnvironmentMap(ApiHandle<AzureSession> session)
{
    LoadTextureFromSASParams params;
    params.TextureType = TextureType::CubeMap;
    params.TextureUrl = "builtin://VeniceSunset";
    ApiHandle<LoadTextureAsync> skyTextureLoad = *session->Actions()->LoadTextureFromSASAsync(params);

    skyTextureLoad->Completed([&](ApiHandle<LoadTextureAsync> res)
        {
            if (res->GetIsRanToCompletion())
            {
                ApiHandle<SkyReflectionSettings> settings = session->Actions()->GetSkyReflectionSettings();
                settings->SetSkyReflectionTexture(res->GetResult());
            }
            else
            {
                printf("Texture loading failed!\n");
            }
        });
}

请注意,上面使用了 LoadTextureFromSASAsync 变体,因为加载了内置纹理。Note that the LoadTextureFromSASAsync variant is used above because a built-in texture is loaded. 如果纹理是从关联的 Blob 存储加载的,请使用 LoadTextureAsync 变体。In case of loading from linked blob storages, use the LoadTextureAsync variant.

天空纹理类型Sky texture types

可以使用立体地图2D 纹理作为环境地图。You can use both cubemaps and 2D textures as environment maps.

所有纹理都必须采用支持的纹理格式All textures have to be in a supported texture format. 不需要为天空纹理提供 mipmap。You don't need to provide mipmaps for sky textures.

立体环境地图Cube environment maps

下面提供了一个已解包的立体地图供参考:For reference, here is an unwrapped cubemap:

已解包的立体地图

AzureSession.Actions.LoadTextureAsync/ LoadTextureFromSASAsyncTextureType.CubeMap 一起使用来加载立体地图纹理。Use AzureSession.Actions.LoadTextureAsync/ LoadTextureFromSASAsync with TextureType.CubeMap to load cubemap textures.

球体环境地图Sphere environment maps

使用 2D 纹理作为环境地图时,图像必须处于球面坐标空间中。When using a 2D texture as an environment map, the image has to be in spherical coordinate space.

球面坐标中的天空图像

结合使用 TextureType.Texture2DAzureSession.Actions.LoadTextureAsync 加载球体环境地图。Use AzureSession.Actions.LoadTextureAsync with TextureType.Texture2D to load spherical environment maps.

内置环境地图Built-in environment maps

Azure 远程渲染提供了几个始终可用的内置环境地图。Azure Remote Rendering provides a few built-in environment maps that are always available. 所有内置环境地图都是立体地图。All built-in environment maps are cubemaps.

标识符Identifier 说明Description 图示Illustration
builtin://Autoshopbuiltin://Autoshop 各种条带光线,明亮的室内基本照明Variety of stripe lights, bright indoor base lighting 用于浅对象的 Autoshop skybox
builtin://BoilerRoombuiltin://BoilerRoom 明亮的室内光线设置,多窗口光线Bright indoor light setting, multiple window lights 用于浅对象的 BoilerRoom skybox
builtin://ColorfulStudiobuiltin://ColorfulStudio 中等亮度室内照明设置中的各种彩色光线Varyingly colored lights in medium light indoor setting 用于浅对象的 ColorfulStudio skybox
builtin://Hangarbuiltin://Hangar 适中亮度的大厅环境光线Moderately bright ambient hall light 用于浅对象的 SmallHangar skybox
builtin://IndustrialPipeAndValvebuiltin://IndustrialPipeAndValve 昏暗室内设置和明暗对比度Dim indoor setting with light-dark contrast 用于浅对象的 IndustrialPipeAndValve skybox
builtin://Lebombobuiltin://Lebombo 白天的室内环境光线,明亮的窗口区域光线Daytime ambient room light, bright window area light 用于浅对象的 Lebombo skybox
builtin://SataraNightbuiltin://SataraNight 夜晚昏暗的天空和地面以及许多周边光线Dark night sky and ground with many surrounding lights 用于浅对象的 SataraNight skybox
builtin://SunnyVondelparkbuiltin://SunnyVondelpark 明亮的日光和阴影对比度Bright sunlight and shadow contrast 用于浅对象的 SunnyVondelpark skybox
builtin://Syferfonteinbuiltin://Syferfontein 晴朗天空光线和适中的地面照明Clear sky light with moderate ground lighting 用于浅对象的 Syferfontein skybox
builtin://TearsOfSteelBridgebuiltin://TearsOfSteelBridge 适度变化的日光和阴影Moderately varying sun and shade 用于浅对象的 TearsOfSteelBridge skybox
builtin://VeniceSunsetbuiltin://VeniceSunset 傍晚接近黄昏时的日落光线Evening sunset light approaching dusk 用于浅对象的 VeniceSunset skybox
builtin://WhippleCreekRegionalParkbuiltin://WhippleCreekRegionalPark 明亮、嫩绿和白色光线色调,昏暗的地面Bright, lush-green, and white light tones, dimmed ground 用于浅对象的 WhippleCreekRegionalPark skybox
builtin://WinterRiverbuiltin://WinterRiver 白天的明亮地面环境光线Daytime with bright ambient ground light 用于浅对象的 WinterRiver skybox
builtin://DefaultSkybuiltin://DefaultSky 与 TearsOfSteelBridge 相同Same as TearsOfSteelBridge 用于浅对象的 DefaultSky skybox

API 文档API documentation

后续步骤Next steps