How to achieve variable distortion along height on single 2D Sprites - unity3d

I'm trying to achieve an effect on single 2D sprites that is similar to those used on animes when characters are moving fast.
My start point was using the Tilling and Offset node on URP shader graphs to distort the sprite, i could change the tilling based on variables such as time but that didn't achieve the desired effect, the main problem with that node is that it distorts the whole sprite on the same amount, while the desired effect would be a distortion that varies along the height of the sprite.
Anyone got any insights on this?
Here's my reference point,
base sprite:
distorted (i would like a more detailed - less distorted effect but i hope you get the idea):
Edit 1: My current progress

Related

Any way to get a URP shader to tile at a constant size, regardless of face orientation?

I need a shader which I can apply to a surface, and have it tile a texture at a constant size. Think 'stretchable brick wall' I looked at this world shader hoping I could adapt. https://www.youtube.com/watch?v=vIh_6xtBwsI&ab_channel=JustinFoley
The problem with world UV's is they only project along the major axes. I need it to follow the rotation of the object, just not affected by scale.
This is what I was trying:
But as you can imagine, it is still affected by scale, and appears to align with the y plane:

How to feed a transform.position into shader graph?

I am trying to mask a sprite by using shader graph.
Here is a picture of what I have so far:
my problem is that when I feed the mask texture into the shader it centers itself on the main texture, as you see in this image.
See the slightly transparent checkerboard to the right side of the character? I only want this operation to affect the parts where the checkerboard intercepts with the character.
For this I would need someway to displace and scale(?) the mask texture so that it detaches from the center of the main texture.
What nodes do I have to add to accomplish this, and where to connect them? Thanks.
As I commended I do not fully understand the question, but I will give it a try!
You want to move the UV of the texture to only make it apply to part of the image, and disable wrapping!
This can be done by using UV node while using the same channel you have on the overlapping texture and then adding the offset to it.
In order to disable wrapping you need to disable it on texture itself
Change Wrap Mode to Clamp
Set offset to values below 1. Now you need to just calculate what offset value for you will be as 1 is the full width of the image.
EDIT:
Instead of manually changing the UV texture you should use Tiling and Offset node which has easy scaling by changing tiling values.
Good luck :)

Standing inside an Object without clipping

My Application is a simulation of a 3D-Audio cage we have in our lab at uni.
To best simulate it, we made it a wireframe-sphere.
I need to be able to stand inside the cage, but if my Sphere is around my Camera, it clips, so it doesn't render until i move away.
I also need to be able to Rotate it, but not move it.
Is there a way to disable clipping for this case? What else can i try to get the desired result?
I've tried to set the clipping pane for the camera to 0, but 0.01 is the lowest it can be.
Also I've tried to use a transparent shader, both tries left me the same problem of the object clipping.
Object visibility when inside
Is there a way to disable clipping for this case? What else can i try
to get the desired result?
You can invert the normals of the sphere. Or model a sphere with normals on the inside and the outside if you want to look at it from both sides.
Another solution could be to use a shader with disabled backface culling (Cull off).
This stackoverflow answer might be helpful: Flip Normals in Unity 3D/spheres
Missing Manipulation Handler (MRTK)
If I understand the ManipulationHandler correct, you can make a smaller sphere with a ManipulationHandler inside the larger sphere and copy the transform changes to the larger sphere.
If you want to keep the larger sphere at the same place don't copy the position changes.

Unity - Avoid quad clipping or set rendering order

I am using Unity 5 to develop a game. I'm still learning, so this may be a dumb question. I have read about Depth Buffer and Depth Texture, but I cannot seem to understand if that applies here or not.
My setting is simple: I create a grid using several quads (40x40) which I use to snap buildings. Those buildings also have a base, made with quads. Every time I put one one the map, the Quads overlap and they look like the picture.
As you can see, the red quad is "merging" with the floor (white quads).
How can I make sure Unity renders the red one first, and the white ones are background? Of course, I can change the red quad Y position, but that seems like the wrong way of solving this.
This is a common issue, called Z-Fighting.
Usually you can reduce it by reducing the range of “Clipping Planes” of the camera, but in your case the quads are at the same Y position, so you can’t avoid it without changing the Y position.
I don't know if it is an option for you, but if you use SpriteRenderer (Unity 2D) you don’t have that problem and you can just set “Sorting Layer” or “Order in Layer” if you want modify the rendering order.

Find angle face under mouse pointer in Unity 3d

I have a projector component and I need to find the angle that projected texture falls at to exclude the projecting on vertical faces.
My projector is under the mouse pointer and works ok when it is over an horizontal face:
I would like the projector to switch off on vertical faces to avoid this bad effect:
If possible, I would like to do it in the shader code to avoid the vertical projected image even if the cursor is located on the corners of an horizontal face and a part "goes out" on vertical face.
I found this solution in C#:
if (Physics.Raycast(MouseRay,out hitInfo)){
if(hitInfo.normal.y>0) {
// draw
} else {
// not draw
}
}
But only it works on curved surfaces and not, for example, on the face cubes.
How can I do this properly?
Normally they would use an image on a quad using TGA transparency, which rotates itself to the face that the middle of the object is aligned to, using ray to find the vertex and making it's absolute normal.
Other ways of doing it would be quite tricky, perhaps using decals... If you did it using a shader, it would take so much time... it's a case of problem solving not being ordered in order of importance for fast development. Technically you can project a volumetric texture on top of whatever object you are using... that way you can add your barred circle projected from a point in space towards the object, as a mathematical formula, it takes a while to do, check out volumetric textures, i have written some and in your case it needs the mouse pos sent to texture and maths to add transparent zone and red zone to texture. takes all day.
It's fine to have a flat circle that flips around when you change the pointer onto a different face, it will just look like a physical card and it's much easier to code, 10 minutes instead of many hours.