Unity Camera Target Texture Render Texture How To Get Masks To Work? - unity3d

I'm looking at using Camera TartetTexture RenderTexture functionality for less processing intensive menu transitions but I'm having some trouble. Every texture I render out from the camera doesn't have masks working. I can see the whole version of every graphic on the screen. How can I get it rendering keeping the masks in tact? It is also failing to render any of my spawned prefabs. Either that or they could be hidden behind the unmasked graphics.
Also, I was told to render to a material. None of the shaders I've tried have supported the masks (don't know if that's really the problem) or have looked like the original image. They all look dark and moody, with the occasional weird alpha channel in the upper left corner. How can I get the image looking just like my screen?
My menus are all on a Screen Space - Overlay canvas, so they shouldn't need to be lit.

Related

How do i make a 3d game pixel perfect? so that there is no anti aliasing or other filtering applied

This is what the game looks like in the 'game' window in unity, which is what it should look like https://ibb.co/xjst4vw achieved by removing all lighting including ambient lighting.
And this is what it looks once built https://ibb.co/4RcbMv8
Why is there a haze in the border between colors? How do I get it to be pixel perfect?
The aspect ratio of the in editor display is 160x144
I have change the game resolution by going to >edit >project setting >player and changing the height and width to the right size
The camera is also passing to a render texture which is of the right size, with the filter mode set to point.
I cant figure out what is causing this. to my knowledge All lighting is turned off. It looks like some up scaling error or maybe some sort of anti-aliasing effect which has also been turned off everywhere i could find.
Does anyone have an idea about what might be causing this? thanks.
There is postprocessing window in unity where you can specify such things like antyaliasing and so on. I think that this will make your game pixel perfect.
Found the answer to my own question the resolution in the >edit >project setting >player >resolution and presentation need to be as high res as it can be so in my case for a 1920x1080 screen it should 1120,1008 which is 160x144 scaled up by 7.
Then send data from you're main camera to a render texture that is set to the resolution you want (in my case 160x144) and create UI canvas that takes up the whole screen and a raw image as a child. Then put the render texture you created in the texture.

All shaders render black while using shadergraph in unity 2020 1.10f

I am doing a simple animation in unity and I wanted to add portal efecct using shadergraph 8.2.0 and everything renders black
like this
shader setings
I have no clue whatsoever what it is
I'm still learning the pipeline, however, I would think you need to scale up the texture on the top left, I can't read its name from the image. But you are getting the red/yellow mix, getting the swirl, but the area that's being blacked out is comparable to the texture I mentioned. Sorry I don't know how to put it exactly, but the white to grey to black gradient is not large enough so you are rendering the center fine just need to expand the white-grey area, I think scaling the texture up would produce the effect you want.

Unity: Any way to get anti-aliasing on Screen Space - Overlay Canvas?

I'm using Unity and I have a Screen Space - Overlay canvas and it has Image objects that rotate. The problem is that on shallow rotations the images have really obvious jagged edges. I can't find any built in anti-aliasing solution that fixes this.
I know the MSAA in the settings doesn't apply to overlay canvases, neither does the anti-aliasing in the Post Effects package.
I can't change to a Screen Space - Camera canvas, I know that will apply MSAA but it breaks my game in too many other ways to be viable (my game is almost finished, I left adding AA to the end which may have been a mistake).
Is there any way to get AA to work on an overlay canvas?
A possible solution is in the second answer in this question on Game Development Stack Exchange: add a transparent outline to your image.
Enabling mip-maps gets you half way there, but the other half of it is to make sure that sides you want smoothed are bordered by alpha transparency. The outer edge of everything you want smooth must be transparent.

Unity3D - Make texture edges not stretch

I've been searching around for this one for a bit, and unfortunately I can't seem to find any good, consistent results. So, in the Unity UI system, buttons can stretch without becoming pixelated or distorted. This is because the texture is split up into 9 parts - the corners, middle, and sides.
This works because the button's middle and sides are stretched, but not the corners. Then, the button appears not pixelated, at any dimension.
So, the question is as follows: How can I do the same thing for a transparent, unlit texture in 3D space? I have a speech bubble texture on a flat plane that I know how to re-scale to fit the text in the speech bubble.
I've set the texture type to Multiple Sprite, and divided it up into 9 parts. However, I cannot seem to find where I can set the texture to act like the UI button does, and I'm not sure that this is even possible in this way in 3D space.
Is there a way, or should I just make the different parts of the texture different objects, and move them together? That would seem very inefficient and ugly compared to this.
To accomplish what you are asking, you would need to create tiles for this speech bubble and then write a script that procedurally builds a speech bubble based on the plane's scale value. You could also try just changing the texture's Filter Mode to Point.
However I really don't think you should be using textures for this anyway. Why not just use a Unity Canvas and set the Render Mode to World Space? Then you can just set your text box to be a sprite, not a texture, and set its filter mode to Point (See below). This would also make it a lot easier for when you want there to be text in the speech bubble later on.

