Add occlusion culling
This commit is contained in:
parent
76b95bcf67
commit
6dc6297b7b
|
@ -18,3 +18,7 @@ config/icon="res://icon.svg"
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|
||||||
project/assembly_name="Thief Mission Viewer"
|
project/assembly_name="Thief Mission Viewer"
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
occlusion_culling/use_occlusion_culling=true
|
||||||
|
|
|
@ -120,6 +120,8 @@ public partial class Mission : Node3D
|
||||||
idxOffset += poly.VertexCount;
|
idxOffset += poly.VertexCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cellNode = new Node3D();
|
||||||
|
|
||||||
var arrMesh = new ArrayMesh();
|
var arrMesh = new ArrayMesh();
|
||||||
var arrays = new Godot.Collections.Array();
|
var arrays = new Godot.Collections.Array();
|
||||||
arrays.Resize((int)Mesh.ArrayType.Max);
|
arrays.Resize((int)Mesh.ArrayType.Max);
|
||||||
|
@ -133,7 +135,14 @@ public partial class Mission : Node3D
|
||||||
Mesh = arrMesh,
|
Mesh = arrMesh,
|
||||||
CastShadow = GeometryInstance3D.ShadowCastingSetting.On
|
CastShadow = GeometryInstance3D.ShadowCastingSetting.On
|
||||||
};
|
};
|
||||||
AddChild(meshInstance);
|
cellNode.AddChild(meshInstance);
|
||||||
|
|
||||||
|
var occluderInstance = new OccluderInstance3D();
|
||||||
|
var occluder = new ArrayOccluder3D();
|
||||||
|
occluder.SetArrays(vertices.ToArray(), indices.ToArray());
|
||||||
|
occluderInstance.Occluder = occluder;
|
||||||
|
cellNode.AddChild(occluderInstance);
|
||||||
|
|
||||||
|
|
||||||
var r = new Random();
|
var r = new Random();
|
||||||
if (r.NextSingle() > 0.9 && cell.SphereRadius > 5.0)
|
if (r.NextSingle() > 0.9 && cell.SphereRadius > 5.0)
|
||||||
|
@ -143,7 +152,9 @@ public partial class Mission : Node3D
|
||||||
Position = cell.SphereCenter.ToGodotVec3(4.0f),
|
Position = cell.SphereCenter.ToGodotVec3(4.0f),
|
||||||
OmniRange = cell.SphereRadius * (r.NextSingle() + 1.0f) * 0.5f,
|
OmniRange = cell.SphereRadius * (r.NextSingle() + 1.0f) * 0.5f,
|
||||||
};
|
};
|
||||||
AddChild(light);
|
cellNode.AddChild(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddChild(cellNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue