Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
billboard [2020/01/10 12:21] – [Example: Terrain Grass Billboard] adminbillboard [2020/04/11 14:30] – [Billboard] admin
Line 4: Line 4:
  
 The billboard component is a mesh itself, into which proxies are merged. Much faster rendering is possible if proxy meshes are merge into one mesh, instead of rendering each mesh. The billboard component is a mesh itself, into which proxies are merged. Much faster rendering is possible if proxy meshes are merge into one mesh, instead of rendering each mesh.
 +
 +Restriction: multi-mesh models will be used as multiple source objects and not merged as one object. For example: if you have a model including a cube and sphere mesh, the cube and sphere will be registered as source objects. They will not be handled as single mesh.
  
 We typically use this technique for grass or trees. We typically use this technique for grass or trees.
Line 54: Line 56:
   FGrass := TGorillaBillboard.Create(FGorilla);   FGrass := TGorillaBillboard.Create(FGorilla);
   FGrass .Parent := FGorilla;   FGrass .Parent := FGorilla;
-  FGrass.SourceObject := LBillboard;+  FGrass.AddSourceObject(LBillboard);
   FGrass.MaterialSource := LGrassMat;   FGrass.MaterialSource := LGrassMat;
   FGrass.SetSize(GORILLA_BILLBOARD_SIZE, GORILLA_BILLBOARD_SIZE, GORILLA_BILLBOARD_SIZE);   FGrass.SetSize(GORILLA_BILLBOARD_SIZE, GORILLA_BILLBOARD_SIZE, GORILLA_BILLBOARD_SIZE);
Line 160: Line 162:
   // after usage, it will be destroyed, because it consumes a lot memory   // after usage, it will be destroyed, because it consumes a lot memory
   // and we only need it for the moment   // and we only need it for the moment
-  TMeshDef(FTerrain.Def).AcquireBVH();+  TMeshDef(ATerrain.Def).AcquireBVH();
   try   try
     LChunks := 64;     LChunks := 64;
Line 190: Line 192:
       // place billboard chunk over terrain       // place billboard chunk over terrain
       LGrass.Position.Point := Point3D(LX, 0, LZ);       LGrass.Position.Point := Point3D(LX, 0, LZ);
 +      
 +      // take the template model material source as material for the billboard
 +      // this could be replaced by a grass material shader of course
       LGrass.MaterialSource := FGrassTemps[0].Meshes[0].MaterialSource;       LGrass.MaterialSource := FGrassTemps[0].Meshes[0].MaterialSource;
       FGrassBillboards.Add(LGrass);       FGrassBillboards.Add(LGrass);
  
       // fill up billboard chunk with 64 copies of our grass template       // fill up billboard chunk with 64 copies of our grass template
-      LFillAlg := TGorillaBillboardTerrainFilling.Create(LGrass, FTerrain);+      LFillAlg := TGorillaBillboardTerrainFilling.Create(LGrass, ATerrain);
       try       try
         LFillAlg.Count := 64;         LFillAlg.Count := 64;
Line 203: Line 208:
  
       // we put grass billboard into terrain model       // we put grass billboard into terrain model
-      LGrass.Parent := FTerrain;+      LGrass.Parent := ATerrain;
     end;     end;
   finally   finally
     // at the end we destroy the bounding volume hierarchy again to free memory     // at the end we destroy the bounding volume hierarchy again to free memory
-    TMeshDef(FTerrain.Def).ReleaseBVH();+    TMeshDef(ATerrain.Def).ReleaseBVH();
   end;   end;
 end; end;