Green Instance Renderer – BRG Renderer & Culling System for Unity #11
Replies: 5 comments
Installation
Known limitations & Requirements
Supported Platforms
Usage
Known Issues
As a result, you may occasionally observe on the editor at runtime: |
Main Functions// Create the uploader
PropUploaderID myUploader = AssetGreenRenderer.Instance.Generate( );
// Register mesh for 3 level of details (LOD)
AssetGreenRenderer.Instance.Register ( myUploader, lod0Mesh, isLOD0Lit, lod1Mesh, isLOD1Lit lod2Mesh, isLOD2Lit, limit );
// Set transform data to render instances
AssetGreenRenderer.Instance.Upload ( myUploader, positionsList, rotationsList, scalesList );
// Destroy the Uploader and clean the memory
AssetGreenRenderer.Instance.Unregister ( myUploader );Generate will make an empty uploader and set a culling job. lodXMesh type mesh, meshes will be changed based on the distance from the camera to the instance. |
Update Functions
// Change the visibility state of the instance with the same index to the state passed
AssetGreenRenderer.Instance.Update_State ( myUploader, int index, bool state );
// Change the visibility state of all instances to the state passed
AssetGreenRenderer.Instance.Update_StateAll ( myUploader, bool state );
// From the start, change the visibility state of as many instances to the state passed
AssetGreenRenderer.Instance.Update_StateSource ( myUploader, int[] _source );
AssetGreenRenderer.Instance.Update_StateSource ( myUploader, bool[] _source );
// Update the transform of the instance with the same index as the one passed
AssetGreenRenderer.Instance.Update_Transform ( myUploader, int index, float3 position, float3 rotation, float3 scale );
// Update the transform of as many instances as the length of the position list
AssetGreenRenderer.Instance.Update_Transform ( myUploader, List<float3> allPositions, List<float3> allRotations, List<float3> allScales );
AssetGreenRenderer.Instance.Update_Transform ( myUploader, float3[] allPositions, float3[] allRotations, float3[] allScales );
// Rotation and scale are optional, default values are used if they are not found
// Update the transform of as many instances as the length of the smallest array
AssetGreenRenderer.Instance.Update_TransformRaw ( myUploader, NativeArray<float3> positions, NativeArray<PackedMatrix> objectToWorld, NativeArray<PackedMatrix> worldToObject );
// The positions array will be used on the culling as the instance position while the matrix will be passed to the graphic buffer to update the render positionGetter Functions// Get a list of all instances positions
// Returns a list of type List<float3>
AssetGreenRenderer.Instance.GrabPositions_List ( myUploader );
// Returns a list of type float3[]
AssetGreenRenderer.Instance.GrabPositions_Array ( myUploader );
// Returns a list of type NativeArray<float3>
AssetGreenRenderer.Instance.GrabPositions_NativeArray ( myUploader ); |
Settings Functions
// Set default rotation and scale values
AssetGreenRenderer.Instance.Defaults_Transform ( myUploader, float3 rotation, float3 scale );
// Set a default color, if randomize is enabled, a random color will be set
AssetGreenRenderer.Instance.Defaults_Color ( myUploader, Color color, bool randomize );
// Set a default rim color, if randomize is enabled, a random color will be set
AssetGreenRenderer.Instance.Defaults_Rim ( myUploader, Color color, bool randomize );
// Set a default phase value that will be used as timing on the wind effect, if randomize is enabled all objects will have a different visual timing
AssetGreenRenderer.Instance.Defaults_Phase ( myUploader, float value, bool randomize );
// Set values for the camera culling
AssetGreenRenderer.Instance.Culling_Options ( myUploader, float frustumPlaneRadius, float lod0Distance, float lod1Distance, float cullDistance, int frameSkip );
// Camera and light culling results will be reused for an amount of frames by the value passed to frameSkip
// Set values for the light culling, not needed if shadows are disabled or unlit materials are used
AssetGreenRenderer.Instance.Culling_Shadow ( myUploader, float frustumShadowRadius, float shadowDistance );
// while frustumShadowRadius takes the light frustum, shadowDistance will render shadows from objects on a distance from the camera
// Commands are what is passed on the culling to dictate what to render and what not to
AssetGreenRenderer.Instance.Culling_Commands ( myUploader, int lodLevel, bool shadowCasting, float shadowReceive, bool shadowStaticCaster );
// lodLevel: what LOD(0 to 2) to affect, use a different value to set on all LODs
// shadowCasting: true to make the instance cast shadow which will make the light culling to be called, false to not render shadows
// shadowReceive: a value for the shadow attenuation
// shadowStaticCaster: tells unity if the object's shadow is static, no movement, no mesh deformation
// Add an albedo texture
AssetGreenRenderer.Instance.Material_Albedo ( myUploader, Texture2D albedo, int lod, int submesh );
// Add a normal texture and a strength value
AssetGreenRenderer.Instance.Material_Normal ( myUploader, float value, Texture2D normal, int lod, int submesh );
// Set mask value
AssetGreenRenderer.Instance.Material_Mask ( myUploader, float value, Texture2D mask, int lod, int submesh );
// Set a color to add to the surface and a strength value
AssetGreenRenderer.Instance.Material_Subsurface ( myUploader, float value, Color subsurface, int lod, int submesh );
// Select the color of the shadow to receive
AssetGreenRenderer.Instance.Material_Shadow ( myUploader, Color shadow, int lod, int submesh );
// Alpha clipping
AssetGreenRenderer.Instance.Material_AlphaClipping ( myUploader, float value, int lod, int submesh );
// Wind influence
AssetGreenRenderer.Instance.Material_Wind ( myUploader, float value, int lod, int submesh );
// Rim strength
AssetGreenRenderer.Instance.Material_Rim ( myUploader, float value, int lod, int submesh );
// Brightness
AssetGreenRenderer.Instance.Material_Brightness ( myUploader, float value, int lod, int submesh );
// Contrast
AssetGreenRenderer.Instance.Material_Contrast ( myUploader, float value, int lod, int submesh );
// Saturation
AssetGreenRenderer.Instance.Material_Saturation ( myUploader, float value, int lod, int submesh );
// Dither
AssetGreenRenderer.Instance.Material_Dither ( myUploader, float value, int lod, int submesh );lod: which LOD to affect(0 to 2), different values will add the settings to all LODs |
|
Reserved |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
A lightweight, code-driven GPU instance renderer built on Unity's Batch Renderer Group (BRG).
Green Instance Renderer makes high-performance mesh instancing accessible in just three function calls — no inspector setup, no complex configuration. Register your meshes, upload your transforms, and let the GPU handle the rest.
How It Works
Call Generate to make an uploader, this will return the uploader ID
Call Register with the uploader ID, the max amount of objects to render, the mesh you wish the uploader to use and if it should be Lit or Unlit, it needs 3 mesh for LODs
Call Upload with the ID and the positions you wish to render
That's it. Instances are rendered immediately, with LOD, shadows, and culling handled automatically.
Features
Itchio Link
Test Scenes
https://play.unity.com/en/games/93426df5-29be-4866-ba28-f12866b539ed/instance-re...
https://play.unity.com/en/games/91ddf759-cc33-4bc9-9327-475aaa9c45f1/v134-brg-te...
All reactions