- Home /
Question by
rabirland · Aug 29, 2017 at 06:32 PM ·
imagerenderopaqueimageeffect
ImageEffectOpaque problem
I have this Image effect:
[ImageEffectOpaque]
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Graphics.Blit(source, destination, fogMaterial);
}
And the shader code:
Shader "Custom/Nebula Fog"
{
Properties
{
_MainTex("Base (RGB)", 2D) = "white" {}
}
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
sampler2D _CameraDepthTexture;
float4 _FogColor;
float _Density;
float _Start;
float _End;
float ComputeDistance(float depth)
{
float dist = depth * _ProjectionParams.z;
dist -= _ProjectionParams.y;
return dist;
}
float4 frag(v2f_img i) : COLOR
{
float4 c = tex2D(_MainTex, i.uv);
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv);
depth = Linear01Depth(depth);
float dist = ComputeDistance(depth);
float fog = saturate(1 - ((_End - dist) / (_End - _Start)));
return lerp(c, _FogColor, fog * saturate(_Density));
}
ENDCG
}
}
}
But this hides every particle in the scene, none of them is visible by the camera. Disabling "ImageEffectOpaque" shows the particles, but when the fog density is set, they are hidden again.
Any solution?
Comment
Your answer
Follow this Question
Related Questions
Low FPS, GPU usage at 99.9% 0 Answers
When are Lens Flares rendered? 1 Answer
What GUI method renders 3D object thumbnail previews in the editor? 1 Answer
How is a Skybox Made From an Image? 4 Answers