Use the whole screen to display a shader / material - unity3d

I created a hlsl shader which is rendering a sierpinski fractal using Raymarching. Currently I have assigned the shader to a material, this material is assigned to a cube which I placed in the scene. So the sierpinski fractal is displayed / rendered on the cube geometry.
How can I use the whole screen / camera view to display my shader? I don’t want to add my shader to a material which I assign to a geometry.

In case someone is coming to this question and have the same problem as I had, you can do the following:
use a Graphics.Blit to execute a certain shader
store this information in a RenderTexture
assign this RenderTexture to e.g. a Canvas RawImage.texture

Related

Rendering one mesh before another in Unity 2018?

I have a bunch of models with inverted normals for outlines. However, I want to render the meshes in front of the outlines so there's no glitchy clipping. Does anyone know of a shader or way to render the meshes in front of the outlines?enter image description here
Changing the render queue for the outline shader should fix your issues.
In the outline shader:
Tags{ "Queue" = "Geometry-1"}
Just make sure the queue number to render the outline is before the other objects. Example of tags location below.

Getting angles in my 2d circles when using texture in unity

I am building my first 2D mobile game using unity, everything works as expected when I create a circle with a new default Material, but when I use a Material that has a Shader and a texture the circle shows angles.
I am using unity 2020.2.1f1 with Universal Render Pipeline running on Linux.
I have attached an image of the problem, the left circle uses a Material with Shader and texture and the right one uses a Material without texture.
I would like the left circle to be also a proper circle as the one in the right side.
Circles
Shader
There is also an error that says Material does not have _MainTex texture property. It is required for SprintRenderer But when I add that as reference of the property, the texture is not shown at all. I don't know if that could be related.
When I install unity 2019.4.19f1 the circle is rendered as I expected. So that is how I fixed it.
The message:
Material does not have _MainTex texture property. It is required for SprintRenderer
wasn't related with the problem.

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?

Shader to warp or pinch specific areas of a texture in Unity3d

I've mocked up what I am trying to accomplish in the image below - trying to pinch the pixels in towards the center of an AR marker so when I overlay AR content the AR marker is less noticeable.
I am looking for some examples or tutorials that I can reference to start to learn how to create a shader to distort the texture but I am coming up with nothing.
What's the best way to accomplish this?
This can be achieved using GrabPass.
From the manual:
GrabPass is a special pass type - it grabs the contents of the screen where the object is about to be drawn into a texture. This texture can be used in subsequent passes to do advanced image based effects.
The way distortion effects work is basically that you render the contents of the GrabPass texture on top of your mesh, except with its UVs distorted. A common way of doing this (for effects such as heat distortion or shockwaves) is to render a billboarded plane with a normal map on it, where the normal map controls how much the UVs for the background sample are distorted. This works by transforming the normal from world space to screen space, multiplying it with a strength value, and applying it to the UV. There is a good example of such a shader here. You can also technically use any mesh and use its vertex normal for the displacement in a similar way.
Apart from normal mapped planes, another way of achieving this effect would be to pass in the screen-space position of the tracker into the shader using Shader.SetGlobalVector. Then, inside your shader, you can calculate the vector between your fragment and the object and use that to offset the UV, possibly using some remap function (like squaring the distance). For instance, you can use float2 uv_displace = normalize(delta) * saturate(1 - length(delta)).
If you want to control exactly how and when this effect is applied, make it so that has ZTest and ZWrite set to Off, and then set the render queue to be after the background but before your tracker.
For AR apps, it is likely possible to avoid the preformance overhead from using GrabPass by using the camera background texture instead of a GrabPass texture. You can try looking inside your camera background script to see how it passes over the camera texture to the shader and try to replicate that.
Here are two videos demonstrating how GrabPass works:
https://www.youtube.com/watch?v=OgsdGhY-TWM
https://www.youtube.com/watch?v=aX7wIp-r48c

Custom skybox shader for tiled skybox

I am new to writing shaders. I want to use a texture for 6-sided skybox in unity and I want that texture to be repeated several times also called tiling.
But the default 6-sided skybox shader in unity doesn't have tiling option. Can anyone write a custom shader for 6-sided skybox in unity which has option to tile textures? I also want an option to apply a color tint on the texture if possible. Thanks in advance.
Tiling can be achieved by multiplying texcoord by the number of tiles you want. Or in Surface shader it's uv_YourTex (likely MainTex) instead of texcoord. Writing from a phone so can't post an example, but it's really just one multiplication.
I don't know your specific scenario, but I needed to get more detailed sky with not very detailed texture and instead of UV I used view direction to sample a texture. It made it look like clouds in the distance are further away + clouds can move as you move . It's in this asset.
View direction sampling will not help if you are trying to make space though, which seams to be the case.
Also IMHO tiling on the skybox might be too visible.