Jump to content

Gena Details Spawner is completely broken


SwenSVK

Recommended Posts

Situation:

I set the spawner to spawn 3 details (rocks and grass) in number of instances between 20 to 30 in radius of 20. In single spawn with 1s interval.
It doesnt reflect any of this - it spawns in like double the radius and it spawns around 1000 of details objects.

On top of this - it is not even spawning what it should. I set it to spawn 2 different rocks and 1 bush. It spawns only 1 type of rock and grass that I did not set to spawn. And one more bonus action - after the spawn all spawn prefabs are set to the grass automatically without me setting anything. But only in the spawner setting. The spawner is actually continuning to spawn that 1 rock and that 1 unwanted grass.

Using unity 2021.3lts, HDRP and GeNa PRO up to date.

I am also using GPU Instancer which imports the prefabs to Terrain Trees and Terrain Details. I believe this can cause the issue.

PS: Using Trees as prefabs in the spawner works fine (at least it seems to). But it doesnt register the trees from the terrains. It only catch the trees you have already spawn at least at once - and that must be on one specific terrain which Gena picks. I dont know how it picks the terrain. From my 9 terrain it takes 1-2 terrain, so basically one in the middle as the one it register the trees. Weird, annoying, but workable. 
Btw. the detail register works in the same way - it picks random terrain you need to spawn details first to even being able to see it in GeNa Spawner.

I believe for the Gena Details spawner there is some erro going on. When I shift click to preview, this red circle appears and stay there.
Accompanied with this error:
Detail index out of bounds in DetailDatabase.SetLayers
UnityEngine.TerrainData:SetDetailLayer (int,int,int,int[,])
GeNa.Core.GeNaMultiTerrainOperation:AddForeignTerrainDetails (int,UnityEngine.RenderTexture,single)
GeNa.Core.TerrainEntity:Perform ()
GeNa.Core.GeNaTerrainDecorator/<OnSelfSpawned>d__10:MoveNext () (at Assets/Tools/Procedural Worlds/GeNa/Scripts/Runtime/Decorators/GeNaTerrainDecorator.cs:51)
GeNa.Core.GeNaSpawnerInternal/GLJPAFFHCKI:MoveNext ()
GeNa.Core.GeNaSpawnerInternal/AKCIBFDGDCM:MoveNext ()
GeNa.Core.GeNaSpawnerInternal/GKBJJEFKLFM:MoveNext ()
GeNa.Core.GeNaManager/APJFKHAOELC:MoveNext ()
GeNa.Core.EditorCoroutine/YieldProcessor:MoveNext (System.Collections.IEnumerator) (at Assets/Tools/Procedural Worlds/GeNa/Scripts/Editor/EditorCoroutines/EditorCoroutine.cs:60)
GeNa.Core.EditorCoroutine:ProcessIEnumeratorRecursive (System.Collections.IEnumerator) (at Assets/Tools/Procedural Worlds/GeNa/Scripts/Editor/EditorCoroutines/EditorCoroutine.cs:106)
GeNa.Core.EditorCoroutine:MoveNext () (at Assets/Tools/Procedural Worlds/GeNa/Scripts/Editor/EditorCoroutines/EditorCoroutine.cs:89)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

 

Can you have a look at it?

Thx.

Ivan

Link to comment
Share on other sites

The RED CIRCLE in Detail Spawner mentioned in first post - I could upload it despite not reaching the limit of 2.9MB - it sasy i can still udd to the video 484Kb, the image is 370kb and it says it is over the limit ...

2022-05-06 10_38_39-Pagan Grounds_v1 - PolanaSmallMap - Windows, Mac, Linux - Unity 2021.3.0f1 Perso-min.png

Link to comment
Share on other sites

  • 3 weeks later...
40 minutes ago, Manny said:

Hey @SwenSVK,

This is something we're very aware of with GeNa. But rest assured, there is actually a significant update to GeNa on the way that fixes the design of this. What's happening here is there is actually a legacy system conflicting with the way the new one works. The new system is supposed to act as a 'brush' similar to Unity's way of painting Terrains but with added 'smart' functionality whereby you can use the Spawn Criteria to paint details, textures and trees to the terrain. The old system used to work similarly by painting various small 1x1 sized 'Paint' operations to the Terrain for all terrain details, textures and trees. But this didn't gel well with the new Undo system as you can see there would be 1000s of Undo stack operations in a single spawn. 

The good news is the new system I've been working on allows us to use both systems without the performance hit. While you're waiting for the new update, there's a workaround but fair warning; it comes at a huge performance cost per spawn:
1. Create a Grass or Detail Spawner the way you normally would.

2. Set the Area of Effect to 1 Unit.

image.png

3. Setup the Spawner Ranges the way you want (eg, 50-100 Spawn Instances, etc).
image.png

