Jump to content

Addressables


properpixelUK

Recommended Posts

Hello, I am having an issue where I am trying to use addressables, which have been working fine, but If I want to use GTS with these addressables, the GTS Profile never starts applied and I cannot seem to apply it at runtime within a build. 

 

Any help appreciated

Link to comment
Share on other sites

Hi @properpixelUK, we do not have any experience values with GTS and addressables yet, but we will set up an example project to test to see if we can get it working out of the box, or if there are certain pitfalls. Speaking from past experience we found that sometimes not all dependencies for a certain shader / materials are pulled into the addressable package, and are then missing in the build. We will see what we can find out.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

For those having issues with GTS, and Scriptable objects with Addressables.

 

 

I wrote one that uses a Dictionary /List .

 

You need to make references of the SO... 

 

I had to go through alot of trial and error to fix this nonsense for SO's.  and Addressables, Unity made a mess of it...  

 

This is what gave me a better idea and a few other places, I had to research in order to fix this issue.... Real fun, let me tell you....

 

https://bronsonzgeb.com/index.php/2021/09/11/the-scriptable-object-asset-registry-pattern/

 

 

 

But if you are unsure how to do this...

 

 

 

This asset basically does the same thing... Addressables been a real pain in the ass with Scriptable objects which is what GTS uses for its profiles. 

 

I use alot of Scriptable objects myself for all sorts of things...  

 

https://assetstore.unity.com/packages/add-ons/addressables-object-pooling-204192#releases

 

I have not tested, but after finding this, it looks like it fixes this problem..    

 

Or you can do what I did and program it your self. 

  • Like 1
Link to comment
Share on other sites

Thanks @Recon for sharing your insights, I myself experienced a few oddities with addressables where e.g. shaders were not included in the addressable bundle build where they would need to be.

Sorry @properpixelUK and @TCastelo for the lack of updates on this topic - we initially had planned to use GTS and addressables internally in a project, where we could have investigated this along the way, but we ended up not using addressables in the end.
What I did now instead is I created two small example projects, one with Gaia  + GTS installed (source project) and another empty one as a "target" project to see if I can load a catalog build in the source project, and get an unity terrain with GTS on it to load correctly in the editor in the target project, but also in a build made from the target project as well. Goal of this was to investigate if it is possible to load / build a GTS terrain in another project from an addressable bundle without GTS being installed in the project.

For the test I built an empty scene with an unity terrain with a single texture on it


image.png

and applied GTS to it. I set up the Geo feature and snow feature so I could immediately tell whether GTS was applied to this terrain:

image.png

I added the scene to the default group, and set it to build and load into the StreamingAssets folder in the source project.

image.png

After building the addressable bundles I exported the resulting files in the  into the target project. In the target project I loaded the catalog and the source scene and the terrain loads up with the GTS profile on it. I can then also build the scene from a target project and the terrain still appears with GTS on it in a build.

When looking at the asset references in the bundle via the analyze function in the source project, I can see that it seems to pick up GTS and all the required implicit references correctly:


image.png

 

So in this very isolated example it seems that GTS works in a separate project / in a build when part of an addressable bundle without any special requirements. 
I know that this is not the case for you @properpixelUK and @TCastelo, so we would need to find out what the differences are for your projects. As a first step, could you please check within the Addressable Analyze window, if you can see all the dependent GTS assets (shader, material, map textures...) listed as implicit references in there? It would also helpful to know if you are using Gaia to create the addressable group configuration, or if you are setting up the group config yourself like I did in the example above.

 

Link to comment
Share on other sites

5 hours ago, Peter said:

Thanks @Recon for sharing your insights, I myself experienced a few oddities with addressables where e.g. shaders were not included in the addressable bundle build where they would need to be.

Ya Addressables can be tricky, I spent a hours, days, weeks figuring it out..  But I had got it working for my kids project, with SO's., materials, shaders.  

 

That thread there, had helped me among others.  What happens, is they tend to make duplicates of the SO.  So that is one issue, that I had to over come. 

 

For shaders, to work with addressables, I had to add them to a  shared Bundle and Strip variants that your not using.  

 

Alot of people have been struggling with Addressables, mobile it has been x10 worse..  Which is what I been working with, along with a few other Unity users, that I know, that are making mobile games, we been sharing resources, due to how much they been a pain.

 

Peter, make sure shaders are in always include, and make sure your not using different groups.  Not sure if your doing this or tried this yet, but this is some things I had found . That would  not include the shaders. 

 

 

 

