Can I make a unity camera mask inside a shape? - unity3d

Is there a way to render a camera only inside a sphere (or any 3D object)?
I want to render 2 cameras...each of them has different post processing effects...but one of them renders its effects in a spherical area around the player (with feathered edges if possible)...and the other renders the rest of the screen.

Related

How do I get the 2d sprite gameObject in front of the UI Canvas?

hierarchy
2d sprite
panel UI
in game
Fist make sure your canvas' Render Mode is not set to Screen Space - Overlay.
If it is, then switch it to Screen Space - Camera and then change its Render Camera property to point to your main camera.
You can then use the following canvas' properties to control where it appears in relation to other sprites (which appears on top of which), the same way you control any other 2D Sprite:
Sorting Layer
Order in Layer
Also worth noting that 2D Sprites with same Sorting Layer and Order in Layer will use the distance to the camera to decide which one appears on top of which, and the same is true for the canvas:
If your canvas' Render Mode is set to Screen Space - Camera, it will always be positioned in front of your camera and you need to use its Plane Distance property in order to position it correctly.
If your canvas' Render Mode is set to World Space, you can position it freely in the world in the same way you position any other sprite.
First of all the hierarchy window in unity is completely irrelevant when its about positioning.
In Unity everything is 3D, even if you switch to 2D perspective.
So in your case you still have your camera, your sprite and your canvas in a 3D Dimension.
To set your sprite in front of the canvas you only need to increase the positioning stats (seen in your "panel UI" screenshot) at least slightly closer to your camera than the canvas is.

How to apply a shader on multiple sprites' rendering in Unity3D?

In Unity3d, I'm trying to make a simple metaball effect using multiple sprites of a blurred round, and those sprites move randomly.
Thus I'd like the shader to perform a pixel color change from the rendering of all the sprites all together and not one by one.
Here is an example :
The picture on the left shows four sprites with the blurred sprite ; the picture on the right is the result of the shader.
And I have no clue of how to do this.
If I understand your question correctly, what you can do is
Create a new RenderTexture
Move these sprites off-screen, out of the main camera's view.
Point a new orthographic camera at all of the sprites that you've moved off-screen and set this camera's Target Texture field (in the Inspector view) to the render texture. This will save whatever the camera is seeing to that texture.
From here you can render that texture onto the surface of another game object (maybe a Quad?)
Attach a custom shader material to that quad that takes the render texture as input.
Perform whatever operations you wish to the render texture within this shader
Position this quad object in front of your main camera so that the final result gets rendered to screen
Does this make sense?

Projecting Orthographic Matrix Through A Perspective Camera

I need to render a mesh in screenspace, essentially like Unity's IMGUI. I say a mesh specifically as it is a constructed mesh of many UI tris, so I am not looking to use GL quads/tris, for example.
To avoid two cameras, I need to take the scene perspective camera, and draw that mesh with an orthographic projection so that it is drawn ortho to the screen. I've tried overriding Camera::projectionMatrix, with no success, along with GL::Push/PopMatrix and GL::LoadProjectionMatrix calls.
Is there a way to draw a single mesh (i.e. Graphics::DrawMeshNow, or a related call) with an orthographic projection matrix, using a perspective camera (or a way to force the camera into ortho just for rendering that one object)?

Displaying 3D animation on 2D Raw Image in Unity

I have 3D animation and display it on Raw Image.
The animation was quite ok testing on 3D plane, now changed to 2D Raw Image, then I am a bit weird about origins of GameObjects.
On 3D plane, animation models have origin on the ground between two legs.
Once changed to 2D Raw Image, the origin is shifted to chest. The first image is on 3D plane and the second is on 2D Raw Image.
All other position of club handle, club shaft and club head are also shifted to chest.
When I print the (x,y,z) position of club head, I have 374.9705,741.7168,-0.4869962. They should be less than 2 in 3D plane and less than 2 is correct.
How I run 3D animation on 2D Raw Image is discussed here and stated below
(1)Put the object in a specific layer (called MyLayer for the sake of the example)
(2)Set the Culling mask of a new camera to render only this specific layer
(3)Uncheck the MyLayer in the Culling mask of your main camera in order to prevent the latter to render your model
(4)Create a new Render texture in the project, and drag & drop it in the Render Texture field of your new Camera
(5) Add a new Raw Image to your UI canvas and assign the render texture in the Texture field
(6)Run my 3D animation
How can I have position of clubhead same as in my previous 3D plane?
I can't shift the origin, when I drag the whole GameObject is also shifted.
EDIT:
Let me add in why I run animation on RawImage is I need to display 3D animation on 2D canvas. For that I need Raw Image and RenderTexture to run 3D animation.
Please see the below image.
EDIT 1:
I take out of the canvas, but I don't see my model at the scene view to set the position. Why I can't see my model.
I see the model on the preview of my RawImage, but not at the scene.
DisplayCamera can see the model, but when I run I don't see model on the greencanvas too.

Unity3D Gui Sphere having distorted edges

I'm trying to make a make switch board with circular button.
For it i'm using Quad as a base and then overlaying 3D Spheres for the buttons.
For the texture of sphere's, I have made a Material to which a rectangular image is set.
in preview it looks good with all smooth edges, however, in game preview when I look closely at the sphere's their edges are distorted/pixelated.
Is there any restriction which should be adhered to make the sphere's have perfect smooth edges.
or I must be missing something.
Image uploaded. The Quad is of White color and there is a light source.
the texture was imported and overridden for platform for 2048.