Unity - Render Texture from Camera's targetTexture produces seams

I am attempting to render a specific section of my scene using a separate camera, and a render texture. That object is on a separate layer that the main camera is not rendering, but a separate camera is. The secondary camera has a target texture set to be a render texture that I have created. Everything is working as intended except for the fact that the object, when rendered to a texture, has a bunch of seams that are not present when rendering directly to the screen.
What it looks like when rendered directly to the screen:
Correct
What it looks like when rendered to a texture, and then displayed on a quad in the scene:
Incorrect
Notice how the second image has a bunch of transparent "lines" in between the sprites where there shouldn't be any.
I am using a basic transparent shader to display the render texture on the quad (since the background isn't part of the render texture, just the black crowd part). I have tried a number of different shaders, and none of them seem to make a difference.
The render texture's settings are: Width: Screen.width Height: Screen.height Format: RenderTextureFormat.ARGBFloat;
Unity Version: 5.2.3f1 - iOS Platform
Note: The reason I am doing this is so that I can apply a "Blur" image effect to the texture, and make the crowd in the foreground appear to be out of focus. Any alternative suggestions for how to do this are also welcome.
I'm not quite sure -- but it almost sounds like you have line ghosting. You may want to give this a read and let me know if that's what you're dealing with or not:
The reason for this is due to how the texture image was authored, combined with the filtering that most 3d engines use when textures are displayed at different sizes on screen.
Your image may have coloured areas which are completely opaque, coloured areas which are partially transparent, and areas which are completely transparent. However, the areas where your alpha channel is completely transparent (0% opacity) actually still have a colour value too. In PNGs (or at least, the way Photoshop exports PNGs) seems to default to using white for the completely transparent pixels. With other formats or editors, this may be black. Both are equally undesirable when it comes to use in a 3d engine.
You may think, "why is the white colour a problem if it's completely transparent?". The problem occurs because when your texture appears on screen, it's usually either upscaled or downscaled depending whether the pixels in the texture's image are appearing larger or smaller than actual size. For the downsizing, a series of downscaled versions get created during import. These downscaled versions get used when the texture is displayed at smaller sizes or steeper angles in relation to the view, and is intended to improve visual quality and make rendering faster. This process is called "mip-mapping" - read more about mip-mapping here. For upscaling, simple bilinear interpolation is normally used.
The scaled versions are usually created using simple bilinear interpolation, which means that the transparent pixels are mixed with the neighbouring visible pixels. With the mipmaps, for each smaller level, the problem with the invisible mixing with the visible pixel colours increases (with the result that your nasty white edges become more apparent at further distances away).
The solution is to ensure that these completely transparent pixels have a colour value which matches their neighbouring visible pixels, so that when the interpolation occurs, the colour 'bleed' from the invisible pixels is of the appropriate colour.
To solve this (in Photoshop) I always use the free "Solidify" tool from the Flaming Pear Free Plugins pack, like this:
Download and install the Flaming Pear "Free Plugins" pack (near the bottom of that list)
Open your PNG in photoshop.
Go to Select -> Load Selection and click OK.
Go to Select -> Save Selection and click OK. This will create a new alpha channel.
Now Deselect all (Ctrl-D or Cmd-D)
Select Filter -> Flaming Pear -> Solidify B
Your image will now appear to be entirely made of solid colour, with no transparent areas, however your transparency information is now stored in an explicit alpha channel, which you can view and edit by selecting it in the channels palette.
Now re-save your image, and you should find your white fuzzies have dissappeared!
Source: http://answers.unity3d.com/questions/10302/messy-alpha-problem-white-around-edges.html
Turns out that the shader I was using for my scene was using "Blend SrcAlpha OneMinusSrcAlpha" for some reason, when it should have been using "Blend One OneMinusSrcAlpha". This was causing objects with alpha less than 1 to make the objects under them become semi-transparent as well exposing the camera's clear colour background.