Why seen cross-sections of objects? - unity3d

Why seen cross-sections of objects? I have different meshes on objects with materials (with Standard Shader rendering mode = opaque)
http://prntscr.com/9vt7no
http://prntscr.com/9vt7px

It might be that the backface culling is set wrong (for your meshes). If it is culling front facing triangles while showing the backfacing ones, the effect would be about what you have shown on the pictures.
Either flip the cull mode of your shader, or flip the triangles in your mesh.
For a quick test your can just disable backface culling. If it looks right then, you know that your issue is about the culling.

Related

How to render transparent faces on a cube - unity

I'm trying to make a 3d environment in unity where there are many partially see-through cubes and cuboids. However, right now the cubes look like this:
Where it only shows the faces visible to the camera.
But I want it to show all faces, a bit like this:
Is there any way I can do this in unity? (I don't mind downloading shaders)
The thing you are looking for is called Backface Culling, as explained here: (and in many other places) https://answers.unity.com/questions/1160848/backface-culling-off-for-unlit-transparent-shader.html
place Cull Off in your shader code (possibly ZWrite Off might be useful too)

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.

Parts of mesh become invisible at certian angles Unity3D

I am importing an fbx model but parts of it are invisible in the scene And game at certain angles.
Attached image SS-1 = the full model - You can see that some parts of the mesh are invisible Attached image SS-2 = closeup of an invisible mesh selected
Attached image SS-3 = Main Camera Settings
Attached image SS-4 = Model import settings
Any ideas what's going on?
The normals of your mesh are not set properly, so the culling algorithm treats it as a back-face that should not be rendered.
If you can edit the model so that you can inverse the normals that would work. Most modeling tools have convenient tools or direct routines for "flipping normals". However, if that is not possible, a trick is to change the culling settings from your material: When the culling mode is set to Cull Back (which is the default setting), the polygons that are not facing the camera are not rendered. Then, for the mesh that is not visible, you can change the culling property from Cull Back to Cull Front. This way it will be visible.
The caveat is that most of the time material properties might be overlooked as Cull Front and No Cull settings are not as common as Cull Back. Also, performance-wise, you will have a different shader running because of that mesh.
Try two-sided shader, as suggested here
The easiest solution I found for this problem is:
1.Select the object that's going invisible on certain angles.
2.Navigate to Mesh Renderer > Render Face > Both
The problem should be solved now
My Unity version is 2019.3

Unity3D, Glass Shader, prevent rifts

I'm new to Unity and 3D and currently working on a 3D model of a smartphone. I have a Mesh that uses Standard shader with glass material. This mesh covers all of the surface, and is able to fill in any rifts that exist on the model.
My glass material looks like this:
The properties:
The model:
The problem is that this shader is black, it's covering other elements of the model, like camera, if I remove it, the model will look like this:
which is ok, but you may see that there are little gaps near to the camera, the rifts:
I have no idea how to fill this gaps and use glass shader in the same time.
Also, I cannot use Standard shader, because it doesn't work on mobile devices.
I tried to apply any other Glass Shaders with lower LOD, which seem to work, but the gaps still remain.
Any help is highly appreciated.
Okay, so I played around with the Standard Shader and the main problem you have is that it has no transparency at all. You won't be able to look through it if it has no alpha.
What I did to get results that seemed "okay" is:
I set the rendering mode to Transparent
I set the color to #0024050C
I set the Metallic to 0
I set the Smoothness to 0.9
I kept everything else on default
There may be a comparable version for the Standard (Specular) setup:
Same values as above
Specular to #181818FF
Source to Specular Alpha
And as far as I know, the Standard Shader should work on mobile with some features disabled.

How to achieve Terraria/Starbound 2d lighting?

I am making a 2d game in the perspective of Terraria/Starbound. I want the lighting to look similar to this:
Ive tried to get lighting like this by adding a material on all the sprites in my game and then giving them a sprite diffuse shader. Then I made a point light wherever I needed light. There where two problems with this though: 1) Where the light was most intense, it was draining the color of a sprite and made it lighter. 2) I noticed a big FPS drop (And I only had 1 point light!).
Is there any way of achieving lighting like this without having to write my own lighting engine? Ive search the asset store and Ive searched to see if unity has any way of handing 2D lighting from this angle but I have found nothing.
If I do have to write my own lighting engine, would that be to complex for someone who is relatively new to unity and has only had ~ 8 months experience?
Assume you are using tile map.
You need to have a field of view map, which can be achieved by reading this: http://www.redblobgames.com/articles/visibility/
Using such map, you know exactly the color tinting for each tile. Now, just blend the color to the SpriteRenderer of every tile on the map.
Somebody already created a line of sight plugin:
http://forum.unity3d.com/threads/light-of-sight-2d-dynamic-lighting-open-source.295968/
Here's my hacky solution on GitHub
There's 2 cameras.
Empty tiles on the tilemap are filled in with white blocks (only one camera renders this)
A gaussian blur is applied to the camera rendering the white blocks
Then, blend the two cameras, darkening everything not covered by the white blur.
You can adjust the "light" penetration by changing the white tile's sprite's Pixels Per Unit.