公司
This commit is contained in:
@@ -1,282 +0,0 @@
|
||||
---
|
||||
原文发布链接: https://github.com/Syomus/ProceduralToolkit
|
||||
tags:
|
||||
- 工具包
|
||||
---
|
||||
|
||||
## Toolkit structure
|
||||
### Runtime/
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#runtime)
|
||||
|
||||
- [ArrayE](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/ArrayE.cs): Various Array and List extensions, such as looped getters/setters and flood fills.
|
||||
- [CellularAutomaton](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/CellularAutomaton.cs): Generic cellular automaton for two-state rulesets. Common rulesets can be found in CellularAutomaton.Ruleset.
|
||||
- [ClipperUtility](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/ClipperUtility.cs): Utility class for conversion of Clipper data from and to Unity format.
|
||||
- [ColorE](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/ColorE.cs): Color extensions, HTML colors, Gradient constructors.
|
||||
- [ColorHSV](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/ColorHSV.cs): Serializable representation of color in HSV model.
|
||||
- [CompoundMeshDraft](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/CompoundMeshDraft.cs): Helper class for mesh generation supporting large meshes and submeshes.
|
||||
- [DebugE](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/DebugE.cs): Collection of drawing methods similar to Debug.DrawLine.
|
||||
- [Directions](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Directions.cs): Enum with direction flags along three axes.
|
||||
- [Draw](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Draw.cs): Collection of generic vector drawing algorithms.
|
||||
- [DrawRaster](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/DrawRaster.cs): Collection of generic raster drawing algorithms.
|
||||
- [GizmosE](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/GizmosE.cs): Collection of drawing methods similar to Gizmos.
|
||||
- [GLE](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/GLE.cs): Collection of GL drawing methods similar to Gizmos.
|
||||
- [MeshDraft](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/MeshDraft.cs): Helper class for mesh generation.
|
||||
- [MeshDraftPrimitives](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/MeshDraftPrimitives.cs): Constructors for MeshDraft primitives.
|
||||
- [MeshE](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/MeshE.cs): Mesh extensions.
|
||||
- [PathClipper](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/PathClipper.cs) and [PathOffsetter](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/PathOffsetter.cs): [Clipper](http://www.angusj.com/delphi/clipper.php) library wrappers.
|
||||
- [PTUtils](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/PTUtils.cs): Various useful methods and constants.
|
||||
- [RandomE](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/RandomE.cs): Class for generating random data. Contains extensions for arrays and other collections.
|
||||
- [RendererProperties](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/RendererProperties.cs): Serializable Renderer properties, use Renderer.ApplyProperties extension to apply them to a target renderer.
|
||||
- [Tessellator](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Tessellator.cs): [LibTessDotNet](https://github.com/speps/LibTessDotNet) library wrapper.
|
||||
- [TextureE](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/TextureE.cs): Texture extensions.
|
||||
- [VectorE](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/VectorE.cs): Vector extensions.
|
||||
|
||||
### Runtime/Buildings/
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#runtimebuildings)
|
||||
|
||||
- [BuildingGenerator](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/BuildingGenerator.cs): The main generation class. Generates buildings based on input configuration and strategies, reusable. See examples for details.
|
||||
- [ILayout](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/Interfaces/ILayout.cs), [ILayoutElement](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/Interfaces/ILayoutElement.cs), [IConstructible](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/Interfaces/IConstructible.cs), [Layout](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/Layout.cs), [HorizontalLayout](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/HorizontalLayout.cs), [VerticalLayout](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/VerticalLayout.cs): Interfaces and classes used in facade layout generation.
|
||||
- [IFacadePlanner](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/Interfaces/IFacadePlanner.cs), [IFacadeConstructor](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/Interfaces/IFacadeConstructor.cs), [IRoofPlanner](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/Interfaces/IRoofPlanner.cs), [IRoofConstructor](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/Interfaces/IRoofConstructor.cs): Interfaces for strategies controlling the details of the building generation process.
|
||||
- [FacadePlanner](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/FacadePlanner.cs), [FacadeConstructor](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/FacadeConstructor.cs), [RoofPlanner](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/RoofPlanner.cs), [RoofConstructor](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/RoofConstructor.cs): Serializable wrappers for strategy interfaces.
|
||||
- [ProceduralRoofs](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Buildings/ProceduralRoofs.cs): A collection of roof constructors for the building generator.
|
||||
|
||||
### Runtime/Geometry/
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#runtimegeometry)
|
||||
|
||||
See [this wiki page](https://github.com/Syomus/ProceduralToolkit/wiki/Geometry-algorithms) for a matrix of available algorithms.
|
||||
|
||||
- [Circle2](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Circle2.cs), [Circle3](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Circle3.cs), [Sphere](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Sphere.cs), [Line2](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Line2.cs), [Line3](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Line3.cs), [Segment2](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Segment2.cs), [Segment3](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Segment3.cs): Representations of geometric primitives.
|
||||
- [Geometry](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Geometry.cs): Utility class for computational geometry algorithms, contains various point samplers and helper methods.
|
||||
- [Closest2D](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Closest2D.cs), [Closest3D](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Closest3D.cs): Collection of closest point(s) algorithms.
|
||||
- [Distance2D](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Distance2D.cs), [Distance3D](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Distance3D.cs): Collection of distance calculation algorithms.
|
||||
- [Intersect2D](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Intersect2D.cs), [Intersect3D](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Intersect3D.cs): Collection of intersection algorithms.
|
||||
- [IntersectionType](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/IntersectionType.cs): Enum used in intersection algorithms.
|
||||
- [Intersections](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/Intersections) folder: Structures containing information about intersections.
|
||||
|
||||
### Runtime/Geometry/StraightSkeleton/
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#runtimegeometrystraightskeleton)
|
||||
|
||||
Classes used in [straight skeleton](https://en.wikipedia.org/wiki/Straight_skeleton) generation.
|
||||
|
||||
- [StraightSkeletonGenerator](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/StraightSkeleton/StraightSkeletonGenerator.cs): A straight skeleton generator, computes a straight skeleton for the input polygon, reusable. The generation algorithm is loosely based on the work of Tom Kelly (2014) [Unwritten procedural modeling with the straight skeleton](http://www.twak.co.uk/2014/02/unwritten-procedural-modeling-with.html).
|
||||
- [StraightSkeleton](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/StraightSkeleton/StraightSkeleton.cs): A straight skeleton representation.
|
||||
- [Plan](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Geometry/StraightSkeleton/Plan.cs): Representation of the active plan during generation process.
|
||||
|
||||
### Runtime/ClipperLib/
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#runtimeclipperlib)
|
||||
|
||||
The [Clipper](http://www.angusj.com/delphi/clipper.php) library. Use [PathClipper](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/PathClipper.cs) and [PathOffsetter](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/PathOffsetter.cs) for seamless interoperability with Unity.
|
||||
|
||||
### Runtime/LibTessDotNet/
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#runtimelibtessdotnet)
|
||||
|
||||
The [LibTessDotNet](https://github.com/speps/LibTessDotNet) library. The recommended use is through the wrapper class [Tessellator](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Tessellator.cs).
|
||||
|
||||
### Runtime/FastNoiseLib/
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#runtimefastnoiselib)
|
||||
|
||||
The [FastNoise](https://github.com/Auburns/FastNoise_CSharp) library.
|
||||
|
||||
### Shaders/
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#shaders)
|
||||
|
||||
Depending on the installation type, the shader library can be used like this:
|
||||
|
||||
```hlsl
|
||||
#include "Packages/com.syomus.proceduraltoolkit/Shaders/SDF.cginc"
|
||||
```
|
||||
|
||||
Or like this:
|
||||
|
||||
```hlsl
|
||||
#include "Assets/ProceduralToolkit/Shaders/SDF.cginc"
|
||||
```
|
||||
|
||||
- [Common.cginc](https://github.com/Syomus/ProceduralToolkit/blob/master/Shaders/Common.cginc): Collection of shaping and debug functions.
|
||||
- [Easing.cginc](https://github.com/Syomus/ProceduralToolkit/blob/master/Shaders/Easing.cginc): Normalized easing functions.
|
||||
- [SDF.cginc](https://github.com/Syomus/ProceduralToolkit/blob/master/Shaders/SDF.cginc): Collection of signed distance functions.
|
||||
- [Transitions.cginc](https://github.com/Syomus/ProceduralToolkit/blob/master/Shaders/Transitions.cginc): Collection of transition animations.
|
||||
- [Gradient Skybox](https://github.com/Syomus/ProceduralToolkit/blob/master/Shaders/Gradient%20Skybox.shader): Simple gradient skybox.
|
||||
- [Debug](https://github.com/Syomus/ProceduralToolkit/blob/master/Shaders/Debug) folder: Debug shaders for some of the most common mesh channels.
|
||||
- [VertexColor](https://github.com/Syomus/ProceduralToolkit/blob/master/Shaders/VertexColor) folder: Textureless shaders for use with color information from the vertices.
|
||||
|
||||
### Editor/
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#editor)
|
||||
|
||||
- [ColorHSVDrawer](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Editor/ColorHSVDrawer.cs): PropertyDrawer for ColorHSV.
|
||||
- [MeshFilterExtension](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Editor/MeshFilterExtension.cs): Mesh saving utility available at .`MeshFilter context menu > Save Mesh`
|
||||
- [ProceduralToolkitMenu](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Editor/ProceduralToolkitMenu.cs): Submenu with constructors for primitives at .`GameObject > Procedural Toolkit`
|
||||
- [RulesetDrawer](https://github.com/Syomus/ProceduralToolkit/blob/master/Runtime/Editor/RulesetDrawer.cs): PropertyDrawer for CellularAutomaton.Ruleset.
|
||||
|
||||
### Tests/
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#tests)
|
||||
|
||||
Tests for the library
|
||||
|
||||
## Samples
|
||||
### [Buildings](https://syomus.com/ProceduralToolkit/Buildings)
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#buildings)
|
||||
|
||||
[](https://camo.githubusercontent.com/735315a0fc2e06f029c69819b5458fddd3536a52c746e79c94966945f635243a/68747470733a2f2f73796f6d75732e636f6d2f50726f6365647572616c546f6f6c6b69742f73637265656e73686f742d6275696c64696e67732e706e67)
|
||||
|
||||
A fully procedural building generator, creates an entire mesh from scratch and paints it's vertices. Keep in mind that the generated mesh has no uv map so using it with Standard shader is pointless.
|
||||
|
||||
- BuildingGeneratorComponent: A simple minimal example on how you can use BuildingGenerator
|
||||
- BuildingGeneratorConfigurator: A configurator for BuildingGenerator with UI and editor controls.
|
||||
- BuildingGeneratorReuse: An example on how you can reuse the same generator to generate multiple buildings.
|
||||
- ProceduralFacadePlanner: A facade planning strategy, controls the layouts of the facades.
|
||||
- ProceduralFacadeConstructor: A facade construction strategy, used in conjunction with ProceduralFacadePlanner.
|
||||
- ProceduralRoofPlanner: A roof planning strategy, generates a roof description based on the input config.
|
||||
- ProceduralRoofConstructor: A roof construction strategy, used in conjunction with ProceduralRoofPlanner.
|
||||
- ProceduralFacadeElements: A collection of fully procedural facade panels for the building generator.
|
||||
- PolygonAsset: A ScriptableObject container for vertices.
|
||||
- BuildingGeneratorConfiguratorEditor: A custom inspector for BuildingGeneratorConfigurator.
|
||||
|
||||
### [Chairs](https://syomus.com/ProceduralToolkit/Chairs)
|
||||
|
||||
[](https://camo.githubusercontent.com/26d9a87a3f912a162bda356d8000bcc052798f777f2752fa66450c051618a643/68747470733a2f2f73796f6d75732e636f6d2f50726f6365647572616c546f6f6c6b69742f73637265656e73686f742d6368616972732e706e67)
|
||||
|
||||
A fully procedural chair generator, creates an entire mesh from scratch and paints it's vertices.
|
||||
|
||||
- ChairGenerator: Main generator class. Generates chairs based on input configuration.
|
||||
- ChairGeneratorConfigurator: Configurator for ChairGenerator with UI and editor controls.
|
||||
- ChairGeneratorConfiguratorEditor: Custom inspector for ChairGeneratorConfigurator.
|
||||
- Armrests, Backs, Stretchers: Chair parts constructors.
|
||||
|
||||
### [Low Poly Terrain](https://syomus.com/ProceduralToolkit/LowPolyTerrain)
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#low-poly-terrain)
|
||||
|
||||
[](https://camo.githubusercontent.com/3e29b07fce0d650233b9affb875a556b7671d09d9b553a150992dc505c047b8a/68747470733a2f2f73796f6d75732e636f6d2f50726f6365647572616c546f6f6c6b69742f73637265656e73686f742d6c6f772d706f6c792d7465727261696e2e706e67)
|
||||
|
||||
A simple low poly terrain generator based on fractal noise. Doesn't support chunking or anything like that, just an example of how you can use a noise function in a plane generation algorithm.
|
||||
|
||||
- LowPolyTerrainGenerator: Main generator class. Generates terrain based on input configuration.
|
||||
- LowPolyTerrainExample: Configurator for LowPolyTerrainGenerator with UI and editor controls.
|
||||
- LowPolyTerrainExampleEditor: Custom inspector for LowPolyTerrainExample.
|
||||
|
||||
### [Signed Distance Functions](https://syomus.com/ProceduralToolkit/SDF)
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#signed-distance-functions)
|
||||
|
||||
[](https://camo.githubusercontent.com/311818ba566f2959e4ede0d748979bcfa1b305b761b0aafdedb51e5b848e5ba6/68747470733a2f2f73796f6d75732e636f6d2f50726f6365647572616c546f6f6c6b69742f73637265656e73686f742d7364662e706e67)
|
||||
|
||||
A collection of shaders showing how you can utilise functions from the shader library.
|
||||
|
||||
- StarPolygon: A simple shader that draws a star polygon and shows a difference between "normal" and "cheap" functions.
|
||||
- Shapes: A demonstration of some of the available shapes.
|
||||
- DistanceOperations: A square and a circle combined with different functions.
|
||||
- Easing: All easing functions in one shader showing the ease curve and the easing motion.
|
||||
- Transitions: An example showing the sequencing and animation techniques.
|
||||
- Animation: A more complex example on how you can create patterns and animate them in shader.
|
||||
|
||||
### [Cellular Automata](https://syomus.com/ProceduralToolkit/CellularAutomata)
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#cellular-automata)
|
||||
|
||||
[](https://camo.githubusercontent.com/44f7a508ab234ec52a9d44aa6e3268d7e1fe64da8473399fe9effd126d9565f6/68747470733a2f2f73796f6d75732e636f6d2f50726f6365647572616c546f6f6c6b69742f73637265656e73686f742d63656c6c756c61722d6175746f6d6174612e706e67)
|
||||
|
||||
A demonstration of CellularAutomaton from the main library, draws the automaton simulation on a texture. Note that some of the rulesets need noise value different from the default setting.
|
||||
|
||||
- CellularAutomatonConfigurator: Configurator for the automaton with UI controls.
|
||||
|
||||
### [Mazes](https://syomus.com/ProceduralToolkit/Mazes)
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#mazes)
|
||||
|
||||
[](https://camo.githubusercontent.com/1dcb674041b0050154917acc828ab331eff24fe17d74a64363926805f4a73a02/68747470733a2f2f73796f6d75732e636f6d2f50726f6365647572616c546f6f6c6b69742f73637265656e73686f742d6d617a65732e706e67)
|
||||
|
||||
A generic maze generator, draws the maze generation process on a texture.
|
||||
|
||||
- MazeGenerator: Main generator class. Generates mazes based on input configuration.
|
||||
- MazeGeneratorConfigurator: Configurator for MazeGenerator with UI controls.
|
||||
- Maze: Maze graph representation.
|
||||
|
||||
### [Noise](https://syomus.com/ProceduralToolkit/Noise)
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#noise)
|
||||
|
||||
[](https://camo.githubusercontent.com/a6f5362fe2188bfea2d55c99dcb8e5cfacebdf7b36ab7a1f760e2ba3ff234424/68747470733a2f2f73796f6d75732e636f6d2f50726f6365647572616c546f6f6c6b69742f73637265656e73686f742d6e6f6973652e706e67)
|
||||
|
||||
An example demonstrating various noise types from the [FastNoise](https://github.com/Auburns/FastNoise_CSharp) library.
|
||||
|
||||
### [Breakout](https://syomus.com/ProceduralToolkit/Breakout)
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#breakout)
|
||||
|
||||
[](https://camo.githubusercontent.com/e47c47ac4ed574bc9753587c59feb5274fbdb007b4ef224cabb442e5994a789f/68747470733a2f2f73796f6d75732e636f6d2f50726f6365647572616c546f6f6c6b69742f73637265656e73686f742d627265616b6f75742e706e67)
|
||||
|
||||
A [Breakout](https://en.wikipedia.org/wiki/Breakout_\(video_game\)) clone with procedurally generated levels.
|
||||
|
||||
- Breakout: Game engine and level generator.
|
||||
- BreakoutConfigurator: Configurator for the game with UI controls.
|
||||
- Brick: Disables game object on collision.
|
||||
|
||||
### [Characters](https://syomus.com/ProceduralToolkit/Characters)
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#characters)
|
||||
|
||||
[](https://camo.githubusercontent.com/fa720682ac1cee0566e794e176c567e632c22267c138016805d28b742d6e7f42/68747470733a2f2f73796f6d75732e636f6d2f50726f6365647572616c546f6f6c6b69742f73637265656e73686f742d636861726163746572732e676966)
|
||||
|
||||
A simple 2D character generator. Sprites made by [Kenney](http://kenney.nl/).
|
||||
|
||||
- Character: A container for sprite renderers
|
||||
- CharacterGenerator: Generates a sprite set and a name for character.
|
||||
- CharacterGeneratorConfigurator: Configurator for CharacterGenerator.
|
||||
- NameGenerator: Generates a random name from a large array of names.
|
||||
|
||||
### [Primitives](https://syomus.com/ProceduralToolkit/Primitives)
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#primitives)
|
||||
|
||||
[](https://camo.githubusercontent.com/a14cbae0a0009b6c2be38b5c3605be404902d5d65555a9b1ae01e4d3feb1392a/68747470733a2f2f73796f6d75732e636f6d2f50726f6365647572616c546f6f6c6b69742f73637265656e73686f742d7072696d6974697665732e706e67)
|
||||
|
||||
A demonstration of some of the available MeshDraft primitives.
|
||||
|
||||
- Cylinder, Dodecahedron, FlatSphere, Hexahedron...: Mesh generators that can be configured via the inspector.
|
||||
|
||||
### Drawing
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#drawing)
|
||||
|
||||
Three identical shapes made with three different methods: DebugE, GLE and GizmosE.
|
||||
|
||||
### Clipper
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#clipper)
|
||||
|
||||
A simple example demonstrating the api's of PathClipper and PathOffsetter.
|
||||
|
||||
### Tessellator
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#tessellator)
|
||||
|
||||
An example showing the usage of Tesselator.
|
||||
|
||||
### StraightSkeleton
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#straightskeleton)
|
||||
|
||||
An StraightSkeletonGenerator example showing how you can generate a straight skeleton from a polygon and use the result.
|
||||
|
||||
### Common
|
||||
|
||||
[](https://github.com/Syomus/ProceduralToolkit#common)
|
||||
|
||||
UI prefabs and the skybox material used in examples.
|
||||
|
||||
- SkyBoxGenerator: Skybox generator, assuming that scene uses gradient skybox shader, animates transitions to new parameters every few seconds.
|
||||
- ButtonControl, SliderControl, TextControl, ToggleControl: UI controls for generators.
|
||||
- CameraRotator: Orbiting camera controller.
|
||||
- ConfiguratorBase: Base class for configurators.
|
||||
File diff suppressed because it is too large
Load Diff
2
3Resources/游戏开发/性能优化/卡片/内存碎片如何优化.md
Normal file
2
3Resources/游戏开发/性能优化/卡片/内存碎片如何优化.md
Normal file
@@ -0,0 +1,2 @@
|
||||
- 大对象尽量复用,比如数组,可以在开头就分配好空间
|
||||
- new int\[1000]
|
||||
55
3Resources/游戏开发/性能优化/压缩/ASTC图片压缩.md
Normal file
55
3Resources/游戏开发/性能优化/压缩/ASTC图片压缩.md
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
参考链接: "[ASTC图片压缩技术浅析 - 知乎](https://zhuanlan.zhihu.com/p/1898042738022285491)"
|
||||
参考链接2: "[深入理解ASTC](https://zhuanlan.zhihu.com/p/707250800)"
|
||||
---
|
||||
# 浅析
|
||||
|
||||
### ASTC是什么
|
||||
|
||||
有了上面的简单说明铺垫,接下来正式介绍一下ASTC是什么:
|
||||
ASTC([Adaptive Scalable Texture Compression](https://zhida.zhihu.com/search?content_id=256803808&content_type=Article&match_order=1&q=Adaptive+Scalable+Texture+Compression&zhida_source=entity))是一种高级纹理压缩技术,由 ARM 和 AMD共同开发。其设计目标是提供更高效的压缩率和更高的图像质量,并且支持多种块尺寸和位深度。
|
||||
ASTC的核心优势在于其可变块大小系统,支持从4x4到12x12的任意大小块(包括非正方形块),以及3D纹理的压缩和广泛的硬件支持。这种技术能够适应不同的纹理特征和压缩率需求,从而在保持图像质量的同时,显著减少纹理数据的大小。
|
||||
|
||||
### 常规的压缩方法
|
||||
- **减少颜色数量**:图片是由许多像素组成的,每个像素都有一个颜色值。常规压缩技术会减少颜色的数量,比如把256种颜色减少到16种,然后用这16种颜色来近似原来的颜色。这样,存储颜色信息的数据量就减少了。根据权重算出Block里主要颜色,相似的颜色用这个主要颜色来储存,达到减少颜色的目的。
|
||||
- **去除冗余信息**:图片中往往有很多重复的内容,比如一片蓝色的天空。压缩技术会识别这些重复的部分,只存储一次,然后在需要的地方引用它,这样也能减少数据量。
|
||||
|
||||
### ASTC核心思想
|
||||
- **根据不同区域的特点,灵活地选择压缩方式**
|
||||
- **分块处理**:ASTC把图片分成很多小块,每个小块独立处理。就像把大画分成很多小区域一样,每个小块可以根据自己的内容选择合适的压缩方式。
|
||||
- **自适应性**:对于简单的内容(比如一片纯色的天空),ASTC可以用很少的颜色来表示;对于复杂的内容(比如人物的面部细节),ASTC会用更多的颜色来保持细节。这种自适应性使得ASTC在保持较高图像质量的同时,还能实现较高的压缩率。
|
||||
|
||||
### ASTC压缩算法工作原理
|
||||
- 将这张大图切成很多小块。
|
||||
- ASTC允许我们选择块的大小,比如选择块的大小为4x4,那么512x512的大图就会被切成(512x512)➗(4x4)=16384块。再比如选择块的大小为8x8,512x512的大图就会被切成4096块。
|
||||
- 这里要注意一个点,**ASTC中,无论每个块覆盖的像素数量是多少,大小都固定为128比特(16字节)**。
|
||||
- 选择颜色
|
||||
- 对于已经切割好的每个矩形块,ASTC算法会智能地选择两个颜色端点,来定义这个矩形块里的颜色范围(比如一块天空的颜色主要是浅蓝到深蓝,那么两个端点就是浅蓝色和深蓝色);有时候矩形块里的颜色比较多样,ASTC算法就会使用更多的颜色端点,来代表整个方块的颜色范围。
|
||||
- 颜色渐变
|
||||
- 在选择了颜色端点后,ASTC算法会通过插值计算每个像素的颜色。值插值方法通常是线性的,即根据像素在块内的位置,计算其颜色值在两个端点之间的比例。例如,靠近浅蓝色端点的像素会更接近浅蓝色,而靠近深蓝色端点的像素会更接近深蓝色。
|
||||
- 对于包含许多颜色的块,ASTC则会使用多维插值的方法。例如,如果一个块中有红色、绿色和蓝色的渐变,ASTC会分别在红、绿、蓝三个颜色通道上进行插值,以生成更自然的颜色过渡。
|
||||
- 存储信息
|
||||
- 对于每一个矩形块,记录下它的颜色端点,插值权重以及其他的辅助信息。
|
||||
- 在存储时,还会采用更高效的编码方式来存储这些信息。例如,颜色端点可以使用较少的位数来表示,而插值权重则根据块内颜色的复杂度动态分配位数。这种编码方式确保了数据量的最小化,同时尽可能保留图像的视觉质量。
|
||||
- 除了颜色端点和插值权重,ASTC还会存储一些索引信息,用于快速定位每个像素的颜色值。这些索引信息通常以紧凑的格式存储,进一步减少了数据量。
|
||||
- BISE(Bounded Integer Sequence Encoding)
|
||||
- 这个是ASTC压缩算法里面一个很核心的算法,它的基本原理就是用一串一定范围内数值大的数来表示一串固定数量的数值小的数,Color Endpoint和weight的数据都是用这种方式编码的。
|
||||
- 这里首先抛开ASTC,先把BISE说清楚。举例来说会更清楚:
|
||||
- 比如现在有三个数字需要编码{40,50,70},一般情况下,我们可能想到的使用二进制来编码这三个值,这三个值在128以内,所以,可以每个数用7bit来编码,那么也就是需要21bit位。那这里我们可以用BISE来减少编码的位数,以此来压缩数据量。BISE会把数分为高位和地位,高位使用Trits(三进制)或者Quints(五进制)来表示,多少值范围内的数如何分割表示是有个最佳实践的,这里可以查表来确定,为了简单,这里直接给出例子中的结论,它们是在80(查找表中的固定值)以内的数字,所以使用4bit的Bits表示低位,高位用Quints来表示。那它们的低位就是{101000,110010,1000110},这个直接编码就可以了,高位的值为{2,3,4},然后把这三个值拼到一个大数值上,因为高位用Quints表示的,三位的Quints就能表示125(5*5*5)以内的数字,我们可以用7bit(128)来表示,这样原本要24(3\*8)bit的三个数字就用了4\*3 + 7 = 19bit来表示了。
|
||||
- 解压缩
|
||||
- 当需要在屏幕上显示这张画布时,解压缩算法会读取每个块的压缩数据,恢复颜色端点和插值权重。然后,根据这些信息,通过插值计算每个像素的颜色值,从而重建出原始图像。
|
||||
- 这里需要了解ASTC的一个重要特点:**硬件加速**。现代GPU通常内置了对ASTC解压缩的支持,能够快速高效地解压缩图像数据,从而在不显著增加计算负担的情况下,实现高质量的图像显示。
|
||||
|
||||
### ASTC压缩使用建议
|
||||
目前使用人数比较多的工具是 Arm ASTC Encoder(astcenc)
|
||||
可以从这里获取 [https://github.com/ARM-software/astc-encoder.git](https://link.zhihu.com/?target=https%3A//github.com/ARM-software/astc-encoder.git)
|
||||
其主要的特点有:支持BMP、JPEG、PNG、TGA等多种图像格式;提供多种质量预设;开源
|
||||
在使用ASTC技术时,需要合理选择块大小和平衡视觉质量,以下是一些建议:
|
||||
- 一般情况的合适的块大小
|
||||
- 4×4块:适用于颜色变化复杂或细节丰富的区域,如**法线贴图**或**高精度纹理**。这种块大小可以提供较高的图像质量,但压缩率较低。
|
||||
- 5×5或6×6块:**适合一般的纹理,很多手游都用这个**,能够在质量和压缩率之间取得较好的平衡。
|
||||
- 8×8、10×10、12×12块:适用于尺寸较大但细节要求不高的纹理,如**背景图或大面积的填充纹理**。这些块大小可以显著提高压缩率,但可能会牺牲一些图像质量。
|
||||
- 考虑纹理类型
|
||||
- 法线贴图:建议使用4×4或5×5的块大小,以避免丢失过多细节。
|
||||
- 带Alpha通道的贴图:推荐使用5×5的块大小。
|
||||
- 无Alpha通道的贴图:可以选择8×8的块大小。
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
链接1: https://github.com/killop/anything_about_game
|
||||
链接2: https://github.com/michidk/Unity-Script-Collection
|
||||
链接3: https://github.com/Syomus/ProceduralToolkit
|
||||
tags:
|
||||
- 工具包
|
||||
---
|
||||
|
||||
71
3Resources/游戏开发/算法/前中后序遍历.md
Normal file
71
3Resources/游戏开发/算法/前中后序遍历.md
Normal file
@@ -0,0 +1,71 @@
|
||||
- 前
|
||||
```
|
||||
void Order(tree){
|
||||
print(data);
|
||||
Order(left);
|
||||
Order(right);
|
||||
}
|
||||
```
|
||||
|
||||
- 中
|
||||
```
|
||||
void Order(tree){
|
||||
Order(left);
|
||||
print(data);
|
||||
Order(right);
|
||||
}
|
||||
```
|
||||
|
||||
- 后
|
||||
```
|
||||
void Order(tree){
|
||||
Order(left);
|
||||
Order(right);
|
||||
print(data);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### 1. 前序遍历 (Root-Left-Right)
|
||||
|
||||
- **复制二叉树:** 需要先创建当前根节点,再递归复制其左右子树。前序遍历天然符合这个过程。
|
||||
|
||||
- **获取前缀表达式:** 在表达式树中,前序遍历直接得到前缀表达式(波兰表达式),无需括号即可明确运算顺序,常用于某些计算器或编译器。
|
||||
|
||||
- **序列化二叉树:** 将树结构转化为字符串或字节流以便存储或传输。前序遍历序列化相对直观(常用`#`或`null`表示空节点)。
|
||||
|
||||
- **打印结构化文档/目录树:** 需要先打印当前目录/节点,再打印其子目录/子节点,形成缩进结构。
|
||||
|
||||
- **某些树形UI的渲染:** 有时需要先渲染父组件/节点,再递归渲染其子组件/节点。
|
||||
|
||||
|
||||
### 2. 中序遍历 (Left-Root-Right)
|
||||
|
||||
- **二叉搜索树(BST)的排序输出:** **最重要的应用!** 对BST进行中序遍历,会以升序(从小到大)输出所有节点的值。这是BST的核心特性之一。
|
||||
|
||||
- **获取中缀表达式:** 在表达式树中,中序遍历得到中缀表达式(常见的数学表达式形式)。但需要注意,中序遍历本身不包含括号信息,需要额外处理运算符优先级。
|
||||
|
||||
- **查找BST中的第K小/大元素:** 利用中序遍历的有序性,可以在O(k)时间复杂度(平均)或O(n)(最坏)找到第k小的元素。优化方法(如Morris遍历或记录子树大小)可提高效率。
|
||||
|
||||
- **验证二叉搜索树:** 在中序遍历过程中,检查当前节点值是否**严格大于**前一个访问节点的值。如果不是,则不是有效的BST。
|
||||
|
||||
- **双向链表的转换:** 将BST原地转换成一个按节点值升序排序的双向链表,通常利用中序遍历修改节点指针实现。
|
||||
|
||||
|
||||
### 3. 后序遍历 (Left-Right-Root)
|
||||
|
||||
- **删除二叉树:** 为了安全释放内存,必须先删除左右子树的所有节点,最后才删除根节点本身。后序遍历完美符合这个顺序。
|
||||
|
||||
- **计算节点的高度/深度:** 要计算一个节点的高度(到最深叶子节点的距离),需要先知道其左右子树的高度,取最大值再加1。后序遍历先访问子树,再访问根节点。
|
||||
|
||||
- **计算表达式树的值:** 需要先计算左右子树(子表达式)的值,才能用根节点的运算符对这两个结果进行运算。后序遍历直接得到后缀表达式(逆波兰表达式),非常适合用栈来高效计算。
|
||||
|
||||
- **获取后缀表达式:** 在表达式树中,后序遍历直接得到后缀表达式(逆波兰表达式),无需括号且易于用栈求值。
|
||||
|
||||
- **计算目录/子树大小:** 要计算一个目录(节点)的总大小(包含其所有子目录和文件),必须先计算其所有子目录的大小,然后加上自身文件的大小。后序遍历满足此需求。
|
||||
|
||||
- **判断树/子树的结构或属性:** 许多树的问题(如判断平衡二叉树、计算直径、查找最近公共祖先LCA)需要在递归到某个节点时,已经知道其左右子树的信息(如高度、是否存在目标节点、子树的结果等)。后序遍历提供了这种自底向上的信息传递方式。
|
||||
|
||||
- **释放树/图资源:** 类似于删除,需要先释放子节点资源,再释放父节点资源(如文件句柄、网络连接等)。
|
||||
|
||||
- **某些垃圾回收算法:** 标记-清除等算法在回收内存前,可能需要遍历对象引用图,后序遍历有助于处理依赖关系。
|
||||
Reference in New Issue
Block a user