void Update() { #if UNITY_EDITOR Shader.SetGlobalFloat("_GlobalLightEstimation", 1.0f); #else ARLightEstimate light = ARFrame.GetLightEstimate(); if (!light.Valid) { return; } const float middleGray = 0.466f; float normalizedIntensity = light.PixelIntensity / middleGray; Shader.SetGlobalFloat("_GlobalLightEstimation", normalizedIntensity); #endif }
/** * \if english * @brief Inherit from Unity Update(). * \else * @brief Unity的Update()。 * \endif */ public void Update() { if (BackGroundMaterial == null) { return; } else if (!ARFrame.TextureIsAvailable()) { return; } const string backroundTex = "_MainTex"; const string leftTopBottom = "_UvLeftTopBottom"; const string rightTopBottom = "_UvRightTopBottom"; BackGroundMaterial.SetTexture(backroundTex, ARFrame.CameraTexture); if (ARFrame.IsDisplayGeometryChanged()) { transformedUVCoords = ARFrame.GetTransformDisplayUvCoords(QUAD_TEXCOORDS); } BackGroundMaterial.SetVector(leftTopBottom, new Vector4(transformedUVCoords[0], transformedUVCoords[1], transformedUVCoords[2], transformedUVCoords[3])); BackGroundMaterial.SetVector(rightTopBottom, new Vector4(transformedUVCoords[4], transformedUVCoords[5], transformedUVCoords[6], transformedUVCoords[7])); Pose p = ARFrame.GetPose(); m_camera.transform.position = p.position; m_camera.transform.rotation = p.rotation; m_camera.projectionMatrix = ARSession.GetProjectionMatrix(m_camera.nearClipPlane, m_camera.farClipPlane); if (m_backgroundRenderer == null) { m_backgroundRenderer = new ARBackgroundRenderer(); m_backgroundRenderer.backgroundMaterial = BackGroundMaterial; m_backgroundRenderer.camera = m_camera; m_backgroundRenderer.mode = ARRenderMode.MaterialAsBackground; } }
public static List <ARPlane> GetAllPlanes() { return(ARFrame.GetPlanes(ARTrackableQueryFilter.ALL));; }
public static List <ARAnchor> GetAllAnchors() { return(ARFrame.GetAnchors(ARTrackableQueryFilter.ALL)); }