I assume you added them to always included?

 

https://docs.unity3d.com/Manual/class-GraphicsSettings.html

 

 

 

 

What Peter shared is a pretty good work around, most of the time some of these programs will be removed anyways, when the user game is built anyways...  

 

Nice share there @Peter

Link to comment
Share on other sites

Thanks @Recon and @Peter

 

I replicated @Peter process and generated two projects. A source one with the gaia terrain and a client just for loading it.

Both projects have Gaia and GTS installed, the only main difference is that I am using the remote build and load process.

 

On the addressable settings I have set up a Remote Build and Load Path 

 

spacer.png

 

Then on Gaia Manager I create the addressable config and build the addressables from that menu.

 

spacer.png

 

When I analyse the addressables all materials and shaders seem to be in the implicit section.

 

Addressables-Analyse.png

 

On the Source project gaia looks like this.

Unity-Editor-Source-Side.png

 

On the inspector, the gaia profile shows in green stating that it is applied.

 

Then I go the the buildPath Folder and run a python server on localhost port 8080

 

 python -m http.server 8080

 

Now on the client side project, I load the catalogue explicitly and then the scene 

 

using System;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.ResourceManagement.AsyncOperations;

public class LoadAddressable : MonoBehaviour
{
	public string gaiaCatalogueName = "http://localhost:8080/catalog_2022.10.03.16.32.01.json";
	public string sceneName = "";
	private void Start()
	{
		LoadTest(gaiaCatalogueName);
	}

	private void LoadTest(string gaiaCatalogueName)
    {
	    LoadCatalogue(
		    gaiaCatalogueName,
		    x =>
		    {
			    if (x.IsDone && x.Status == AsyncOperationStatus.Succeeded)
			    {
				    LoadScene(sceneName);
			    }
		    }
	    );
    }

    private void LoadCatalogue(string catalogueUrl, Action<AsyncOperationHandle<IResourceLocator>> op)
    {
	    var loadContentCatalogAsync =
		    Addressables.LoadContentCatalogAsync(catalogueUrl, true);
	    loadContentCatalogAsync.Completed += op;
    }

    private void LoadScene(string sceneKey)
    {
	    Addressables.LoadSceneAsync(sceneKey);
    }
}

 

On the client side this is what it looks like

Client-Side-Addressables.png

 

On the ispector, When checking the gaia profile it states in red that it is not applied.

 

If I click on apply profile it will show as it should but only until I restart the unity client project.

If restarted it reverts back to not applied.

 

The same happend with the Client build, it will look dark as  it is in the image.

 

@Peter I have these two projects in a repo that I can send you so you can take a look at it and examine it. They don't contain any code other than Gaia and the script I posted here. 

 

Let me know if you wish to take a look.

 

Thanks in advance

 

 

Link to comment
Share on other sites

Hi @TCastelo thanks for the detailed report! This helps us to understand your setup better. From the first look it seems all the necessary data is in the addressable bundles, but there is something wrong with the initial setup of GTS on the terrain when the scenes are loaded in.
I will contact you via DM so you can give me access to the repo, this will be far easier to investigate than messaging back and forth.

  • Like 1
Link to comment
Share on other sites

4 hours ago, TCastelo said:

Thanks @Recon and @Peter

 

I replicated @Peter process and generated two projects. A source one with the gaia terrain and a client just for loading it.

Both projects have Gaia and GTS installed, the only main difference is that I am using the remote build and load process.

 

On the addressable settings I have set up a Remote Build and Load Path 

 

spacer.png

 

Then on Gaia Manager I create the addressable config and build the addressables from that menu.

 

spacer.png

 

When I analyse the addressables all materials and shaders seem to be in the implicit section.

 

Addressables-Analyse.png

 

On the Source project gaia looks like this.

Unity-Editor-Source-Side.png

 

On the inspector, the gaia profile shows in green stating that it is applied.

 

Then I go the the buildPath Folder and run a python server on localhost port 8080

 

 python -m http.server 8080

 

Now on the client side project, I load the catalogue explicitly and then the scene 

 

using System;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.ResourceManagement.AsyncOperations;

public class LoadAddressable : MonoBehaviour
{
	public string gaiaCatalogueName = "http://localhost:8080/catalog_2022.10.03.16.32.01.json";
	public string sceneName = "";
	private void Start()
	{
		LoadTest(gaiaCatalogueName);
	}

