Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] GPU Instancer

Discussion in 'Assets and Asset Store' started by LouskRad, May 3, 2018.

  1. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    571
    Hello there,

    First off I'd like to thank you for updating GPUI to work with URP & HDRP, very cool of you.

    Now I'm encountering a wierd issue when trying to setup GPUI for some relatively low poly trees in a mobile game, using the URP.

    Here's a screenshot of the scene i'm trying to draw using GPUI:
    upload_2020-7-28_17-6-25.png

    Now the profiler:
    On the left is the game rendering trees the usual way through MeshRenderers.
    On the right is the same game/scene etc but with GPUI enabled, with all tree prefabs added to it. (Note that all those trees use the same material using an atlas, dunno if it makes any difference for GPUI)

    upload_2020-7-28_16-48-8.png

    I was expecting worst case to have similar performance, not severly worsened performance :D
    I tried builds with numerous combinations of all available settings, without success so far.

    Any idea what can cause such response on Android builds ?

    Cheers
     
  2. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,866
    @LouskRad , I have almost made the variation buffer shader using Amplify Shader Editor to work with SRP, but with one issue with GPUInstancer generating shader incorrectly. I have sent support email with shaders in question so please take a look at it and get back to me. It's almost there...
     
  3. SinDeSiecle

    SinDeSiecle

    Joined:
    Sep 30, 2017
    Posts:
    38
    Hi, anybody experienced that foliage prefab is rendered at editor but not on build? And how did you solve it? I am using Unity 2020.1 and HDRP 8.2.0. I have the prefabs in addressables system and in another setup, everything renders correctly. In my main setup, when foliage prefabs are to be generated, generation stops.

    EDIT: I just recreated the situation also in edit mode. I turned off the GPUInstancerPrefabManager game object. Foliage did not render, also rendered 2 kinds of objects have uncorrected rotations. This is exactly the same view I get on build. So, can we assume that build does not include or initiate GPUInstancerPrefabManager? Or, disabled after initial loading on build? No warnings in development build, so no clues...

    SOLVED: It was because all my prefabs were addressables. In build, they needed to be unpacked from the archive, and assigned to the prefab manager as prefab prototypes on runtime, and then, instanced via API on runtime.
     
    Last edited: Jul 31, 2020
    LouskRad likes this.
  4. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,866
    @LouskRad , Can you tell me what is the order of rendering per prototype registered in the manager?

    Is it possible to control the order in which it renders the instances per prototype? I can understand it may not be possible to do per instance basis, but I was wondering if it is possible to do it per prototype basis at least.
     
  5. mau_iida

    mau_iida

    Joined:
    Apr 2, 2020
    Posts:
    5
    Hi, we are using URP and GPU Instancer 1.40. I have two issues want to ask.

    • About Shader graph, we have set up "GPU Instancer Setup" node as FAQ ShaderGraph Setup section.
      (using this "GPUInstancer/Extras/GPUI_ShaderGraph_v5.x_or_Later_Node.unitypackage")
      But still has below error, and can't use the material with GPU Instancer.
      How can we keep using GPU Instancer with Shader graph?
    upload_2020-7-31_10-7-17.png

    • Additional Lights.
      We are using a lot of point lights in our scene.
      If we use GPUInstancer, only 8(the number in URP settings) lights which is near to the camera will be on(affect the objects). Is there a way to let all lights on with Instanced objects?
      upload_2020-7-31_12-23-13.png
     
  6. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    833
    This is the related pragma directive that should be in the shader:

    #pragma multi_compile _ LOD_FADE_CROSSFADE

    Yes, it is the intended way to use the Detail Manager with multiple terrains.

    You need to extract the URP_Demos_Package file under the Demos folder.

    Since ASE does not support structured buffers, we can't implement this integration.

    Gaia basically creates Unity terrains. The integration only serves to put quick access buttons to the GX menu. Once you generate your terrains with Gaia / Gaia Pro, you can use GPUI managers as you normally would for any Unity terrain.


    No - since the Single Pass Instanced is an instancing solution itself, they can't work together with GPUI.
    For such fine tuned usage, I would recommend (a) checking the options under the Advanced Actions in the manager and (b) using a no game object workflow where you have no restrictions posed by GameObjects.

    The profiler data shows that your device is GPU bound which kills the performance. I would recommend checking the Best Practices to see how you can optimize this.

    Since GPUI works by taking the load off the CPU and handing it to the GPU, in platforms with limited GPU capabilities, you might get less performance when your device gets GPU bound.

    The draw (DrawMeshInstancedIndirect) calls are made in the order of the prototypes that are defined in the manager. However, Unity handles the actual draw calls behind the scenes when this API is used, so it is not in our control.

    GPUI_ShaderGraph_v5.x_or_Later_Node.unitypackage was added in a version later then GPUI v1.40 and as such would not work in that version (since there are also required script changes). Upgrading GPUI to the latest version from the asset store would solve the issue.

    As for lighting, GPUI does not do anything special about the lighting; so the usual URP shader restrictions still apply when using GPUI.
     
  7. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    833
    Hi everyone,

    I just wanted to let you know that the GPU Instancer team will be on a summer break until September 1st. We will be answering all the questions and support requests after the break.
     
    _met44, julianr and Duffer123 like this.
  8. mau_iida

    mau_iida

    Joined:
    Apr 2, 2020
    Posts:
    5
    Thanks.
    Upgrading GPUI to the latest version broke everything we have made with v1.40..but I will try again.

    Is it possible to have "Material Variations" with Shader graph? And how to do it?
     
  9. prognosist

    prognosist

    Joined:
    Jun 4, 2017
    Posts:
    1
    Hello! Does your solution can be used for several cameras simultaneously?

    We have a really huge world 150/150km and our player has one front view camera, two side view cameras and two back view cameras. So we need to let all instanced objects be seen from all cameras simultaneously.

    But in your tutorials we can see that your plugin can use only one camera at the same time.

    Moreover we have a great amount of turned on and off terrains with VS PRO now but our game play is too heavy and even loading and unloading needed at current time parts of the full world (using world streamer) can't give good results. When we turn off vegetation everything runs fast as we need, but as soon as we turn the vegetation on we have 1-2 fps when small parts are loading. So we need your solution as we understand but we have to understand how it works with several cameras and what will be the size of the scene if we have more than 500k trees now.

    So when we use vs pro it gives us an opportunity to on/of only part of vegetation wich is located on the loaded part of terrains.

    Will it be possible to solve that problem with the help of your plugin and how will it look like?

    And one more problem. We have a huge project on 2018.4 and it is impossible to move to 2019 or later. Is it an unsolvable situation or we can use 2018.4 today?

    Thank you so much
     
    Last edited: Aug 1, 2020
  10. VirtusH

    VirtusH

    Joined:
    Aug 18, 2015
    Posts:
    25
    I've got an issue with shadows not clipping properly, but only when I use GPUInstancer.
    I do not know if GPUInstancer has some incompatibility with the NGSS asset, though I imagine it shouldn't.

    Here I'm using Graphics.DrawMeshInstanced (no lods or anything):
    upload_2020-8-7_16-45-39.png

    Here I've switched to GPUI Gameobject-less:
    upload_2020-8-7_16-46-19.png

    The vegetation shader is a surface shader made with amplify. I've regenerated the GPUI shaders, I've tried everything I could think of.

    Any idea? Thanks!
     
  11. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    55
    I'm new with GPUI and sorry I didn't find my answer in this forum but I was wondering, is it possible to have the prefab always simulated on editor mode with MapMagic 2?

    It is not easy to do level design with this :p

    upload_2020-8-11_19-40-33.png
     
  12. Leniaal

    Leniaal

    Joined:
    Nov 7, 2012
    Posts:
    77
    Absolutely loving the vegetation shader for HDRP. Amazing performance and simply looks great. However there is an issue with it that collides with another one of your features. It doesn't work properly with a floating origin. I'm guessing the wind is calculated in world space, and so if you change origin you can see it happening on the vegetation.

     
  13. SuperSonic68

    SuperSonic68

    Joined:
    Feb 8, 2013
    Posts:
    4
    Getting a weird error out of nowhere when using the Detail Manager: Image attached.
     

    Attached Files:

  14. MatkoSimecki

    MatkoSimecki

    Joined:
    Aug 14, 2020
    Posts:
    1
    Hi,

    Have few problems and I am hoping you can answer them, sorry in advance if this was asked or discussed before.

    So I am currently using the latest LTS HDRP (2019.4.8f1) version and have a problem of actually losing FPS when using GPUI.
    Altho I lost a lot of batches, but I gained more Set pass calls and lost about 10fps. (I instanced 4 terrain tree prefabs that each had around 200 copies in the scene) I am using TVE materials for my assets, all of them have LODs.
    A similar thing happens with scene prefabs, but it's in a higher number of prefabs(around 50). Also using TVE materials, plus some of them having Standard LIT.
    (Most of them have LODs.)

    What I realized also, GPUI Occlusion culling isn't working, and that it renders everything in front of the camera (no matter the distance or the vision obstacle in front of the camera).
    (Frustrum works normally.)
    Compared to now unitys frustum and occlusion culling that works normally.

    So in conclusion, yes I get a lower number of batches (in some cases) but most of the time I don't gain fps, or I just lose a couple of fps, because prefabs are not bein occluded.

    Maybe I missed something in the documentation or the Demo scenes, I don't know. :(

    Thank you.
     

    Attached Files:

    • 1.JPG
      1.JPG
      File size:
      171.7 KB
      Views:
      12
    • 2.JPG
      2.JPG
      File size:
      176.9 KB
      Views:
      10
  15. VirtusH

    VirtusH

    Joined:
    Aug 18, 2015
    Posts:
    25
    Hey again!

    Is the foliage shader in Advanced Foliage Shaders incompatible with GPUI?
    There is a _GPUI version of the shader generated, I've cleared and regenerated that stuff multiple times.
    I even tried stripping down the AFS shader and reconverting it to no avail.

    I realized that the fallback shader is automatically being used, but still cannot figure out why.

    Instead of beautiful vegetation, we're seeing this. Any ideas? upload_2020-8-14_21-37-18.png
     
  16. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    3,827
    Does it work with light probes or lppv?
     
  17. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    55
    It may be linked to the post that I made above, it seems I didn't install MapMagic 2's integration like I should. So I did the work back using the video showing how to install MapMagic2 with GPUI but it seems it still doesn't work because I don't see any vegetation inside GPUI when I click Import.
    I use Biomes inside the main graph, is it possible that GPUI don't see them?

    Edit: Details and object work if I bring them into the main graph, but it doesn't work if I put them inside a biome (which is a graph inside a graph)

    upload_2020-8-16_11-2-56.png
     
  18. mikerz1985

    mikerz1985

    Joined:
    Oct 23, 2014
    Posts:
    75
    Is there any possibility to have GPUI use the DrawMeshInstancedIndirect method with single pass instanced along with LODGroups? Single pass instanced is the only method supported on all platforms with the new XR loader plugin system. WMR only supports single pass instanced and has no plans for anything else. We are temporarily having to switch to Multipass and supporting only openVR and oculus, and will have to stop using this asset due to changes to the VR ecosystem unless there’s a route to supporting single pass instanced...
     
  19. RatBytes

    RatBytes

    Joined:
    Nov 10, 2018
    Posts:
    31
    Hi,
    I created Unity 3D plane Object Prefab (some 100 Instances) .
    I added to the prefab to the Prefab manager.
    However, these prefabs are not rendered during runtime.
    The Component "Mesh Renderer" remains disabled.

    Some other prefabs work fine and are rendered.
     

    Attached Files:

    • ddx.jpg
      ddx.jpg
      File size:
      298.1 KB
      Views:
      14
    Last edited: Aug 18, 2020
  20. MaksimRozanov

    MaksimRozanov

    Joined:
    Apr 19, 2017
    Posts:
    1
    hey there
    got this problem:

    EndLayoutGroup: BeginLayoutGroup must be called first.
    UnityEditor.EditorGUILayout:EndVertical()
    GPUInstancer.GPUInstancerManagerEditor:DrawGPUInstancerPrototypesBox() (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerManagerEditor.cs:409)
    GPUInstancer.GPUInstancerTreeManagerEditor:OnInspectorGUI() (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerTreeManagerEditor.cs:66)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    it happens after i hit button "generate prototypes" in terrain manager
    can you tell how to fix this error?
     
    Last edited: Aug 19, 2020
  21. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    413
    hi

    after import tool i se this:

    Maximum number (256) of shader global keywords exceeded, keyword NORMALSALWAYSUP will be ignored.
    You will have to delete some shaders or make them use less keywords.
    Keywords used in project now: APPLY_FORWARD_FOG ATMOSPHERE_REFERENCE AT_CAMERA_MATERIAL AT_CAMERA_SHADER AT_HUE_VARIATION_OFF AT_HUE_VARIATION_ON AUTO_EXPOSURE BILLBOARD_FACE_CAMERA_POS BLIT_SINGLE_SLICE BLOOM BLOOM_LOW CETO_REFLECTION_ON CETO_UNDERWATER_ON CETO_USE_4_SPECTRUM_GRIDS CETO_USE_OCEAN_DEPTHS_BUFFER CHROMATIC_ABERRATION CHROMATIC_ABERRATION_LOW COLOR_GRADING_HDR COLOR_GRADING_HDR_2D COLOR_GRADING_HDR_3D COLOR_GRADING_LDR_2D DEBUG_DISPLAY DECALS_3RT DECALS_4RT DECALS_OFF DIFFUSE_LIGHTING_ONLY DIRECTIONAL DIRECTIONAL_COOKIE DIRLIGHTMAP_COMBINED DIRLIGHTMAP_OFF DIRLIGHTMAP_SEPARATE DISABLE_TEXTURE2D_X_ARRAY DISTORT DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON EDITOR_VISUALIZATION EFFECT_BILLBOARD EFFECT_BUMP EFFECT_EXTRA_TEX EFFECT_HUE_VARIATION EFFECT_SUBSURFACE ETC1_EXTERNAL_ALPHA FAR_CULL_ON FAST_SIN_ON FINALPASS FOG_EXP FOG_EXP2 FOG_LINEAR FXAA FXAA_KEEP_ALPHA FXAA_LOW GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH GLOW_ON GPU_FRUSTUM_ON GRAIN HIZ_TEXTURE_FOR_BOTH_EYES INSTANCING_ON IS_DRAWPROCEDURALINDIRECT LIGHTMAP_OFF LIGHTMAP_ON LIGHTMAP_SHADOW_MIXING LIGHTPROBE_SH LIGHT_LAYERS LOCAL_SPACE LOD_FADE_CROSSFADE LOD_FADE_PERCENTAGE MATERIAL_QUALITY_HIGH MULTIPASS_VR_ENABLED MULTI_BOUNCE_INDIRECT OUTLINE_ON OUTPUT_SPLIT_LIGHTING POINT POINT_COOKIE PROCEDURAL_INSTANCING_ON RENDER_SUN SHADOWS_CUBE SHADOWS_DEPTH SHADOWS_SCREEN SHADOWS_SHADOWMASK SHADOWS_SINGLE_CASCADE SHADOWS_SOFT SHADOWS_SPLIT_SPHERES SHADOW_HIGH SHADOW_LOW SHADOW_MEDIUM SHADOW_VERY_HIGH SHOW_FEATURE_VARIANTS SHOW_LIGHT_CATEGORIES SINGLEPASS_VR_ENABLED SOFTPARTICLES_ON SOURCE_GBUFFER SPDTREE_HUE_VARIATION SPOT STEREO_CUBEMAP_RENDER_ON STEREO_DOUBLEWIDE_TARGET STEREO_INSTANCING_ENABLED STEREO_INSTANCING_ON STEREO_MULTIVIEW_ON TONEMAPPING_ACES TONEMAPPING_CUSTOM TONEMAPPING_NEUTRAL TOUCH_BEND_ON TRANSPARENT_COLOR_SHADOW UNDERLAY_INNER UNDERLAY_ON UNITY_HDR_ON UNITY_PASS_SHADOWCASTER UNITY_SINGLE_PASS_STEREO UNITY_UI_ALPHACLIP UNITY_UI_CLIP_RECT USE_CLUSTERED_LIGHTLIST USE_FPTL_LIGHTLIST USE_HDWIND USE_MIS USE_NOISE_TEXTURE USE_SNOW VARIANT0 VARIANT1 VARIANT10 VARIANT11 VARIANT12 VARIANT13 VARIANT14 VARIANT15 VARIANT16 VARIANT17 VARIANT18 VARIANT19 VARIANT2 VARIANT20 VARIANT21 VARIANT22 VARIANT23 VARIANT24 VARIANT25 VARIANT26 VARIANT27 VARIANT28 VARIANT3 VARIANT4 VARIANT5 VARIANT6 VARIANT7 VARIANT8 VARIANT9 VERTEXLIGHT_ON VIGNETTE WIND_DISTANCE_CULL_ON WORLD_SPACE WRITE_MSAA_DEPTH WRITE_NORMAL_BUFFER _ADDITIONAL_LIGHTS _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHT_SHADOWS _ALBEDOCONTRIBUTION _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHATEST_ON _BACKFACEMIRRORNORMAL_ON _BENDINGCONTROLS_VERTEX_COLORS_AND_UV4 _BENTNORMALMAP0 _BENTNORMALMAP1 _BENTNORMALMAP2 _BENTNORMALMAP3 _BILLBOARDFACECAMPOS_ON _BLENDMODE_ALPHA _BLENDMODE_PRESERVE_SPECULAR_LIGHTING _COLORMAP _DETAIL_MAP0 _DETAIL_MAP1 _DETAIL_MAP2 _DETAIL_MAP3 _DETAIL_MULX2 _DETALUSEUV3_ON _DISABLE_DBUFFER _DISABLE_DECALS _DISABLE_SSR _DISPLACEMENT_LOCK_TILING_SCALE _DOUBLESIDED_ON _EMISSION _EMISSIVE_COLOR_MAP _ENABLESPECULAROCCLUSION _ENABLE_FOG_ON_TRANSPARENT _GLOSSYREFLECTIONS_OFF _HAS_MOTION_VECTORS _HEATMAP _HEIGHTMAP0 _HEIGHTMAP1 _HEIGHTMAP2 _HEIGHTMAP3 _HEIGHT_BASED_BLEND _INVERTVCOLORMASKSECONDROAD_ON _LIGHTMAPPING_DYNAMIC_LIGHTMAPS _LIGHTMAPPING_REALTIME _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MASKMAP _MASKMAP0 _MASKMAP1 _MASKMAP2 _MASKMAP3 _MATERIAL_FEATURE_CLEAR_COAT _MATERIAL_FEATURE_SUBSURFACE_SCATTERING _MATERIAL_FEATURE_TRANSMISSION _METALLICGLOSSMAP _MIXED_LIGHTING_SUBTRACTIVE _NORMALMAP _NORMALMAP0 _NORMALMAP1 _NORMALMAP2 _NORMALMAP3 _NORMALMAP_TANGENT_SPACE _NORMALMAP_TANGENT_SPACE0 _NORMALMAP_TANGENT_SPACE1 _NORMALMAP_TANGENT_SPACE2 _NORMALMAP_TANGENT_SPACE3 _PARALLAXMAP _REQUIRE_UV3 _SHADOWS_SOFT _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A _SPECGLOSSMAP _SPECULARHIGHLIGHTS_OFF _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP _SPECULAR_OCCLUSION_NONE _SPLATMAP_PREVIEW _SUBSURFACE_MASK_MAP0 _SUBSURFACE_MASK_MAP1 _SUBSURFACE_MASK_MAP2 _SUBSURFACE_MASK_MAP3 _SURFACE_TYPE_TRANSPARENT _TERRAIN_INSTANCED_PERPIXEL_NORMAL _TERRAIN_NORMAL_MAP _TESSELLATION_PHONG _THICKNESSMAP _THICKNESSMAP0 _THICKNESSMAP1 _THICKNESSMAP2 _THICKNESSMAP3 _TOUCHREACTACTIVE_ON _USECURVES_ON _USEDYNAMICSNOWTSTATICMASKF_ON _USESECONDROADALPHA_ON _USESNOW_ON _UVSEC_UV1 _VERTEX_WIND _WETNESS_NONE _WINDQUALITY_BEST _WINDQUALITY_BETTER _WINDQUALITY_FAST _WINDQUALITY_FASTEST _WINDQUALITY_NONE _WINDQUALITY_PALM


    and spam of othed warnings and info text in console
    dont know what is it, but cant stop
    only delete gpu instancer from project can fix this
     
  22. meichen8050753

    meichen8050753

    Joined:
    Jan 16, 2017
    Posts:
    16
    @LouskRad
    if I load scene form assetbundle, and have a particle system in the scene, there has some strange block on screen.
    platform: android
    unity version:2019.4.5f
    happend GPUs: MSM8998, Snapdragon 845, Snapdragon 855.
    project and apk I already sended to support@gurbu.com.
     
    Last edited: Aug 31, 2020
  23. Leniaal

    Leniaal

    Joined:
    Nov 7, 2012
    Posts:
    77
    Just read what it says. Message has nothing to do with GPU instancer, you just have too many global keywords in your project. Here is some more info: https://answers.unity.com/questions/1667795/maximum-number-256-of-shader-global-keywords-excee.html
     
  24. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    413
  25. mikerz1985

    mikerz1985

    Joined:
    Oct 23, 2014
    Posts:
    75
    How do you know you have 130 shader keywords? Unity will also be reserving some global keywords. You can try changing all of your global keywords to local ones.
     
  26. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    413
    got ShaderKeyWord toll for this

    found that problem is local for me. other ppl in project dont see any errors.
    now i need to understand why this happening on my machine only.
     
  27. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    833
    This is currently not supported.

    For a multiple camera setup, you can take a look at this wiki article.

    For best practices when using GPUI (for better performance / visual quality balancing) please take a look at this wiki.

    GPUI does not officially have an integration with World Streamer, but you can manage your streamed terrains per terrain.

    New GPUI versions will always be available for 2019.1 on. They mostly should work in 2018.4, but you might need to manually handle assembly definitions for older versions.

    In most cases, all you need to do is to enable the Shadow with Original Shader feature.

    Real-time editor simulation for MM is currently not supported. It would require controlling the MM2 editor pipeline from GPUI, which is not be an efficient solution.

    Thank you for the feedback. We will look into providing a solution for this.

    This looks like the shader file is inaccessible for some reason. You can try using the
    Tools -> GPU Instancer-> Shaders -> Clear Shader Bindings
    feature and see if it helps.

    It might be the case that one of your screen effects (possibly water, weather, etc.) is not playing well with indirect instancing. I would suggest disabling various effects one by one and testing for the culprit.

    As for occlusion culling, it is a known issue that when you put the game and scene views side by side in the editor in HDRP, the occlusion effect does not show. When displaying the game view only however, occlusion culling is actually working. You can take a look at this wiki F.A.Q. for further info.

    As far as I know, the AFS shaders make use of various Material Property Block updating operations, and it would not work out of the box with GPUI.

    No, they are not supported.

    Thank you for the feedback. We will check the latest biome package updates from MM2 and look into this.

    Unfortunately not. As I mentioned before, GPUI and Single pass instanced are two different instancing solutions and as such are incompatible.

    This might be related to the culling settings in the manager for the plane objects. You can try different values and see if it helps the issue. It is expected that the MeshRenderer component will be disabled when GPUI is rendering the instances.

    We could not reproduce this error. If you can send a support request as mentioned here and we can investigate the issue.
     
  28. DirtyHippy

    DirtyHippy

    Joined:
    Jul 17, 2012
    Posts:
    210
    Hi -

    Once you call RemoveInstancesInsideBounds, how do you restore those instances? Do I need to manually force an update on the cell? Can I somehow get back the matrices removed so I can restore them later manually?

    Also, I'm not sure how the spatial partitioning is working. Do detail cells get pulled from the lossy detail maps on demand as the observer moves (and unloaded as presumably the observer is outside the global detail distance)? Or is the entire terrain front loaded at startup (which might be memory prohibitive)? I ask, because if cells are paged out this has ramifications on if RemoveInstancesInsideBounds will be persistent. I.e. will instances need to be removed again when a cell is reloaded?
     
  29. DirtyHippy

    DirtyHippy

    Joined:
    Jul 17, 2012
    Posts:
    210
    Also, is there a way to bake instances at edit time? I.e. if I wanted to pregen positions/rotations for all prototype instances for a terrain for certain prototypes at edit time so I can stash that meta, is that possible? Looking at the code I suspect it is, but not the way it is currently structured.
     
  30. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    833
    Removal operation is not undo-able, so you need to re-initialize instances if you need to bring them back. If you need a finer control over your instances, you can use a no gameobject workflow for full control over the matrices. As for partitioning, all terrain detail data (the map) is stored in memory at startup, however instances are generated in the GPU.

    Yes, you can use the Serialize Registered Instances feature under Advanced Actions.
     
  31. DirtyHippy

    DirtyHippy

    Joined:
    Jul 17, 2012
    Posts:
    210
    Hi, in this case I am referring to masking out vegetation details for stuff like buildings. I'm assuming all of the detail map stuff already runs off the no-object workflow. I guess my question is there built-in functionality in GPUI to mask out details or do I need to do that manually?
     
  32. visualjoy

    visualjoy

    Joined:
    Aug 23, 2016
    Posts:
    26
    Hi! I recently buy this package and try to use it in my project. The problem is that I have a lot of dynamic unique prefabs, and I need use to make frustum and occlusion culling, and that only makes the fps worse.

    Would it be possible to use several dynamically generated prefabs?

    I'll attach the prints screens to take a look.

    With GPUInstancer:
    WithGPUInstancer.png

    Without GPUInstancer:
    WithoutGPUInstancer.png

    Thanks.
     
  33. TaylorCaudle

    TaylorCaudle

    Joined:
    Feb 8, 2018
    Posts:
    61
    Trying to get this working with Invector Controller,

    Basically I have a bunch of harvestable resources, I'd like to instance the prefabs with the scripts attached (item collection, destroy after collect, etc)

    Is this possible with this asset? Or just the mesh/Collider instancing?
     
  34. xkingjohnx

    xkingjohnx

    Joined:
    Feb 22, 2016
    Posts:
    16
    hi there,
    how can I add the detail manager for terrains in 2019.4.8f1 with HDRP
    I am getting "the current render pipeline does not support detail shaders" when I try to paint on the terrain.
    Is there a workaround for this?

    Many thanks in advance
     
  35. projectorgames_unity

    projectorgames_unity

    Joined:
    Oct 15, 2018
    Posts:
    29
    I did read through this thread, but sadly can't see an answer. I'm using URP and Shader Graph. I've got an extremely simple shader that just displays vertex colour as PBR. Easy. It's applied to a prefab, so GPUI says

    "is created with ShaderGraph, and GPUInstacer Setup is not present. Please copy the shader code and paste it to a new shader file. When you set this new shader to your material, GPUI can run auto-conversion on this shader"

    So I assume this means I click on the shader, I select 'Compile and show code', and then rename the shader and apply it. But this doesn't work in the slightest - Unity can't even compile the shader again, giving errors about TEXTURE_TOK. Is there some step I'm missing to make this work? I honestly can't think of a simpler shader as a test to use! Thanks!

    Edit : And solved!

    "Open the graph, right click the master node and select "Copy shader""
     
    Last edited: Sep 18, 2020
  36. cepoimario280135

    cepoimario280135

    Joined:
    Jan 24, 2020
    Posts:
    6
    It seems that Instancing and raytracing enabled are not working , is this a know issue ?
     
  37. projectorgames_unity

    projectorgames_unity

    Joined:
    Oct 15, 2018
    Posts:
    29
    I'm actually getting this exact issue trying to add ColorVariation into a shader from URP.

    Code (CSharp):
    1. #include "./../../../GPUInstancer/Shaders/Include/GPUInstancerInclude.cginc"
    2.  
    3.             SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
    4.             {
    5.                 uint index = gpuiTransformationMatrix[unity_InstanceID];//Line 166
    6.                 float4 lCol = colorBuffer[index];
    7.  
    8.                 SurfaceDescription surface = (SurfaceDescription)0;
    9.                 float4 _Property_E0B55528_Out_0 = lCol;// colorBuffer;
    I've no idea why it's failing to find the definition, it's clearly at the top of the cginc file.

    Edit : After plastering the file with a huge amount of changes, it's... well, it's broken but compiling. Is there any chance you'll solve the horrible mess than is the URP output code to allow slightly easier addition of VariationBuffers? (Finding whatever random names the URP code has assigned to the Vertex/Frag programs is a nightmare)
     
    Last edited: Sep 22, 2020
  38. Ameng_c

    Ameng_c

    Joined:
    Apr 25, 2019
    Posts:
    7
    Hi there,I use "PrefabsWithoutGameObjects" to make 100x100x100 cubes.It works well when the camera on front or left.But when I move the camera to the right of these cubes,the FPS will drop a lot,and GPU usage will increase.Do you know what's going on here? 1.png 2.png 3.png 5.png 6.png 1.png 2.png 3.png 5.png 6.png
     
  39. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    833
    Yes, as I said earlier you can use the RemoveInstancesInsideBounds API to mask out instances. But there is no built in method to "unmask" them without reinitializing.

    Hi there,

    looks like you are using a high number of prototypes with very low instance counts. You should also be getting warnings in the manager inspector when doing this.

    Basically, GPUI helps you the most in cases where you have a high number of instances of the same prototypes. For more information, you can read up on how GPU Instancing works and what the best practices are for GPUI from this documentation article.

    Hi there,

    GPUI only turns of the Mesh Renderer component of your prefab instances and renders them itself, instead. All your scripts and colliders on the instances are left intact. It also handles the cases where you remove/destroy the instances automatically. So yes, it is possible.

    Unity by default does not support details in HDRP, and shows you that warning. However, since GPUI can render details in HDRP, you can ignore that warning. If your detail is not showing (when using a Detail Manager) you can turn on the simulation mode for the editor.

    However, please note that GPUI is not intended as an editor rendering tool, so editor time simulation for detail painting is a limited workaround since Unity does not support this at all.

    GPUI actually has a shader graph node that you can use as well. You can take a look at the wiki article on it.

    We haven't tried this.

    Well, as you say the problem is the URP shaders. As long as Unity does not provide a surface-shader-like solution for URP, the shader codes are bound to be a mess.

    I can't think of a reason out of the blue, but it might be related to the shadow and lighting setup in your scene. If you can send us a sample project showing this, we can investigate the issue.
     
  40. Ameng_c

    Ameng_c

    Joined:
    Apr 25, 2019
    Posts:
    7
    I uploaded the simple project and a video.I used default lighting and it don't cast shadows.It seems to be about the location of the camera.
     

    Attached Files:

    • test.7z
      File size:
      9.6 MB
      Views:
      7
  41. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    833
    Thank you for the package. Looks like this is related to how the GPU manages the buffer array order while drawing. When you rotate the camera, the instances are processed back to front which the GPU, behind the curtains, seems to manage poorly. Here is a version of your script that shuffles the array randomly - which solves the issue.
     

    Attached Files:

  42. Ameng_c

    Ameng_c

    Joined:
    Apr 25, 2019
    Posts:
    7
    Thank you for your reply.The issume is solved.It's amazing.
     
    LouskRad likes this.
  43. dalbongyi

    dalbongyi

    Joined:
    May 25, 2020
    Posts:
    2
    I am using a custom shader. I know how to change a float value like color or metallic through the color variation demo. But now we want to change the shader's stencil ref value. The shader currently in use is roughly like this. In the case of stencil ref, it is right under pass, so please let me know how to change it.

    Code (CSharp):
    1. // Made with Amplify Shader Editor
    2. // Available at the Unity Asset Store - http://u3d.as/y3X
    3. Shader "GPUInstancer/GPUInstancer/dissolve_test2"
    4. {
    5.     Properties
    6.     {
    7.        
    8.         _OutlineColor("Outline Color", Color) = (0,0,0,1)
    9.        
    10.         [IntRange]_StencilGroup("StencilGroup", Range( 0 , 255)) = 0
    11.         _MainTex("_MainTex", 2D) = "white" {}
    12.         _EmiisonMask("EmiisonMask", 2D) = "white" {}
    13.         [HDR]_EmissionColor("EmissionColor", Color) = (1,1,1,1)
    14.         _MainColor("MainColor", Color) = (1,1,1,1)
    15.         _outlineSize("outlineSize", Float) = 0
    16.         [HideInInspector] _texcoord( "", 2D ) = "white" {}
    17.  
    18.     }
    19.  
    20.         SubShader
    21.     {
    22.         LOD 0
    23.  
    24.         Tags { "RenderType"="Opaque" }
    25.  
    26.         Pass
    27.         {
    28.  
    29.            
    30.            
    31.             Name "Main"
    32.                 CGINCLUDE
    33.                 #pragma target 3.0
    34.                 ENDCG
    35.                 Blend Off
    36.                 Cull Back
    37.                 ColorMask RGBA
    38.                 ZWrite On
    39.                 ZTest LEqual
    40.                 Offset 0 , 0
    41.                 Stencil
    42.                 {
    43.                     Ref [_StencilGroup]
    44.                     Comp Always
    45.                     Pass Replace
    46.                  
    47.  
    48.                 }
    49.                 CGPROGRAM
    50.  
    51.  
    52.               #include "UnityCG.cginc"
    53.               #include "./../../GPUInstancer/Shaders/Include/GPUInstancerInclude.cginc"
    54.               #pragma instancing_options procedural:setupGPUI
    55.               #pragma multi_compile_instancing
    56.               #pragma vertex vert
    57.               #pragma fragment frag
    58.            
    59.                
    60.                
    61.  
    62.                 struct appdata
    63.                 {
    64.                     float4 vertex : POSITION;
    65.                     UNITY_VERTEX_INPUT_INSTANCE_ID
    66.                     float4 ase_texcoord : TEXCOORD0;
    67.                    
    68.                 };
    69.  
    70.                     struct v2f
    71.                     {
    72.                         float4 vertex : SV_POSITION;
    73.                         UNITY_VERTEX_OUTPUT_STEREO
    74.                         UNITY_VERTEX_INPUT_INSTANCE_ID
    75.                             float4 ase_texcoord : TEXCOORD0;
    76.                     };
    77.                    
    78.                     uniform float _StencilGroup;
    79.                     uniform sampler2D _MainTex;
    80.                     uniform float4 _MainTex_ST;
    81.                     uniform float4 _MainColor;
    82.                     uniform sampler2D _EmiisonMask;
    83.                     uniform float4 _EmiisonMask_ST;
    84.                     uniform float4 _EmissionColor;
    85.                     uniform float stencil;
    86.  
    87.                    #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    88.                     StructuredBuffer<float> metallicBuffer;
    89.                    #endif
    90.                 //    UNITY_VERTEX_INPUT_INSTANCE_ID
    91.                 //   #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    92.                 //    _StencilGroup = metallicBuffer[unity_InstanceID];
    93.                 //   #endif      
    94.  
    95.  
    96.                     v2f vert(appdata v )
    97.                     {
    98.                         v2f o = (v2f)0;
    99.                         UNITY_SETUP_INSTANCE_ID(v);
    100.                         UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
    101.                         UNITY_TRANSFER_INSTANCE_ID(v, o);
    102.                         o.ase_texcoord.xy = v.ase_texcoord.xy;
    103.                         float stencil = _StencilGroup;
    104.                         #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    105.                         _StencilGroup = metallicBuffer[gpui_InstanceID];
    106.                         #endif
    107.                         //setting value to unused interpolator channels and avoid initialization warnings
    108.                         o.ase_texcoord.zw = 0;
    109.                        
    110.                         v.vertex.xyz +=  float3(0,0,0) ;
    111.                         o.vertex = UnityObjectToClipPos(v.vertex);
    112.                         return o;
    113.                     }
    114.  
    115.                     fixed4 frag(v2f i ) : SV_Target
    116.                     {
    117.                         UNITY_SETUP_INSTANCE_ID(i);
    118.                        float stencil = _StencilGroup;
    119.                         fixed4 finalColor;
    120.                      
    121.                     float2 uv_MainTex = i.ase_texcoord.xy * _MainTex_ST.xy + _MainTex_ST.zw;
    122.                     float2 uv_EmiisonMask = i.ase_texcoord.xy * _EmiisonMask_ST.xy + _EmiisonMask_ST.zw;
    123.                     float4 temp_output_10_0 = ( tex2D( _EmiisonMask, uv_EmiisonMask ) * _EmissionColor );
    124.                     #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    125.                     _StencilGroup = metallicBuffer[gpui_InstanceID];
    126.                     #endif
    127.  
    128.                     finalColor = ( ( tex2D( _MainTex, uv_MainTex ) * _MainColor ) + temp_output_10_0 );
    129.                     return finalColor;
    130.                 }
    131.                 ENDCG
    132.         }
    133.  
    134.                 Pass
    135.         {
    136.             Cull Front
    137.             Blend Off
    138.  
    139.             Name "Outline"
    140.                     tags{ "LightMode"="ForwardBase" "IgnoreProjectors"="True"}
    141.                     Blend Off
    142.                     ColorMask RGBA
    143.                     ZWrite On
    144.                     ZTest LEqual
    145.                     Offset 0 , 0
    146.                     Stencil
    147.                     {
    148.                         Ref [_StencilGroup]
    149.                         Comp NotEqual
    150.                         Pass Keep
    151.                     }
    152.                     CGPROGRAM
    153. #include "UnityCG.cginc"
    154. #include "./../../GPUInstancer/Shaders/Include/GPUInstancerInclude.cginc"
    155. #pragma instancing_options procedural:setupGPUI
    156. #pragma multi_compile_instancing
    157.                    
    158.                     #pragma target 3.0
    159.                     #pragma vertex vert
    160.                     #pragma fragment frag
    161.                     #include "UnityCG.cginc"
    162.  
    163.                     struct appdata
    164.                     {
    165.                         float4 vertex : POSITION;
    166.                         float3 normal : NORMAL;
    167.                         float4 texcoord : TEXCOORD0;
    168.                         UNITY_VERTEX_INPUT_INSTANCE_ID
    169.                             float4 ase_tangent : TANGENT;
    170.                     };
    171.  
    172.                         struct v2f
    173.                         {
    174.                             float4 vertex : SV_POSITION;
    175.                             float4 texcoord : TEXCOORD0;
    176.                             UNITY_VERTEX_OUTPUT_STEREO
    177.                             UNITY_VERTEX_INPUT_INSTANCE_ID
    178.                                
    179.                         };
    180.  
    181.                             uniform float4 _OutlineColor;
    182.                             uniform float _OutlineWidth;
    183.                             uniform float _StencilGroup;
    184.                             uniform float _outlineSize;
    185.                            
    186.                            
    187.                             #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    188.                             StructuredBuffer<float> metallicBuffer;
    189.                             #endif
    190.  
    191.                            // #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    192.                             //_StencilGroup = metallicBuffer[unity_InstanceID];
    193.                            // #endif      
    194.  
    195.  
    196.                             v2f vert(appdata v )
    197.                             {
    198.                                 v2f o= (v2f)0;
    199.                                 UNITY_SETUP_INSTANCE_ID(v);
    200.                                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
    201.                                 UNITY_TRANSFER_INSTANCE_ID(v, o);
    202.                                 o.texcoord.xy = v.texcoord.xy;
    203.                                 o.texcoord.zw = 0;
    204.                                 float3 MyLocalVar;
    205.                                 //float stencil = _outlineSize;
    206.  
    207.                                // #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    208.                                //_outlineSize = metallicBuffer[unity_InstanceID];
    209.                                // #endif
    210.                                
    211.                                 //setting value to unused interpolator channels and avoid initialization warnings
    212.                                 o.texcoord.zw = 0;
    213.                                 v.vertex.xyz += ( v.ase_tangent.xyz * _outlineSize);
    214.                                 o.vertex = UnityObjectToClipPos(v.vertex);
    215.                                 return o;
    216.                             }
    217.  
    218.                             fixed4 frag(v2f i ) : SV_Target
    219.                             {
    220.                                 UNITY_SETUP_INSTANCE_ID(i);
    221.                             #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    222.                             _StencilGroup = metallicBuffer[gpui_InstanceID];
    223.                              #endif
    224.                                 fixed4 myColorVar;
    225.                             myColorVar = _OutlineColor;
    226.                             return myColorVar;
    227.                         }
    228.                         ENDCG
    229.                     }
    230.  
    231.     }
    232.         CustomEditor "ASEMaterialInspector"
     
  44. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    833
    Hi there,

    it is not possible to change special values like the stencil ref (or ztest, etc. ) without creating a new material. Unity treats those values differently than it treats regular shader properties. For a discussion, you might want to check this forum post:

    https://forum.unity.com/threads/per...ng-materialpropertyblock.403875/#post-4526692
     
  45. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    55
    I have an issue that only happen on runtime via GPU I
    This world is made using MapMagic 2 and The Vegetation Engine's shader, I have been playing with the billboard for a while to try and find a solution and I really can't match the colors of the original trees and the billboard. Any idea?



    upload_2020-9-28_20-17-38.png
     
  46. terricone

    terricone

    Joined:
    Nov 2, 2014
    Posts:
    4
    Hello!
    Is it possible to add and remove runtime detail to terrain only within the required radius?
     
  47. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,104
    @LouskRad , Hi there, wondering whether Nature Renderer AND then GPUI could play nicely (or better) together on any basis. Could I leave GPUI dealing with buildings, rocks and other objects on the terrain and leave NR to deal with terrain detail, grass, veg and trees, if you see what I mean? Would there still be a speed gain?
     
  48. monda

    monda

    Joined:
    May 14, 2015
    Posts:
    22
    Hi, I recently bought it and after just one day my draw calls are dropped from 4000 to 28, everything works on Editor.

    My project reads an image and for every pixel instantiates a prefab, then pics up the color of the corresponding pixels and applies it to the prefab, basically I got a VOXEL version of the picture...it works even with videos.

    The main problem is that on Xiaomi redmi note 7 the material stays black and on a Samsung S8 it doesn't appear at all.

    I've also built the Demo (color variations) and on Xiaiomi the spheres stay red and on Samsung Galaxy S8 they don't appear at all.

    I've checked the build settings from your website and looks all good...what am I doing wrong?

    I'm using Unity 2019.4.10f1 and the latest version of GPUInstancer.
    Thanks!

    EDIT: I've also tried to reduce the instances to 5 (Originally were 4000) just to see if I was asking too much...but the problem it's still there.

    UPDATE: I've removed the color variation and all is fine on both devices, so clearly something is wrong with the shader...is there anything I can do to fix this? The shader doesn't work even with just 5 instances...

    The LOGCAT says this:
    2020/10/03 06:42:54.650 12017 12033 Error Unity GPUI can not define material variations in this platform and/or with this rendering settings.

    On iOS works great with no problems at all!
     
    Last edited: Oct 3, 2020
  49. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    833
    Hi there,

    you can lower the brightness of the baked billboards from the billboard settings for the prototype in the manager. If that still isn't working for you, you can use a custom billboard instead of the generated one (such as an Amplify Impostor, or a custom mesh-material you make).

    You can use the RemoveInstancesInsideCollider API method with a sphere collider to remove them. Adding details at runtime is not supported, if you need that, you can use a no-game object workflow with a prefab manager instead to implement your own solution.

    Yes, if you have many instances of your rocks, buildings, etc. you would gain additional performance while nature renderer is working on your details and trees.

    Hi there,

    Material variations are not supported in Android platforms because of the buffer limitations on the platform. However, if you are using a texture, you could pass that texture to a custom shader and use world position to sample pixel colors for variation.
     
    mick129 likes this.
  50. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,064
    Hello, I'm trying to switch to URP and I'm running into an issue. I have a shader built in amplify, and the auto converter doesn't work if one of my properties is a instanced property. How do I fix this?

    I managed to inject some stuff using amplify, although it takes some manual copying and pasting to get it working, sadly. However, now my colors (that's what is in the StructuredBuffer) are flickering, as if the instance id is incorrect and changing every frame.

    One thing I noticed is my old shaders used gpui_InstanceID, and the new docs say to use unity_InstanceID. Why is this, and could this be the issue?

    EDIT: Ahh I figured it out. I had to move the additional includes the generated version had placed, and then instead of using "unity_InstanceID", use "gpuiTransformationMatrix[unity_InstanceID]".

    Frustrating I have to manually do this every time I change the shader, but at least it runs now
     
    Last edited: Oct 8, 2020
    LouskRad likes this.
unityunity