using System.Collections;
using System.Collections.Generic;
using Godot;
using System;
using System.Threading.Tasks;
namespace Rokojori
{
/**
A node to render foliage.
The GrassPatch has various settings to create a different styles of grass.
It allows to change the shapes of the blades, their number and distribution, their triangle count,
rotation and scale, LOD levels and much more.
*/
[Tool]
[GlobalClass]
public partial class MeshInstanceFoliageData:FoliageData
{
[Export]
public NodePath meshInstanceReference;
public override void Initialize( FoliageRenderLayer renderLayer )
{
var particles = renderLayer.renderer.CreateChild();
renderLayer.gpuParticles3D = particles;
var processMaterial = new GPUFoliageShaderMaterial();
particles.ProcessMaterial = processMaterial;
particles.Lifetime = 0.01f;
particles.Explosiveness = 1f;
particles.FixedFps = 0;
particles.Interpolate = false;
particles.FractDelta = false;
particles.CustomAabb = Box3.WithSize( 10000 );
processMaterial.positionVariance.Set( renderLayer.renderer.noise );
processMaterial.rotationVariance.Set( renderLayer.renderer.noise );
processMaterial.scaleVariance.Set( renderLayer.renderer.noise );
processMaterial.occupancyVariance.Set( renderLayer.renderer.noise );
renderLayer.gpuFoliageShaderMaterial = processMaterial;
var meshInstance = renderLayer.renderer.GetNode( meshInstanceReference ) as MeshInstance3D;
particles.DrawPasses = 1;
particles.DrawPass1 = meshInstance.Mesh;
particles.CastShadow = GeometryInstance3D.ShadowCastingSetting.Off;
}
}
}