How to feed a transform.position into shader graph? - unity3d

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 :)

Related

Do you know how to do an inverted mask/shader or any other way to see onlu part of an object within a sphere boundary in Unity?

Cut out sphere
What im looking for it this exactly behaviour but what i need is that is compatible with URP, as you may see im just starting with Shaders
could you give me any guidance on how to update this to URP?
i have look up for stencil shader / cut out / Buffer
i have replicated the portal stile ones but i need the object to be able to grow like a tree but if its outside the sphere should not show
You can do it with Sphere Mask node :
And link Out to the Alpha property (if your Surface Type is set to Opaque then, check the Alpha Clipping in your Graph settings).

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 achieve variable distortion along height on single 2D Sprites

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

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.

Sprite Kit Physics Body Complex Shape - Spritekit

I have this situation: http://mokainteractive.com/example.png
I'd like to move the white ball inside the red track and detect wherever the balls touch the limit of the red track.
Which is the best solution? I have to create multiple transparent shape along the borders? Do you have other ideas?
thanks so much
In iOS8 you can create a single physics body for that kind of shape.
Make a texture of your shape with p.e. Adobe Illustrator and use this method:
init(texture texture: SKTexture!,alphaThreshold alphaThreshold: CFloat,size size: CGSize) -> SKPhysicsBody
The SKTexture is your shaped image. The body is defined by the colored pixels.
The alphaThresHold: The minimum alpha value for texels that should be part of the new physics body.
The Size is clear I think.
The texture is analyzed and all invisible pixels around the egg are ignored and only the color pixels are interpreted as the body of the SKPhysicsNode. You should use too many of these because they are very expensive to calculate for the Physics Engine.
Variations of this method are found in the SpriteKit Class Reference.
To your problem. Make an inverse texture of your area which should be transparent and pass it as texture to the physics body. It will be analyzed and a body around the free zone is created.
You cannot create a single physics body for that kind of shape.
Using bodyWithPolygonFromPath: will only allow you to create a convex polygonal path which obviously does not work for your shape.
I think you have 3 options here:
Use a number of bodyWithPolygonFromPath: bodies (probably the hardest to do and time consuming).
Use a number of various size bodyWithRectangleOfSize: bodies (not so hard but time consuming).
Use only straight lines in your image and use bodyWithRectangleOfSize: (the easiest and fastest). If you choose this option remember you are still free to rotate your straight lines to various angles.