How to make inner edge shader in unity shader graph? - unity3d

I want to create a wall shader that looks like this:
Image
The inner part is already done (diagonal lines) and works fine, but I can't do the inner edge around the shape correctly. It has to lign-up properly and react to object scales and probably position
I only managed to make it work with rectangle objects any other shapes break the effect of continuity. The problem lies in the edge outline which doesn't work with such custom shapes.
I tried to do this with the Rectangle node but I could apply object scale tilling to it so I did the outline another way but as I said it's totally broken with complex shapes
Here are the results:
Image
The white on the right shape is this broken edge outline. So if someone can create an inner edge outline I would be glad to learn it!

Related

Hide parts of mesh overlapping another mesh in Unity

I have thoses two meshes:
In my game, I put the hat on the hair at runtime:
As you can see, as expected, the hair is visible outise the hat part.
How can I achieve this in Unity (what kind of mask shader should I use?):
I've tryed to make a depth mask but it hides every meshes in my scene. I just want to hide the hair, not others meshes.
And what if I have two player having the same case? Would player mask hide player 2 hair? How can I avoid that?
What I would do:
write a C# code that gets the pivot position (bottom part of the hat) and its up vector every frame.
build a plane with these values. The up vector would be the normal vector of the plane and a plane can be defined by a point and a normal vector.
I would pass the equation of the plane to the shader (via Material.SetFloat or Material.SetVector) and evaluate if the world positions of the hair vertices are in the correct or in the wrong side of the plane.

Unity Line Mesh Inward Shader

I am pretty new to shaders in unity and am stuck on a problem.
I am using ShaderGraph and unity 2021. I understood the ShaderGraph examples from the unity page and "implemented" an OutlineShader thinking I could simply "inverse" the direction (not multiply by some value to get a bigger object then coloring that object and laying the original object ontop). Yet I am nowhere near what I want.
Basically what I am trying to achive is a stepped color gradient to the inside of the object. As an image it should look something like this:
Starting from color0 (green) going inward to color1 (yellow) until i reach the center with colorN (white) and repeat the same for the other side. The shader is then used on a material that is applied to a MeshLineRenderer (LineRendererPro from asset store with minor modifications for custom behavior) which kind of looks like this:
In the end the line should be colored according to the specified colors and the direction the line is going.
Explanation of a simple "Inline" Shader (similar to an outline) would help alot. I think I would be able to adapt that concept and implement multiple colors with (maybe) percentages of width. I don't want to use a fixed image/texture since i want to change the widths and colors.
Any input is welcome and thank you in advance.

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.

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.

Detect Eyes Using Matlab

I have tryed hough circle algo but it give not acceptable out put of detecting
eyes . Can we find way to get the eyes detect in image I having face front ...
Try this implementation from Oxford's Visual Geometry Group. Their pipeline consists of a Viola-Jones face detector at the front and then 9 face landmarks including inner and outer corners of both eyes, center/edge of nostrils, and mouth corners.
I've used this with some success in the past. If you want an exact eye corner, then some additional refinement may be necessary as this includes a model that tries to make a best fit for the entire face.