	private void LoadTest(string gaiaCatalogueName)
    {
	    LoadCatalogue(
		    gaiaCatalogueName,
		    x =>
		    {
			    if (x.IsDone && x.Status == AsyncOperationStatus.Succeeded)
			    {
				    LoadScene(sceneName);
			    }
		    }
	    );
    }

    private void LoadCatalogue(string catalogueUrl, Action<AsyncOperationHandle<IResourceLocator>> op)
    {
	    var loadContentCatalogAsync =
		    Addressables.LoadContentCatalogAsync(catalogueUrl, true);
	    loadContentCatalogAsync.Completed += op;
    }

    private void LoadScene(string sceneKey)
    {
	    Addressables.LoadSceneAsync(sceneKey);
    }
}

 

On the client side this is what it looks like

Client-Side-Addressables.png

 

On the ispector, When checking the gaia profile it states in red that it is not applied.

 

If I click on apply profile it will show as it should but only until I restart the unity client project.

If restarted it reverts back to not applied.

 

The same happend with the Client build, it will look dark as  it is in the image.

 

@Peter I have these two projects in a repo that I can send you so you can take a look at it and examine it. They don't contain any code other than Gaia and the script I posted here. 

 

Let me know if you wish to take a look.

 

Thanks in advance

 

 

Ya, its losing its references, be sure to pack anything that is a scriptableobject by itself. Don't pack it together. I found that it won't reference it properly or it will lose it.

 

I had forgot about this, Unity as a good video, here  that may help you explain it better too.   This is not showing your set up with remote, but I use remote as well.  I set up my own packs for all of my own SO'S, and made sure to reference them. 

 

 

Now stating this, this is related to SO'S in general.... So, looks like Peter will come up with something to fix the GAIA, GTS issue, I know they use SO'S for profiles, so my guess is, since they use them, its related to these issues. 

 

FYI: This is related to Addressables and SO in general, GAIA is using Unity's so it shouldn't be much different, I personally have not used GAIA's.  

 

I will will need to dig into it soon as it has me curious .  I bet its the same issue though as everyone else having issues with SO's and Addressables though.  Since it seems to always effect them. 

 

 

  • Like 1
Link to comment
Share on other sites

Hi @TCastelo, here is an update on the analysis of your project: I was immediately able to reproduce the issue with your example project. One thing that I noticed was that the materials on the terrain running the GTS shader seem to be missing the control texture.
image.png

This happens during the initialization of the GTS component on the terrain, because it seems that the component looses its reference to the control texture even though the texture is included in the addressable packages correctly. But even when I iron that one out in code, it still shows closer portions of the terrain in black.
What is interesting though is that this seems to affect only the near terrain rendering, when zooming further out the issue seems to disappear.
image.png

I need to analyze this further with the dev team of GTS, I think this has less to do with addressables not including any of the required shaders / assets, but rather with some initialization issue of GTS in this scenario. Since we are able to reproduce it now, we should know more soon.

  • Like 3
Link to comment
Share on other sites

Hi @TCastelo we are one step further in the investigation: The issue is being caused by global shader vector data not being calculated & set correctly on the startup when addressables are being involved. We are working on a solution for this that involves baking / storing the required data separately from the GTS component so it can be reapplied on load in an addressable scenario.
What you can do as a workaround for now is to export the GTS profile from your source project to your target project and apply the profile to an empty dummy terrain before running the scene. This will (pre-) populate the global shader data so the terrains will not show the issue anymore when running the scene. This will not fix the problem in a build, but this would allow you to run the scene in a target project without having to constantly re-apply the profile at least.
We will let you know when the proper fix for this is available.

Link to comment
Share on other sites

Hi @Peter, thanks for keeping us posted.

I see what you mean, I will use that workaround for now.

Please let me now if you can think of a similar build workaround as well.

Link to comment
Share on other sites

Hi @TCastelo @properpixelUK we added a feature in GTS for the runtime initialization without a GTS component as discussed above. We just released an update for GTS that contains this new feature. You can use it the following way:

In the source project, where you create and edit your scenes, click the “Create Runtime Data” button in the new "Runtime Settings" section to create a settings asset containing the runtime Data for the current GTS profile.

image.png

 

In your target project, create an empty game object and attach the “Set Runtime Data” component to it.

image.png

 

Assign the runtime data settings asset you created in the source project in this component. When the scene starts, the required global shader values will be set as soon as the scene starts. I have tested this with the sample projects TCasetelo provided, and with this change I can run and build the target project now with the rendering issues being gone.

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...