private void Update() { WPOutlineSetting setting = GetCurrentSetting(); if (setting.cullingMask == 0 || setting.outlineIntensity <= 0.0001f) { ClearOutline(); return; } UpdateDepthNormalMap(setting); UpdateOutlineRender(setting); }
private void UpdateOutlineRender(WPOutlineSetting setting) { depthNormal.aspect = m_mainCamera.aspect; depthNormal.fieldOfView = m_mainCamera.fieldOfView; depthNormal.orthographic = m_mainCamera.orthographic; depthNormal.orthographicSize = m_mainCamera.orthographicSize; depthNormal.nearClipPlane = m_mainCamera.nearClipPlane; depthNormal.farClipPlane = m_mainCamera.farClipPlane; depthNormal.cullingMask = setting.cullingMask & m_mainCamera.cullingMask; Shader.SetGlobalVector(ID_WP_OutlineParams, new Vector4(setting.outlineIntensity, (int)setting.antiAliasing, outlinePower, setting.antiAliasingSize)); Shader.SetGlobalColor(ID_WP_OutlineColor, outlineColor); depthNormal.RenderWithShader(depthNormalMapShader, "RenderType"); }
private void UpdateDepthNormalMap(WPOutlineSetting setting) { int size = setting.resolution == 3 ? 1024 : (setting.resolution == 2 ? 512 : 256); if (size == m_depthNormalMapSize) { return; } if (m_depthNormalMap) { RenderTexture.ReleaseTemporary(m_depthNormalMap); } m_depthNormalMapSize = size; m_depthNormalMap = RenderTexture.GetTemporary(size, size, 0, RenderTextureFormat.Default); m_depthNormalMap.filterMode = FilterMode.Point; depthNormal.targetTexture = m_depthNormalMap; Shader.SetGlobalTexture(ID_WP_DepthNormalMap, m_depthNormalMap); }