void SetCameraFlag() { if (mode == oldMode) { return; } if (oldMode == EdgeDetectMode.SobelDepth || oldMode == EdgeDetectMode.SobelDepthThin) { ImageEffectManager.API_DeAttachCameraRenderFlags(m_Camera, ref flagReference); } else if (oldMode == EdgeDetectMode.TriangleDepthNormals || oldMode == EdgeDetectMode.RobertsCrossDepthNormals) { ImageEffectManager.API_DeAttachCameraRenderFlags(m_Camera, ref flagReference); } if (mode == EdgeDetectMode.SobelDepth || mode == EdgeDetectMode.SobelDepthThin) { flagReference = ImageEffectManager.API_AttachCameraRenderFlags(m_Camera, DepthTextureMode.Depth); } else if (mode == EdgeDetectMode.TriangleDepthNormals || mode == EdgeDetectMode.RobertsCrossDepthNormals) { flagReference = ImageEffectManager.API_AttachCameraRenderFlags(m_Camera, DepthTextureMode.DepthNormals); } oldMode = mode; }
public override bool CheckResources() { CheckSupport(false, true); Shader tonemapper = null; if (!tonemapper) { tonemapper = ImageEffectManager.API_GetShader("Hidden/Tonemapper"); } tonemapMaterial = CheckShaderAndCreateMaterial(tonemapper, tonemapMaterial); if (!curveTex && type == TonemapperType.UserCurve) { curveTex = new Texture2D(256, 1, TextureFormat.ARGB32, false, true); curveTex.filterMode = FilterMode.Bilinear; curveTex.wrapMode = TextureWrapMode.Clamp; curveTex.hideFlags = HideFlags.DontSave; curveTex.name = "curveTex"; } if (!isSupported) { ReportAutoDisable(); } return(isSupported); }
public override void Awake() { InstanceList.Add(this); DissloveObj = new GameObject(); DissloveObj.name = "DissloveGlowCamera"; DissloveObj.hideFlags = HideFlags.HideAndDontSave; DissloveCam = DissloveObj.AddComponent <Camera>(); DissloveCam.cullingMask = (1 << LayerMask.NameToLayer("LightingEffectOnly")); DissloveCam.enabled = false; if (settings == null) { settings = new GlowSettings(); } settings.baseResolution = Resolution.Half; settings.boostStrength = 3; settings.downsampleSteps = 1; HostCamera = GetComponent <Camera>(); highPrecision = _highPrecsion; if (Application.isPlaying) { Shader shader = ImageEffectManager.API_GetShader("ImageEffect/DissloveGlowMask"); if (mat) { Destroy(mat); mat = null; } mat = new Material(shader); } base.Awake(); InitRender(); InitCamera(); }
public override bool CheckResources() { CheckSupport(true); if (null == sunShaftsShader) { sunShaftsShader = ImageEffectManager.API_GetShader("ImageEffect/SunShaft/SunShaftsComposite"); } if (null == simpleClearShader) { simpleClearShader = ImageEffectManager.API_GetShader("ImageEffect/Common/SimpleClear"); } sunShaftsMaterial = CheckShaderAndCreateMaterial(sunShaftsShader, sunShaftsMaterial); simpleClearMaterial = CheckShaderAndCreateMaterial(simpleClearShader, simpleClearMaterial); if (!isSupported) { ReportAutoDisable(); } canUseMask = false; var skybox = RenderSettings.skybox; if (skybox) { if (skybox.HasProperty("_Tint")) { canUseMask = true; } } return(isSupported); }
public void Init() { if (FogShader == null) { FogShader = ImageEffectManager.API_GetShader("ImageEffect/WarFog"); } if (FogShader) { if (FogShader.isSupported) { if (mat) { Destroy(mat); mat = null; } mat = new Material(FogShader); //mat.hideFlags = HideFlags.HideAndDontSave; } else { enabled = false; } } else { enabled = false; } }
public bool prepareMaterials() { if (mAOShader == null) { mAOShader = ImageEffectManager.API_GetShader(k_ShaderString); if (mAOShader != null) { if (mAOMat == null) { mAOMat = new Material(mAOShader); mAOMat.hideFlags = HideFlags.HideAndDontSave; } } } if (mBlitShader == null) { mBlitShader = ImageEffectManager.API_GetShader(k_BlitShaderString); if (mBlitShader != null) { if (mBlitMat == null) { mBlitMat = new Material(mBlitShader); mBlitMat.hideFlags = HideFlags.HideAndDontSave; } } } return(mAOMat != null && mBlitMat != null); }
protected void API_AttachCameraRenderFlags(DepthTextureMode mod) { ImageEffectManager.CameraRenderFlagsNode reslut = ImageEffectManager.API_AttachCameraRenderFlags(m_Camera, mod); if (null != reslut) { flagReferenceList.Add(reslut); } }
public override bool CheckResources() { if (!shader) { shader = ImageEffectManager.API_GetShader("Hidden/FXAA Preset 2"); } CheckSupport(true); if (mat == null) { mat = CheckShaderAndCreateMaterial(shader, mat); } if (!isSupported) { ReportAutoDisable(); } //新的支持头顶文字不反锯齿 if (topNameShader == null) { topNameShader = ImageEffectManager.API_GetShader("Effect/BillBoradFXAA"); } if (blendShader == null) { blendShader = ImageEffectManager.API_GetShader("Hidden/BlendNameShader"); blendMat = CheckShaderAndCreateMaterial(blendShader, blendMat); } if (topNameCam == null) { obj = new GameObject("CpyCam"); topNameCam = obj.AddComponent <Camera>(); } if (updateCamera) { obj.transform.position = gameObject.transform.position; obj.transform.rotation = gameObject.transform.rotation; topNameCam.CopyFrom(GetComponent <Camera>()); topNameCam.renderingPath = RenderingPath.VertexLit; topNameCam.clearFlags = CameraClearFlags.Color; topNameCam.backgroundColor = new Color(0, 0, 0, 0); topNameCam.enabled = false; topNameCam.cullingMask = LayerMask.GetMask("TopName"); //1 << 21;; } if (topNameShader == null) { Debug.Log("头顶文字Shader没有!!"); } //end新的支持头顶文字不反锯齿 return(isSupported); }
public static void API_SetDirty(Camera Cam) { ImageEffectManager result = GetImageEffectManager(Cam); if (result) { result.dirty = true; } }
public static void API_UnResigiterFoucusChage(Camera Cam, System.Action <bool> call) { ImageEffectManager result = GetImageEffectManager(Cam); if (result) { result.OnFoucusChange -= call; } }
public static void API_DeAttachCameraRenderFlags(Camera Cam, ref CameraRenderFlagsNode flags) { ImageEffectManager res = GetImageEffectManager(Cam); if (res) { res.DeAttachCameraRenderFlags(ref flags); } }
public static void API_Remove <T>(Camera Cam) where T : ImageEffectNode { ImageEffectManager result = GetImageEffectManager(Cam); if (result) { result.Remove <T>(); } }
public static void API_SetImagEffectParam <T>(Camera cam, string paramName, float Val) where T : ImageEffectNode { ImageEffectManager result = GetImageEffectManager(cam); if (result) { result.SetImagEffectParam <T>(paramName, Val); } }
private static void API_Refetsh(Camera cam) { ImageEffectManager result = GetImageEffectManager(cam); if (result) { result.Refresh(); } }
public static void API_InitSceneCamera(Camera Cam) { ImageEffectManager ime = Cam.GetComponent <ImageEffectManager>(); if (ime) { ime.InitSceneCamera(); } }
public static void API_ApplicationFocusChanged(Camera cam, bool value) { ImageEffectManager result = GetImageEffectManager(cam); if (result) { result.ApplicationFocusChanged(value); } }
public static void API_ClearSceneCamera(Camera Cam) { ImageEffectManager res = GetImageEffectManager(Cam); if (res) { res.ClearSceneCamera(); } }
public static void API_EnableImageEffect(Camera Cam, Type t) { ImageEffectManager result = GetImageEffectManager(Cam); if (result) { result.EnableImageEffect(t); } }
public static void API_DisableImageEffect <T>(Camera Cam) where T : ImageEffectNode { ImageEffectManager result = GetImageEffectManager(Cam); if (result) { result.DisableImageEffect <T>(); } }
public static void API_UpdatePlayer(Camera cam, GameObject hero) { ImageEffectManager result = GetImageEffectManager(cam); if (result) { result.hero = hero; } }
protected void DeAttachAllCameraRenderFlags() { for (int i = 0; i < flagReferenceList.Count; i++) { ImageEffectManager.CameraRenderFlagsNode nod = flagReferenceList[i]; ImageEffectManager.API_DeAttachCameraRenderFlags(m_Camera, ref nod); } flagReferenceList.Clear(); }
public void InitRender() { m_CommandBuffer = new CommandBuffer(); m_CommandBuffer.name = "GlowOutLineCommandBuffer"; if (Application.isPlaying) { Shader s = ImageEffectManager.API_GetShader("Effect/Glow/GlowOutLineObjects"); GlowOutLineMaterial = new Material(s); } }
public static T API_Add <T>(Camera Cam) where T : ImageEffectNode { ImageEffectManager result = GetImageEffectManager(Cam); if (result) { return(result.Add <T>()); } return(null); }
public static List <ImageEffectNode> API_GetImangeEffectList(Camera cam) { ImageEffectManager result = GetImageEffectManager(cam); if (result) { return(result.AllImageEffeNodeList); } return(null); }
public override bool ImageEffect_RenderImage(RenderTexture source, RenderTexture destination, RenderBuffer depthBuffer) { if (!ImageEffects.ImageEffectManager.AdvanceImangeEffectEnabled) { return(false); } if (!CheckResources() || !IsOnValidLOD()) { return(false); } // clamp & prepare values so they make sense if (aperture < 0.0f) { aperture = 0.0f; } if (maxBlurSize < 0.1f) { maxBlurSize = 0.1f; } focalSize = Mathf.Clamp(focalSize, 0.0f, 2.0f); internalBlurWidth = Mathf.Max(maxBlurSize, 0.0f); // focal & coc calculations ImageEffectManager result = null; ImageEffectManager.ImageEffectManagerTable.TryGetValue(m_Camera, out result); if (result != null) { if (result.hero != null) { focalTransform = result.hero.transform; } } focalDistance01 = (focalTransform) ? (m_Camera.WorldToViewportPoint(focalTransform.position)).z / (m_Camera.farClipPlane) : FocalDistance01(focalLength); dofHdrMaterial.SetVector("_CurveParams", new Vector4(1.0f, focalSize, aperture / 10.0f, focalDistance01)); if (ShowFocus) { WriteCoc(source, true); Graphics.Blit(source, destination, dofHdrMaterial, 2); } else { source.filterMode = FilterMode.Bilinear; WriteCoc(source, true); dofHdrMaterial.SetTexture("_FgOverlap", null); dofHdrMaterial.SetVector("_Offsets", Vector4.one * (2 * internalBlurWidth)); Graphics.Blit(source, destination, dofHdrMaterial, 1); } return(true); }
private static ImageEffectManager GetImageEffectManager(Camera cam) { ImageEffectManager result = null; if (cam) { ImageEffectManagerTable.TryGetValue(cam, out result); } return(result); }
public override void OnActive() { if (mode == EdgeDetectMode.SobelDepth || mode == EdgeDetectMode.SobelDepthThin) { flagReference = ImageEffectManager.API_AttachCameraRenderFlags(m_Camera, DepthTextureMode.Depth); } else if (mode == EdgeDetectMode.TriangleDepthNormals || mode == EdgeDetectMode.RobertsCrossDepthNormals) { flagReference = ImageEffectManager.API_AttachCameraRenderFlags(m_Camera, DepthTextureMode.DepthNormals); } }
private static Material CreateMaterial(string shadername) { if (string.IsNullOrEmpty(shadername)) { return(null); } Material material = new Material(ImageEffectManager.API_GetShader(shadername)); //material.hideFlags = HideFlags.HideAndDontSave; return(material); }
public static CameraRenderFlagsNode API_AttachCameraRenderFlags(Camera cam, DepthTextureMode mod) { CameraRenderFlagsNode reslut = null; ImageEffectManager res = GetImageEffectManager(cam); if (res) { reslut = res.AttachCameraRenderFlags(mod); } return(reslut); }
public override bool CheckResources() { CheckSupport(true); // only requires depth, not HDR dofHdrMaterial = CheckShaderAndCreateMaterial(ImageEffectManager.API_GetShader("ImageEffect/DepthOfField"), dofHdrMaterial); if (!isSupported) { ReportAutoDisable(); } return(isSupported); }