How do I invert the normal of a sphere in SceneKit? - swift

I have a sphere with a texture on the outer side. I want the texture to be on the inside of the sphere. The outside should be transparant, so texturing both sides won't work.
I want to use the sphere for an AR portal to display 360 content.

Set the cullMode property of the SCNMaterial to front instead of the default back. The doubleSided property has to be NO/false. Both sides are textured by default, setting the cull mode to front will cause it to render only back facing faces, as if the normals are flipped, and will give you the desired results.

Related

Objects disappear at certain angles

So I made a water shader and for some reason in-game, the object disappears at certain camera angles. the material is also flipping the plane 90 degrees when i place it on an object
ShaderGraph
ShaderGraph
FlippedPlaneProBuilder
VideoOfError
I tried changing the alpha but that had no effect
I'd wager that your plane is moving into the near-clip plane of the camera. Anything that is not within the camera's viewable frustum is clipped away (not rendered).
read more here

How to make Sphere Mask follow the parent?

I'm making a bubble shield. I use the Sphere Mask in Shader Graph to make a collision effect (the Sphere Mask uses global position as Coords). But if I move the shield, the Sphere Mask will be in the same world place, so the collision effect won't work properly. How can I make the Center property follow the parent?
I'm using this to set the Center:
vfx.SetVector3("SphereCenter", collider.ClosestPoint(transform.position));

How do I get the 2d sprite gameObject in front of the UI Canvas?

hierarchy
2d sprite
panel UI
in game
Fist make sure your canvas' Render Mode is not set to Screen Space - Overlay.
If it is, then switch it to Screen Space - Camera and then change its Render Camera property to point to your main camera.
You can then use the following canvas' properties to control where it appears in relation to other sprites (which appears on top of which), the same way you control any other 2D Sprite:
Sorting Layer
Order in Layer
Also worth noting that 2D Sprites with same Sorting Layer and Order in Layer will use the distance to the camera to decide which one appears on top of which, and the same is true for the canvas:
If your canvas' Render Mode is set to Screen Space - Camera, it will always be positioned in front of your camera and you need to use its Plane Distance property in order to position it correctly.
If your canvas' Render Mode is set to World Space, you can position it freely in the world in the same way you position any other sprite.
First of all the hierarchy window in unity is completely irrelevant when its about positioning.
In Unity everything is 3D, even if you switch to 2D perspective.
So in your case you still have your camera, your sprite and your canvas in a 3D Dimension.
To set your sprite in front of the canvas you only need to increase the positioning stats (seen in your "panel UI" screenshot) at least slightly closer to your camera than the canvas is.

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?

How to make Quads flush with each other

I'm making a game where I move a red cube across a plane with arrow keys (I am setting the velocity in order to get a constant speed) Here is a preview:
game
Currently, I am just using a plane with a grid material/texture. However, I wanted to change one of the tiles in this grid to a different color and detect when my cube passes over it.
My idea was to simply replace the plane with a bunch of quads. However, when I do that and try to navigate my cube across the quads, it seems to collide with the side of the quad and flip up, despite the fact that they are all at the same height and positioned right next to each other.
Is there a way to make the quads flush so when I push my cube over it, it won't collide with the side of the quads? Is there a better way to create this behavior?
You can disable colliders at this quads and add invisible big plane with collider