【问题标题】:Cubemap skybox from the scene of the shader着色器场景中的立方体贴图天空盒
【发布时间】:2019-10-12 12:44:30
【问题描述】:

问题可能很简单: 我不知道如何获取天空盒并将其应用到我的着色器。

我想我已经很接近了,但是如何从场景中取出天空盒??

mygameobjec.GetComponent<Renderer>().material.SetTexture("_SkyReflection",Skybox.material.Texture??);

谢谢

【问题讨论】:

    标签: c# unity3d shader textures skybox


    【解决方案1】:

    试试 RenderSettings.skybox.mainTexture。

    https://docs.unity3d.com/ScriptReference/RenderSettings-skybox.html

    提示:也可以从名为 unity_SpecCube0 的着色器全局访问着色器内的当前反射环境。这是我经常在我的着色器中使用的一个函数:

    // Returns the reflection color given a normal and view direction.
    inline half3 SurfaceReflection(half3 viewDir, half3 worldNormal, half roughness) {
    
        half3 worldRefl = reflect(-viewDir, worldNormal);
        half r = roughness * 1.7 - 0.7 * roughness;
        float4 reflData = UNITY_SAMPLE_TEXCUBE_LOD(
            unity_SpecCube0, worldRefl, r * 6
        );
    
        return DecodeHDR (reflData, unity_SpecCube0_HDR);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-15
      • 1970-01-01
      • 2018-11-24
      • 1970-01-01
      • 1970-01-01
      • 2012-11-18
      • 1970-01-01
      相关资源
      最近更新 更多