Recent

Author Topic: Video: Procedural Terrain Generation  (Read 5382 times)

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
Video: Procedural Terrain Generation
« on: July 14, 2017, 08:28:02 am »
I've been working on actually finishing Bare Game version 2. This evening I created another example program and thought some of you might want to view it.

It's a procedural terrain generation example. You can view a small screen capture of it at this page:

https://www.getlazarus.org/videos/bareterrain

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: Video: Procedural Terrain Generation
« Reply #1 on: July 14, 2017, 08:36:37 am »
Neat!
Specialize a type, not a var.

turrican

  • Full Member
  • ***
  • Posts: 133
  • Pascal is my life.
    • Homepage
Re: Video: Procedural Terrain Generation
« Reply #2 on: July 14, 2017, 02:27:28 pm »
I've been working on actually finishing Bare Game version 2. This evening I created another example program and thought some of you might want to view it.

It's a procedural terrain generation example. You can view a small screen capture of it at this page:

https://www.getlazarus.org/videos/bareterrain

WTF! Voxel engine??? Awesome and runs very good... What graphics backend are you using? Reminds me to Magic Carpet :)

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
Re: Video: Procedural Terrain Generation
« Reply #3 on: July 14, 2017, 08:19:24 pm »
Update: I added the a "mars" planet style to the example. This new style includes depth of field and atmospheric effects.

https://www.getlazarus.org/videos/bareterrain/#mars

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
Re: Video: Procedural Terrain Generation
« Reply #4 on: July 14, 2017, 08:50:52 pm »
What graphics backend are you using?

The graphics are done using strict OpenGL ES 2.0. My bare game library provides a minimal object oriented library on top of all that.

For example there is a TApplication class to run the game loop and manage windows, TWindow class which you derive from to make your game, TAudio class to play sounds and music, TShaderProgram class to create and run shader programs.

A basic program looks like this:

program terrain;

uses Bare.Game, YourWindowUnit;

begin
  Application.Run(TYourWindow);
end.


To compile and use a shader program, you can use this code:

procedure TYourWindow.RenderInitialize;
begin
  // assumes a folder called shaders, and vert/frag shaders starting with mars
  FYourShader := Shaders.Create('shaders/mars');
  // check if your shaders file has compile errors
  if FYourShader.Valid then
    FYourShader.Push
  else
    WriteLine('Shader failed to compile with error: ' + FYourShader.ErrorString);
end;


I also provide OpenGL like legacy extensions, but I add stacks for everything. That is you can push/pop textures, shader programs, perspective, fonts, vertex buffers and so on. In this way you can chain together rendering, push the things you are modifying saving the previous state, do your thing, and pop those things when you're done.
« Last Edit: July 16, 2017, 07:28:25 pm by sysrpl »

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Video: Procedural Terrain Generation
« Reply #5 on: July 15, 2017, 09:37:43 pm »
This new style includes depth of field and atmospheric effects.
Flying toward the Sun looks pretty nice  8)
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
Re: Video: Procedural Terrain Generation
« Reply #6 on: July 16, 2017, 06:41:02 pm »
Update: I added an alien terrain to the demo.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Video: Procedural Terrain Generation
« Reply #7 on: July 16, 2017, 07:01:03 pm »
Update: I added an alien terrain to the demo.
Nice, alien wind is realistically moving dust around.  8)

It would be good to know CPU/GPU combo used in the demo and to show CPU cores usage next to FPS. I think I have seen a little bug on Mars, where one mountain top was raising up while you were passing it.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

airpas

  • Full Member
  • ***
  • Posts: 179
Re: Video: Procedural Terrain Generation
« Reply #8 on: July 16, 2017, 07:19:11 pm »
very nice engine with elegant design , hope to see android support

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
Re: Video: Procedural Terrain Generation
« Reply #9 on: July 16, 2017, 07:27:59 pm »
It would be good to know CPU/GPU combo used in the demo and to show CPU cores usage next to FPS.
It's not using much CPU at all. Most everything is computed in the shaders procedurally. However if I try to record a video, yeah then the CPU gets a lot of use due to the video encoder running the encoding through libx264 which is software.

On a side note, the past day I've been working on writing an encoder front end for a special build of ffmpeg that uses nvidia cuda when available. I'm debating on whether to publish it, because it really would be a nice multiplatform lazarus app, but I don't want to research building ffmpeg with cuda extensions for mac and windows as well.

Regarding android, none of this stuff will run on android. All the android gpu's I've tested can't handle branching without unrolling the code. This means if you have X itterations in a shader, it increases the code generation by X. In the case of the shaders specific to this demo I loop through 3D texture data and anytime I try glCompileShader on android the programs end up crashing.

Simpler non itterative programs do work with bare game and android. Like I've got a vector graphics super pacman game working on all platforms. It need polishing, but gets great frame rates even though it's all vectors (svg like lines, arcs, shapes, gradient fills).

Edit Just fyi regarding tracking cpu usage, I do have a cpu graph program on my website if anyone is interested. It records up to 1 hour of cpu usage:

https://www.getlazarus.org/apps/cpugraph/
« Last Edit: July 16, 2017, 10:29:21 pm by sysrpl »

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Video: Procedural Terrain Generation
« Reply #10 on: July 17, 2017, 09:17:25 am »
Is there a download link somewhere? I can't find it.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
Re: Video: Procedural Terrain Generation
« Reply #11 on: July 17, 2017, 10:29:08 am »
Is there a download link somewhere? I can't find it.
Version 2 isn't done yet so there's no download. Maybe in a few weeks (4-5?) I'll have a release ready with some demos/tutorials and updated website. If your interested you can look at the V1 documentation. The SDL2 game objects and have changed very little. Most of the changes are related to migrating to GLES and shaders, a new vector drawing engine, native audio support for mod tracker music/dynamic note or sound generation, animation storyboard and other things.

Here's the reference page for the unchanged SDL2 game objects:

http://www.baregame.org/#bare_game

The main window class you define overrides the render and logic methods:

http://www.baregame.org/#!!memberoverview_bare_game_twindow

And the global application class:

http://www.baregame.org/#!!memberoverview_bare_game_tapplication
« Last Edit: July 17, 2017, 10:32:16 am by sysrpl »

turrican

  • Full Member
  • ***
  • Posts: 133
  • Pascal is my life.
    • Homepage
Re: Video: Procedural Terrain Generation
« Reply #12 on: July 17, 2017, 11:44:32 am »
What graphics backend are you using?

The graphics are done using strict OpenGL ES 2.0. My bare game library provides a minimal object oriented library on top of all that.

For example there is a TApplication class to run the game loop and manage windows, TWindow class which you derive from to make your game, TAudio class to play sounds and music, TShaderProgram class to create and run shader programs.

A basic program looks like this:

program terrain;

uses Bare.Game, YourWindowUnit;

begin
  Application.Run(TYourWindow);
end.


To compile and use a shader program, you can use this code:

procedure TYourWindow.RenderInitialize;
begin
  // assumes a folder called shaders, and vert/frag shaders starting with mars
  FYourShader := Shaders.Create('shaders/mars');
  // check if your shaders file has compile errors
  if FYourShader.Valid then
    FYourShader.Push
  else
    WriteLine('Shader failed to compile with error: ' + FYourShader.ErrorString);
end;


I also provide OpenGL like legacy extensions, but I add stacks for everything. That is you can push/pop textures, shader programs, perspective, fonts, vertex buffers and so on. In this way you can chain together rendering, push the things you are modifying saving the previous state, do your thing, and pop those things when you're done.

Awesome! So we are facing one of the best Pascal graphics engine :)

 

TinyPortal © 2005-2018