Drawing visibility polygons in Unity (for vision cones with occlusion)

You can use a dynamically generated mesh. The points for the mesh can be obtained using one of the techniques described in the links from the comments. Those steps are as follows:

  1. Collect all the objects in your vision cone. This depends on what you’re using for your vision cone and underlying data structure for keeping track of your objects. You could use a collider for your vision cone and maintain a list of objects using OnTriggerEnter and OnTriggerExit, or you could do a Physics.SphereCastAll.
  2. For each object
    1. Get the points that define the object’s collider, or otherwise find the edges of the collider.
    2. For each point
      • Cast a ray from your vision cone source through the point to the edge of your vision cone.
      • Wherever the ray hits, add that point to your mesh.
      • Cast two additional rays +- a small amount to either side of the point. Also add these hit points to your mesh.

The result ends up looking something like this:
enter image description here

Each line is a ray cast and each point is a place where ray cast hit. The points hitting along the center of geometry are rays that were meant for end points farther away, but hit something along the way.

Finally, complete the mesh, fanning out from the center point to each point around the vision cone.

enter image description here

Rendering – Unreal Engine – Occlusion removal doesn't seem to be working properly

I play with environments bought on the market, one of which has a fairly intensive map with many houses and many detailed interiors for the houses. I was under the impression that Unreal allows dynamic occlusion felling by default, but it seems that occluded meshes are still being rendered. See the comparison of "stat initviews" below:

enter description of image here

enter description of image here

There is not much difference in the number of occluded objects (hopefully eliminated) between these two camera views, and my performance is very similar in both. Am I misunderstanding how occlusion is working in the EU, or is it not working right for me? How can I be sure that occluded objects are not returned?

textures – Cooking problems with ambient occlusion


So I did the texture construction using generators which depend on the ambient occulation. However, I just noticed this problem. There are two platforms that are duplicates of each other and rotate. The green box, the ambient occlusion is correct respectively of the pillars. However, in the red, there seems to be a lag. The two meshes share the same material and the same UV. I can solve this problem in 3D software, but can I just replace this mesh? Or are there other solutions?

unit – isometric occlusion slaughter

I am creating a 3D isometric game in Unity using a standard 3D environment with a fixed camera 35 degrees from the horizontal. While the player is outside the buildings, the entire building is visible (which is a fully 3D building model) and when the player enters the building, everything above the ground on which the player is currently will not be visible, the walls closest to the camera will also not be visible. In addition, when the player is outside the building, the inside of the buildings must be obscured.

I have spent the last two days reading about the removal of the frustrum and the bite removal, but there is really not a lot of information about it. subject beyond the basics of shooting things behind the camera. information or tutorials about slaughter areas and slaughter gates seem even more scarce.

Anyone have any tips or advice on how I can get there please.

Here is a photo that I found on the Internet and which shows an example of what I am trying to achieve.
enter description of image here

occlusion – What & # 39; unit curl error 35: Handshake failed. UnityTIs error code: 7 & # 39; means?

j & # 39; uses Occlusion removal to optimize one of the scenes in my game, as i noticed, it started to be a bit late. I have only done this once before with another scene and it didn't take too long or have any problems.

This scene, however, is starting to cause me quite a few problems that I’ve never seen before, either in tutorial or in person (I'm a Dev novice) and I noticed in the console an unusual error:

unity curl error 35: Handshake failed. UnityTIs error code: 7

The other thing too, at the bottom right where it says Auto Generate Lighting On, it has the loading bar and an ETA hour, which started as 9 hours and has now climbed to 11:00 (the previous level showed jobs instead of a timer)

I've just tried to googling the problem to find out what this error actually means, but nothing relevant is to come, and I wanted to ask more experienced developers here who may have already encountered this.

Occlusion – Calculates the occluded parts of a planet-like object

enter the description of the image here

I therefore have the position of the camera (dynamic), the position of the planet (also dynamic), the rays and coordinates of each corner (knot) and I want to hide the side beyond the l & # 39; horizon (with safety margins). I think I could easily calculate in 2D using trigonometry, but in 3D have no idea for the moment. I found code online:

TileNode.prototype.isWithinHorizon = function () {
  var r = this.master.getRadius();
  var camToTile = this.master.getCamToTile(this);
  var camToCenter = this.master.getCamToCenter();

  var camDistToCenter = camToCenter.length();
  var dotCtCc = camToTile.dot(camToCenter.divideScalar(camDistToCenter));

  return dotCtCc - this.scale*0.5 < (camDistToCenter - r*r/camDistToCenter);

but can not understand the meaning, because it is not commented. Any help appreciated!

P.S. I hope that I use the term "occluded" here

unit – How to add an ambient occlusion to a mesh created by script

I've created a point-by-point mesh with a script (a huge mesh), and I'd like to add an ambient occlusion to this mesh.
I'm using Unity 2019.1.6 and the LWRP model.

I've already tested the post-treatment of ambient occlusion unit, but it does not work on any gaming object …
I've been looking for tutorials but on Unity 2019, it's pretty rare.

Do you have any idea how I could do it?

Thank you for your answers.

unit – How do you write an unenlightened shader that supports ambient occlusion?

One approach is to create AO maps in 3D modeling software (example in Blender) and use them in your shader.

Shader "Unlit / UnlitColorAO"
_Color ("Main Color", Color) = (1,1,1,1)
// MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}

_AOTexture ("Texture AO", 2D) = "white" {}
_AOColor ("Color AO", Color) = (1, 1, 1, 1)
_AOPower ("Power of the texture AO", Range (0, 3)) = 0
Tags {"RenderType" = "Opaque"}
LOD 100

#pragma vertex green
#pragma fragment frag

#include "UnityCG.cginc"

uniform sampler2D _AOTexture;
fixed uniform4 _AOTexture_ST;
half uniform3 _AOColor;
half uniform _AOPower;

fixed4 _Color;

static constant half3 whiteColor = half3 (1, 1, 1);

struct appdata
top float4: POSITION;
normal half3: NORMAL;
half3 vColor: COLOR;
float4 uv0: TEXCOORD0;
// float4 uv1: TEXCOORD1;

struct v2f
float4 pos: POSITION;
// float4 worldPos: TEXCOORD0;
// float2 uv: TEXCOORD1;
float2 auv: TEXCOORD4;


sampler2D _MainTex;
float4 _MainTex_ST;

green v2f (appdata v)
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
//o.uv = TRANSFORM_TEX (v.uv0, _MainTex);
o.aouv = TRANSFORM_TEX (v.uv0, _AOTexture);
return o;

fixed4 frag (v2f i): COLOR
// sample the texture
// fixed4 col = tex2D (_MainTex, i.pos) * _ Color;

// color sample only.
fixed4 col = _Color;

// apply AO
half4 AOTexVar = lerp (half4 (_AOColor, 1), half4 (whiteColor, 1), lerp (half4 (1,1,1,1), tex2D (_AOTexture, i.aouv), _AOPower));
col * = AOTexVar;

back collar;