- Home /
How do I make a particle effect show through fog?
I have a game where the fog turns up to a very high density and I want some particle effects to be unaffected by this fog.
Pretty new to Unity.
Thanks in advance!
Answer by MrSoad · Dec 08, 2014 at 10:32 PM
Ok try this instead(Disable your new camera and set your Main Cam back how it was before). Find your particle materials, click on the material in the particle renderer component to do this. Now change the shader on each of these particle materials(for each material in each particle renderer) to "Mobile/Particles/Additive Culled" (This shader is part of the std Mobile Assets, import if you have not already done so). Now with a bit of luck you will see your particles again.
Here is a pic of the Sparkle particle effect showing through the fog(Density set to 1(max)) with this shader applied to the Sparkle Materials :
Thanks! I only have $$anonymous$$obile/Particles/Additive which didn't work?
Sorry, saw your note, imported in $$anonymous$$obile assets. Trying now...
Here you go :)
Didn't work... Attached are the two states (high fog density vs low fog density) and the particles are not showing through...
Answer by static_cast · Dec 07, 2014 at 11:21 PM
Just an idea, but you could have another camera render the special particle effects seperately. Here's how you would do so:
Make a new camera. You should probably parent it to the main camera.
Make a new Layer. This layer is called "VisibleParticles". Set all of the particle effects you want to show through smoke's layer to VisibleParticles
Go to the main camera and turn off VisibleParticles in the culling mask
Go to the new camera and set every other layer off except VisibleParticles in the culling mask.
Set the new camera's Clear Flags to Depth Only.
Thanks! This is a great approach.
I'm super new though... How can I make it so that the two cameras are both showing through the first person controller at once? At the moment, I can't see the "VisibleParticles" layer because I think everything is just going through $$anonymous$$ain Camera. I've added the other camera as a child of $$anonymous$$ain Camera.
Thanks again!
For this, you just have to remove the layer that the FPC is in from the new camera's culling mask.
Thanks! At the moment...
The FPC controller is in the Default layer. The $$anonymous$$ain Camera has the following in the culling mask: Default, TransparentFX, Ignore Raycast, Water, UI The New Camera has this in the culling mask: Visible Particles
So the new camera doesn't have the FPC's layer in its culling mask. And it's still not showing up in the view.
Am I misunderstanding something? Thanks again for your help.
Look at the camera "Depth" setting on the cameras. This affects which camera draws over the other. Alter this setting on the New Camera to a value above the $$anonymous$$ain Camera so it draws over it.
Great! That was it.
Unfortunately it's still not solving my original problem... The fog in the render settings is at a very high density and the particles are still getting hidden it. I want the particles in the "VisibleParticles" layer to shine through the fog.
Am trying to figure out if there's a way to apply fog to a specific camera rather than all cameras now...
Answer by CraftyMaelyss · Mar 06, 2017 at 05:54 AM
I just want to add something on Mrsoad's comment which helped me get the same effect which is useful if you don't have the Mobile st asset:
Create a C# script and add this to it:
using UnityEngine; [RequireComponent( typeof( Camera ) )] public class CameraFogSetting : MonoBehaviour { [SerializeField] bool enableFog = true;
bool previousFogState;
void OnPreRender()
{
previousFogState = RenderSettings.fog;
RenderSettings.fog = enableFog;
}
void OnPostRender()
{
RenderSettings.fog = previousFogState;
}
}
Then drag and drop this scrip on both your cameras. You can mark fog on for one camera and leave the other unmarked and viola, you can see lights and things through fog(you still have to add another layer and assign objects/lights/particles to said layer like Mrsoad said though) Hope this helps someone! :D
Your answer
Follow this Question
Related Questions
How to change camera visibility after certain distance? 0 Answers
How do you make fog, that works in a day level, work in a night level? 0 Answers
Fog location 2 Answers
Use of particles with built in fog 0 Answers
What is the best way to create volume fog effect for a space sim without compromising performance ? 0 Answers