4. Perform a spawn.

I will keep you posted on the new update. Thanks for your patience!

Hey Manny,

thank you for your answer here. Good to know it is known problem that is being addressed. Just do you have any ETA when it might be ready to deploy? Weeks or months?

Thank you

Ivan

Link to comment
Share on other sites

  • 4 months later...

@Adam / @Manny hello guys. It has been about 5 months since we talked about this last time and the issue is still in GeNa. None of the updates solved that.

Is that still something you will eventually solve?

Thank you for the update

Ivan

Link to comment
Share on other sites

  • 2 months later...
On 11/30/2022 at 8:13 PM, Manny said:

Hey @SwenSVK,

Could you please confirm if you are still experiencing the same issue with the latest version of GeNa Pro?

I think this is happening to me. I added details to my terrain for both a meadow and a forest. I have a spawner for painting meadow details and it works fine as long as I keep the spawner active in the Inspector. If I click away and then resume the spawner in the Inspector the 3 detail 'grass' selectors change to the first one even though the resource name retains the original selection.

 

After creating a forest spawner (and even making it a subspawner) the selectors for 'grass' detail keep resetting to the first grass detail in the selection for meadow. It is like the index isn't being updated and as soon as I click away from the spawner it changes back to the first (default) detail selection.

 

This is a deal breaker because it is what I hoped to use Gena for and was very excited to get it going.

 

Gena Pro 3.4.0

Link to comment
Share on other sites

  • 11 months later...
On 12/18/2022 at 9:29 AM, ericb said:

I think this is happening to me. I added details to my terrain for both a meadow and a forest. I have a spawner for painting meadow details and it works fine as long as I keep the spawner active in the Inspector. If I click away and then resume the spawner in the Inspector the 3 detail 'grass' selectors change to the first one even though the resource name retains the original selection.

 

After creating a forest spawner (and even making it a subspawner) the selectors for 'grass' detail keep resetting to the first grass detail in the selection for meadow. It is like the index isn't being updated and as soon as I click away from the spawner it changes back to the first (default) detail selection.

 

This is a deal breaker because it is what I hoped to use Gena for and was very excited to get it going.

 

Gena Pro 3.4.0

I met your problem and I know how to fix it.

The problem is due to the fact GeNa Pro currently determines the grass ID by the grass texture, not considering the detail mesh at all. Thus you have to add those logic by yourself. I am willing to share these codes with you, it's not that long.

In GeNaEditorUtility.cs ,please modify add following functions:

//modify follow functions
public static int AddGrassResourceToTerrain(TerrainDetailPrototypeData activeDetailPrototype, Terrain terrain)
{        
.....
	if (activeDetailPrototype.prototypeTexture == null && activeDetailPrototype.prototype!=null)
	{
                    ID = GetGrassID(activeDetailPrototype.prototype,newPrototypes);
                
}
...
}
// add following functions
        /// <summary>
        /// Checks if the grass prototype is already on the terrain.
        /// </summary>
        /// <param name="prefab"></param>
        /// <param name="terrain"></param>
        /// <returns></returns>
        public static bool IsGrassOnTerrain(GameObject prefab, DetailPrototype[] prototypes)
        {
            foreach (DetailPrototype prototype in prototypes)
            {
                if (prototype.prototype == prefab)
                {
                    return true;
                }
            }
            return false;
        }
        public static int GetGrassID(GameObject prefab, DetailPrototype[] prototypes)
        {
            int ID = -1;
            for (int i = 0; i < prototypes.Length; i++)
            {
                if (prototypes[i].prototype == prefab)
                {
                    ID = i;
                    break;
                }
            }
            return ID;
        }

In SpawnerEditor.cs, please modify the function as follows:

/// <summary>
        /// Validates all terrains grass in the spawner
        /// </summary>
        /// <param name="spawner"></param>
        /// <param name="terrain"></param>
        private static void ValidateTerrainGrassPrototypes(GeNaSpawnerData spawner, Terrain terrain)
        {
            if (spawner == null)
            {
                return;
            }
            if (terrain != null)
            {
                List<Prototype> prototypes = spawner.SpawnPrototypes;
                foreach (Prototype prototype in prototypes)
                {
                    IReadOnlyList<Resource> resources = prototype.Resources;
                    foreach (Resource resource in resources)
                    {
                        if (!m_noToAllValidations)
                        {
                            if (resource.ResourceType == Constants.ResourceType.TerrainGrass)
                            {
                                Texture2D grassTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(AssetDatabase.GUIDToAssetPath(resource.AssetID));
                                if (grassTexture == null)
                                {
                                    grassTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(GetAssetPath(resource.Name));
                                }

                                if (grassTexture != null)
                                {
                                  
                                    if (!GeNaEditorUtility.IsGrassOnTerrain(grassTexture, terrain))
                                    {
                                        if (!m_yesToAllValidations)
                                        {
                                            if (EditorUtility.DisplayDialog("Add Resources", "The terrain grasses in this spawner are not found on the terrain. The spawner may not function correctly if the grasses are not on the terrain, we recommend that you add them. Would you like to add them?", "Yes", "No"))
                                            {
                                                m_yesToAllValidations = true;
                                            }
                                            else
                                            {
                                                m_noToAllValidations = true;
                                            }
                                        }
                                        if (m_yesToAllValidations)
                                        {
                                            resource.TerrainProtoIdx = GeNaEditorUtility.AddGrassResourceToTerrain(resource.DetailPrototypeData, terrain);
                                        }
                                    }
                                    else
                                    {
                                        resource.TerrainProtoIdx = GeNaEditorUtility.GetGrassID(terrain.terrainData.detailPrototypes, grassTexture);
                                    }  
                                }
                                else
                                {
                                    GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GUIDToAssetPath(resource.AssetID));
                                    if (prefab == null)
                                    {
                                        prefab = AssetDatabase.LoadAssetAtPath<GameObject>(GetAssetPath(resource.AssetName + "Prefab"));
                                    }
                                    if (!GeNaEditorUtility.IsGrassOnTerrain(prefab, terrain.terrainData.detailPrototypes))
                                    {
                                        if (!m_yesToAllValidations)
                                        {
                                            if (EditorUtility.DisplayDialog("Add Resources", "The terrain grass in this spawner are not found on the terrain. The spawner may not function correctly if the grass are not on the terrain, we recommend that you add them. Would you like to add them?", "Yes", "No"))
                                            {
                                                m_yesToAllValidations = true;
                                            }
                                            else
                                            {
                                                m_noToAllValidations = true;
                                            }
                                        }
                                        if (m_yesToAllValidations)
                                        {
                                            resource.TerrainProtoIdx = GeNaEditorUtility.AddTreeResourceToTerrain(prefab, terrain);
                                        }
                                    }
                                    else
                                    {
                                        resource.TerrainProtoIdx = GeNaEditorUtility.GetGrassID(prefab,terrain.terrainData.detailPrototypes);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

That shall work, hope solves your problem.

BTW, I am not an official of the GeNa Team, just a user of this product.  

I post the code just to help others, hope the GeNa Team shall consider including this fix in a later version.

Link to comment
Share on other sites

On 11/29/2023 at 9:00 AM, Manny said:

Hey @dongfangliu,

Thank you for identifying the issue with GeNa's texture checking and providing a detailed fix. Your insight about the need to consider prefabs alongside textures is invaluable.

I have incorporated your suggested modifications in the upcoming GeNa version (v3.5.5). I greatly appreciate your contribution! 😁

hi, glad to help you.

a new suggestion as follows.

I hate the way Gena Pro does code Obfuscation, this prevents me from tracking bugs on generation. 

I recently went to a situation where the road extension spawner did not generate anything when I just swapped the road start and road end... I try to fix it by myself, but finally missing those obfuscation IL codes. 

Maybe your team should consider releasing some debuggable codes, as we users already paid for the asset.

Link to comment
Share on other sites

58 minutes ago, dongfangliu said:

hi, glad to help you.

a new suggestion as follows.

I hate the way Gena Pro does code Obfuscation, this prevents me from tracking bugs on generation. 

I recently went to a situation where the road extension spawner did not generate anything when I just swapped the road start and road end... I try to fix it by myself, but finally missing those obfuscation IL codes. 

Maybe your team should consider releasing some debuggable codes, as we users already paid for the asset.

OK, now I find what triggered this bug, in my code, I place road nodes on the edge of Terrian.

There's a function to decide whether the spawn target is a terrain,

the strange thing is this function uses the first node of the spline to decide, which is quite unfair.

 

the function GetTarget(out _) In function public void UpdateSpawnCallsGround(List<SpawnCall> spawnCalls) causes this problem.

In my view, I hope the official team could do more logging on the spawn results telling users what happened after their spawn attempt, or else those with no code knowledge will get stuck in a similar situation and leave this asset.

As a programmer, I still find an urgent need to get a version of full source code so that I can solve problems faster instead of messing my head for hours in IDE-decompiled codes.

Link to comment
Share on other sites

as a fix, i comment out the Transform ground = GetTarget(out _); 

and add following codes in the loop:

Transform ground = GetTarget(spawnCall.SpawnedLocation,out _);

 

 

Link to comment
Share on other sites

  • 5 months later...

this bug is still not fixed in the latest version.

On 12/4/2023 at 5:48 PM, dongfangliu said:

as a fix, i comment out the Transform ground = GetTarget(out _); 

and add following codes in the loop:

Transform ground = GetTarget(spawnCall.SpawnedLocation,out _);

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...