Comments (4)
Hi,
The background placement Randomizer included with the Perception package uses Poisson disk sampling to select random positions within a given area. In order to make this process more organized, you can modify the corresponding part of the code to have it sample positions in a different manner. To do this, you would first need to create a new background randomizer by copying the code that's already there into a new C# class in your own project. The file is named BackgroundObjectPlacementRandomizer.cs
. Just make sure to change the new class's name and title in the Add Randomizer menu (defined at the top) so that they are different from the stock class.
The part of the code responsible for position sampling and object placement is this:
protected override void OnIterationStart()
{
for (var i = 0; i < layerCount; i++)
{
var seed = SamplerState.NextRandomState();
var placementSamples = PoissonDiskSampling.GenerateSamples(
placementArea.x, placementArea.y, separationDistance, seed);
var offset = new Vector3(placementArea.x, placementArea.y, 0f) * -0.5f;
foreach (var sample in placementSamples)
{
var instance = m_GameObjectOneWayCache.GetOrInstantiate(prefabs.Sample());
instance.transform.position = new Vector3(sample.x, sample.y, separationDistance * i + depth) + offset;
}
placementSamples.Dispose();
}
}
Specifically, the lines that sample positions are:
var placementSamples = PoissonDiskSampling.GenerateSamples(
placementArea.x, placementArea.y, separationDistance, seed);
One thing you could do is to change those lines to have them output a specific order of positions within placementArea
.
Alternately, you could also create complete backgrounds, save them as prefabs, and feed those into the background placement randomizer. With this approach, the background placement randomizer would just have to pick one of your pre-made backgrounds and instantiate it at the same position on each frame. Therefore, the position sampling code would be removed and the position would always be constant.
Let me know if that helps.
from com.unity.perception.
Thank you for the quick response. I'll try this and get back to you.
from com.unity.perception.
Hi,
The background placement Randomizer included with the Perception package uses Poisson disk sampling to select random positions within a given area. In order to make this process more organized, you can modify the corresponding part of the code to have it sample positions in a different manner. To do this, you would first need to create a new background randomizer by copying the code that's already there into a new C# class in your own project. The file is named
BackgroundObjectPlacementRandomizer.cs
. Just make sure to change the new class's name and title in the Add Randomizer menu (defined at the top) so that they are different from the stock class.The part of the code responsible for position sampling and object placement is this:
protected override void OnIterationStart() { for (var i = 0; i < layerCount; i++) { var seed = SamplerState.NextRandomState(); var placementSamples = PoissonDiskSampling.GenerateSamples( placementArea.x, placementArea.y, separationDistance, seed); var offset = new Vector3(placementArea.x, placementArea.y, 0f) * -0.5f; foreach (var sample in placementSamples) { var instance = m_GameObjectOneWayCache.GetOrInstantiate(prefabs.Sample()); instance.transform.position = new Vector3(sample.x, sample.y, separationDistance * i + depth) + offset; } placementSamples.Dispose(); } }Specifically, the lines that sample positions are:
var placementSamples = PoissonDiskSampling.GenerateSamples( placementArea.x, placementArea.y, separationDistance, seed);One thing you could do is to change those lines to have them output a specific order of positions within
placementArea
.Alternately, you could also create complete backgrounds, save them as prefabs, and feed those into the background placement randomizer. With this approach, the background placement randomizer would just have to pick one of your pre-made backgrounds and instantiate it at the same position on each frame. Therefore, the position sampling code would be removed and the position would always be constant.
Let me know if that helps.
This was really helpful. I am new to Unity and I was able to understand what is happening in a better manner.
from com.unity.perception.
Glad to know it helped. I will go ahead and close this issue for now. Feel free to open a new one in case there is anything else to discuss.
from com.unity.perception.
Related Issues (20)
- Depth images in PNG HOT 1
- Perception camera RequestCapture throws Vulkan framebuffer attachment missing error when -runTest uses -batchmode
- Question: Project activity and roadmap HOT 1
- Question: Z option for ForegroundObjectPlacementRandomizer HOT 1
- Inquiry about the Perception Package's Current Status and Future Updates HOT 1
- Failed to get visualizer process ID after lauch
- Running on AWS cloud
- Visualizing Perception datasets with fiftyone HOT 1
- Blurry foreground object HOT 4
- Black Camera Issue HOT 5
- Support IK enabled and AvatarMasks for Animation Randomizer
- Occlusion Labeler for Fisheye Cameras?
- Unity Perception: Semantic Segmentation not capturing whole object
- No depth found HOT 3
- how to add perception camera?
- Unity Terrain not being rendered by the perception camera for semantic segmentation.
- access bounding box information from other script
- Semantic segmentation sky is always black
- 3D object labeler does not work with synthetic human
- Shader error in ":Parse error: syntax error, unexpected TVAL_ID, expecting TOK_SETTEXTURE or '}' at line
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from com.unity.perception.