Is there a way to apply bloom to a specific object? - unity3d

I've currently noticed that, if i uncheck the "is Global" checkbox on the Bloom Effect of a Post Processing Volume, even thought I adjusted my layer to affect one in particular, the Bloom doesnt apply to that layer I've set in the P-p layer. In fact, it doesn't apply at all. Either it sets bloom for everything in the scene, or it doesn't.
Extras: I have no Pipeline asset, maybe thats the issue, but I've tried to setting one LRP (because for some reason URP in my 2019.2.17f1 version doenst exist) and it just breaks all my materials that i use for Particle Systems (Particles/Standard Unlit) even if i upgrade them for LRP materials.
Any ideas? If it's possible to deliver a solution to both these problems excellent, but the main one is the title question.

Note: The "camera stacking" approach mentioned here applies only to Unity URP. For the Unity Built-in Render Pipeline or Unity versions prior to 2019.3.0f3 you can achieve a similar effect with RenderTextures. Though Unity HDRP has no explicit "camera stacking" feature it does allow for the same net effect via the HDRP-specific Graphics Compositor.
"Is there a way to apply bloom to a specific object?"
You could take a leaf out of Unity camera stacking whereby one set of objects are rendered by one camera and another set with a different camera. The results of each camera rendering are merged together automatically by Unity and presented to the screen.
But don't take my word for it, this is what Unity has to say:
In the Universal Render Pipeline (URP), you use Camera Stacking to layer the output of multiple Cameras and create a single combined output. Camera Stacking allows you to create effects such as a 3D model in a 2D UI, or the cockpit of a vehicle. Tell me more...
...and (my emphasis):
A Camera Stack overrides the output of the Base Camera with the combined output of all the Cameras in the Camera Stack. As such, anything that you can do with the output of a Base Camera, you can do with the output of a Camera Stack. For example, you can render a Camera Stack to a given render target, apply post-process effects, and so on. Tell me more...
When you consider that each camera has the potential for its own rendering settings (including bloom) the solution is clear:
ensure there are two cameras in the scene, say My Default Camera and Bloomin' Camera
create a custom layer called "Bloom"
assign whatever objects you want to be rendered with a bloom to layer Bloom
setup the camera stack as per "Adding a Camera to a Camera Stack".
My Default Camera should be set to "Base":
Bloomin' Camera should be set to overlay:
Add Bloomin' Camera to My Default Camera Stack settings:
ensure that the Culling mask for My Default Camera has the Bloom layer unticked. This ensures that the objects to be bloomed are only drawn once on the Bloom layer
ensure that the Culling mask for Bloomin' Camera has a single ticked entry for the Bloom layer and nothing else. You don't want to double-up on rendering otherwise you will get funky and undesirable z-order effects apart from hurting game performance. Other layers will be rendered by My Default Camera.
apply bloom effects to camera Bloomin' Camera
run game, celebrate

The is global might sound confusing at first. Ultimately it does not mean where to apply the post processing effect, but when to apply the effect. If it is set to Global, it will always be applied, otherwise you can set a layer and a border that triggers the effect.
The general approach is to only set emission to materials where you want the effect to take place. If your Materials are to dark otherwise you should adjust the ambient lighting settings.
Atleast in URP there are some work arounds for older versions like this, but afaik this does not work in 2020.3 since they made some changes on URP and the camera system.
edit: on the video Chris Hull
Chris Hull game an answer for how to do it with the new system
#Mezzanine Add your actual game objects to a created bloom layer.
Create two cameras and set one of them to cull everything except that
bloom layer you made. Set the other to only cull the bloom layer. Then
you can set your camera to overlay and it will be added to the other.
You can then use separate post process stacks on these cameras. Note
that you can only bloom objects in the background with this technique
as if you add bloom to an overlay camera, for some reason it just adds
bloom to everything rather than just the things in that camera view.
Doesn't make much sense and makes the purpose of the layers redundant
in my opinion. If you can find a way to add post process to the
overlay camera before it is added to the final image, to do let me
know.
i have not tested that yet, but i presume it's still valid.

Related

Unity AR Foundation: how to influence the renderorder

in my AR application I want to render a model on top over another. Is there any method or variable to influence this?
Yes,there are at least two options:
z-test set to always
this has to be set on the shader of the materal your model is using. Here's the documentation from unity, but there are also some guides online how to write a shader with custom z-test.
two Cameras
This is done by having two cameras. One is your ARCamera and a second one that always at the same pose as the ARCamera. This could for example be done by setting the 2nd camera as a child of the ARCamera with Identity Pose. Then you can create a special Layer for example "Always In Front" and assign the model to it. Then set the cullings Masks accordingly for both cameras such that the 2nd camera only renders the model and the ARCamera only everything else. There might be some overhead when rendering two cameras with this solution.
Your problem has a similar solution to preventing weapons clipping in FPS games. As seen in this blogpost .
MainCamera
SecondCamera
The two picutes show the properties I set in the inspector for each camera. Therefore I tried it also in two diffrent ways but neither made a diffrence.
I: SecondCamera is the Child of the MainCamera
II: SecondCamera and MainCamera are both on the same hierarchy level in the ARSessionOrigin.

