zoukankan      html  css  js  c++  java
  • Vuforia结合Skyshop: Image-Based Lighting Tools & Shaders插件实现真实的光照效果

      Skyshop: Image-Based Lighting Tools & Shaders 插件地址:https://www.assetstore.unity3d.com/en/#!/content/8880

    相关使用教程:http://www.narkii.com/club/thread-300367-1.html

                        http://blog.sina.com.cn/s/blog_6364792d0102uys6.html

    这些基本上都是使用了HDRI 高动态范围图像 作为场景中的天空实现天空的光线照明,而在AR中,如Vuforia等是实时拍摄现实中的场景的,所有要动态更改天空的光照效果。

    首先导入Skyshop的插件,然后在场景中创建带有Sky和SkyManager脚本空物体或直接右键创建。

    把场景中的灯光都删除掉。

    调节Sky脚本中的相关属性。

    把模型的Shader设置为Marmoset下的Shader,譬如Bumped Specular IBL

    在场景中绑定一个脚本,实时更新Sky的SkyboxCube属性和SpecularCube属性。

    using UnityEngine;
    using System.Collections;
    using mset;
    
    public class SkyTest : MonoBehaviour {
    
        public Cubemap testCubmap;
    
        // Use this for initialization
        private Cubemap cubmap;
        private Camera textureCamera;
        private GameObject textureCameraObj;
        private Sky sky;
        void Start () {
            sky=GameObject.Find("Sky").GetComponent<Sky>();
            cubmap = new Cubemap(512, TextureFormat.ARGB32, false);
        }
        
        // Update is called once per frame
        void Update()
        {
            if (textureCameraObj == null)
            {
                textureCameraObj = GameObject.Find("TextureBufferCamera");
            }        
            if (textureCameraObj!= null)
            {
                textureCamera = textureCameraObj.GetComponent<Camera>();
            }
            if (textureCamera != null)
            {
                textureCamera.RenderToCubemap(cubmap);
                sky.SkyboxCube = cubmap;
                sky.SpecularCube = cubmap;
    
    
                //textureCamera.RenderToCubemap(testCubmap);
                //sky.SkyboxCube = testCubmap;
            }
        }
    }

    Cubmap可以自己New一个也可以使用属性面板中传过来的Cubmap。

    最后通过摄像头识别图片进行相关属性和Shader的调节来打到你想要的效果。

  • 相关阅读:
    指针的学习
    (转)c & c++内存分配
    C++实现String
    c& c++笔试题
    appium python api收集
    公司python入职培训流程
    app端性能测试笔记
    h5 测试关注点
    robot framework 牛刀一试
    adb 安装apk 报错:Failure [INSTALL_FAILED_INVALID_URI]
  • 原文地址:https://www.cnblogs.com/townsend/p/4238506.html
Copyright © 2011-2022 走看看