Unity2D bloom doesn't work although the object emits light

I'm working on a 2D game and I want to add neon effects to certain objects. I tried using Universal Render Pipeline, however, I still can't seem to get bloom to... bloom.
I will try my best to describe what I tried before:
Before: I followed a tutorial about using Universal Render Pipeline. I made a lit 2D material, created a point light and increased its intensity. I couldn't get the bloom working so I reverted back to the built-in render pipeline.
Currently: Using the built-in render pipeline, I installed the post-processing package from the package manager. I added Post-process Layer and Post-process Volume components to the Main camera. I set up a post-processing profile and added the Bloom component to it. In the Post-process Layer, I set the Layer to "Glowing Object" and appropriately changed the layers of the objects I want neon effect on. I dragged the profile into the appropriate field in the Post-process Volume. For the objects, I made separate materials that have emission set to true. However, I still don't have a blurry effect on these said objects.
Here is the game view when the directional light is disabled (although I added a culling mask to the "Glowing Object" layer, I disabled it for clarity):
The objects GLOW, but they don't BLOOM which is very confusing to me. I apologize if I'm missing something obvious but I really tried to search around for the solution. I will now provide images of each relevant game object in case I couldn't explain it well.
The object materials:
The main camera (includes post-processing components):
Thank you so much for your help.

How do I use different Post-Processing effects on different cameras in Unity 2017.4.2f2?

Before I explain my situation, it's important that I mention I'm using an older version of Unity, 2017.42f2 (for PSVITA support). for this reason, I'm also using the old Post-Processing Stack.
I'm making a game in which I want a lot of bloom on the UI, but not as much for the rest of the game. I used a camera to render the UI, gave it Post-Processing (Screen Space - Camera on Canvas),
and another one to render the rest of the game
Each is given a different profile to use different effects.
My expectation is that the UI renderer camera would only apply it's effects to the Canvas. Instead, it also applies them to the camera beneath it; the game renderer camera.
As you can see I used Don't Clear clear flags. I also tried Depth-only, to see if it would make a difference.
I'm lost as to what I could do. Grain and bloom get applied to everything
yet the profile for those effects is only given to the UI renderer Camera's Post Processing Behavior Script.
Does anyone have any suggestions or ideas? I'm lost.

Unity 2D and UI rendering issues

I have been developing a game for a little while now and have started to notice rendering issues with the Unity3D engine. The poop emoji is supposed to appear in front of the floor tile but this isn't the case here. There are more depending on how you position the camera. They are both on the default layer and I have no idea what the cause would be.
If multiple sprite are on the same sorting layer and the same order in layer index you cant be sure which one will be on top of others. It could change anytime depending of the camera position or even on game session.
To be sure of your rendering , use the order in layer and set a higher value to the emoji than the floor.
Note : I use the 2020.2.0b unity version. Your inspector could look different but the Order in Layer should be there.

Recommendations for clipping an entire scene in Unity

I'm looking for ways to clip an entire unity scene to a set of 4 planes. This is for an AR game, where I want to be able to zoom into a terrain, yet still have it only take up a given amount of space on a table (i.e: not extend over the edges of the table).
Thus far I've got clipping working as I want for the terrain and a water effect:
The above shows a much larger terrain being clipped to the size of the table. The other scene objects aren't clipped, since they use unmodifed standard shaders.
Here's a pic showing the terrain clipping in the editor.
You can see the clipping planes around the visible part of the terrain, and that other objects (trees etc) are not clipped and appear off the edge of the table.
The way I've done it involves adding parameters to each shader to define the clipping planes. This means customizing every shader I want to clip, which was fine when I was considering just terrain.
While this works, I'm not sure it's a great approach for hundreds of scene objects. I would need to modify whatever shaders I'm using, and then I'd have to be setting additional shader parameters every update for every object.
Not being an expert in Unity, I'm wondering if there are other approaches that are not "per shader" based that I might investigate?
The end goal is to render a scene within the bounds of some plane.
One easy way would be to use Box Colliders as triggers on each side of your plane. You could then turn off Renderers on objects staying in the trigger with OnTriggerEnter/OnTriggerStay and turn them on with OnTriggerExit.
You can also use Bounds.Contains.