Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

What are you working on? (Game Making Thread)

Because I've finished up with university I've got a lot more free time to experiment and test out some ideas.

I've been working on a material loading system and I've also written a new data loader, and today I've managed to get them both working together and drawing a 2D picture.

What I have are materials defined as such:
Code:
type = "solid";

 

shader {

    vertex = "screen.vsh";

    geometry = "screen.gsh";

    fragment = "default.fsh";

}

 

texture0 {

    file = "default.png";

}

 

uniforms {

    uniform_texture0 = 0;

    uniform_alpha = 0.5;

}
The loader will tokenise the file, splitting it by NAME, OPEN_BLOCK, CLOSE_BLOCK, OPERATOR and TERMINATE, it will ignore // markers up until the end of a line and /* markers up until the next */ found (For comments).

Once the tokens have been found the compiler runs over the list; when it finds a name it stores it in a temp buffer, if it then finds an open_block then it creates a new block with the name in the temp buffer, clears the temp buffer and enters the block for adding children.
When it finds the = operator, the stored name becomes a keyword for the current block, it then expects the next name to be a value and converts it to int, double, bool or quoted-string depending on the input string. Every entry ends with a ; termination.

I definitely think this is the way to write file-parsers, my original system did a top-down, single-pass compile but error handling was difficult, because the token system has an expected pattern (Blocks must come after name, end block must close block, operator must have name then a terminate) I am able to report the line that the error happened and describe the error, so large data files can be written and error reported to the developer.

The material system compiles shaders and writes the uniforms for the shaders and loads up to 8 PNG textures with parameters, a Graphics Driver singleton class managers the current active material, so when you change material it will check "Is this material already in use?" if it is, then do nothing, otherwise bind the material's textures and shader. This removes the need for tracking shader and texture bindings (Expensive in OpenGL).

The plan is, build a system that organises objects with no transparency (solids) by material and mesh, so when you draw it the system will only change material and vertex array objects as it needs to, hopefully giving some awesome performance for scenes with many materials and many objects.
 
Holy shit glitch. I have no idea what work goes into minecraft generators but those maps look amazing. (I'm consciously staying away from mc as I know full well how much time I'd end up sinking into it!)
 
Princess Amy":1o2kdod3 said:
Holy shit glitch. I have no idea what work goes into minecraft generators but those maps look amazing. (I'm consciously staying away from mc as I know full well how much time I'd end up sinking into it!)
I don't think very many people understand this kind of terrain generation at all. I've done digging, and there are a few categories that custom minecraft terrain generators fall under:
  • Default terragen with different settings. The big biome mods like Biomes 'O Plenty do this and throw in a bunch of custom blocks and plants.
  • BS custom terrain gen. This includes things like Skygrid (a grid of random blocks with space in between) and Skyblock (a single, tiny, floating island with minimal resources, used as a challenge map.
  • Cool stuff with a very limited range. There are a few that fall in this category, like one of the "biosphere" mods. They make a nice generator but don't understand how to make it independent of anything but map seed and location, and so they pre-populate a list of locations that only goes so many blocks from a central starting point.
  • Legitimately custom terrain generators. All of mine fall under this category, and while there are several others that do, the only publicly available ones that feel "complete" are a pair of generators by the same person. This category is for generators that have the same lack of limits as vanilla minecraft, in terms of how far from spawn you can go before things stop working.

Here are some other examples of stuff I've diddled with in terms of minecraft terrain generation (I'm quoting tumblr posts here):

tumblr_n58hks1iB91svdy6jo5_1280.png

tumblr_n58hks1iB91svdy6jo6_1280.png

tumblr_n58hks1iB91svdy6jo3_1280.png

tumblr_n58hks1iB91svdy6jo8_1280.png

tumblr_n58hks1iB91svdy6jo9_1280.png

tumblr_n58hks1iB91svdy6jo7_1280.png

tumblr_n58hks1iB91svdy6jo10_1280.png

tumblr_n58hks1iB91svdy6jo1_1280.png

tumblr_n58hks1iB91svdy6jo2_1280.png

tumblr_n58hks1iB91svdy6jo4_1280.png


In case it wasn’t painfully obvious by now, this is what I do when I grow bored. I was planning to add “bridges” of a sort to the last generator I showed pictures of, and so here are screenshots taken at three points in their development. I was actually really impressed by the fact that these turned out exactly as I had planned.

This is what happens when I’m bored…

And decide I could waste some time by playing around with terrain generators in minecraft. For those who are curious, this was generated on a Spigot server in 1.6.2 using an API I’m currently designing and fiddling around with. Anyway, now for the pictures:

tumblr_inline_mr5iatgfCp1qz4rgp.png


tumblr_inline_mr5ibbXhu71qz4rgp.png


tumblr_inline_mr5ibl8H2F1qz4rgp.png


tumblr_inline_mr5ibx6hTY1qz4rgp.png


If you’re curious about the lack of anything aside from basic terrain, that’s because all I was fiddling with was basic terrain. I may get around to a bit more differentiation in things like dirt depth eventually, along with things like plants and wildlife, but this is it for now. And if you’re wondering why it’s so strange, the answer is simple: I liked the design, and pushed it a bit further. Even if it isn’t at all realistic. You should have seen some of the other things I came up with while trying to achieve this.

Further Evidence of Boredom

So, I went a bit further with that Minecraft terrain generator, and actually threw in a populator as well. Currently, the populator adds in spruce trees, flowers, mushrooms, pumpkins (with no faces), melons (in a similar fashion to pumpkins), ores, sugar cane, lily pads, tall grass, sheep, wolves, and a customized structure. Anyway, before I continue, here are some more pictures, from approximately the same vantage points:

tumblr_inline_mr6w41KI5i1qz4rgp.png


tumblr_inline_mr6w3gOg6m1qz4rgp.png


tumblr_inline_mr6w4pCSVR1qz4rgp.png


tumblr_inline_mr6w50q9gk1qz4rgp.png


The trees use a custom generator I made that is heavily based on the vanilla spruce generators, but that allows them to be populated much closer together than can be done naturally. The ore veins that spawn use a custom vein generator I coded a month or so ago, that places them in what amounts to a portion of the edge of a bubble. (It also does not spawn iron or gold, because this was originally intended for a multi-world setup where you would be encouraged to work in multiple worlds) The sheep spawn pre-named after a cold-weather variety originally bred in Europe, and will naturally occur in white, black, and two shades of gray. The wolves come pre-named as “Winter Wolves”, due to this world’s original theme being that of a heavily modified wintry landscape. (If you think this biome is fantastical, just wait until you see the one I made before it) The normal hostile mob spawning is disabled for this world, and has been replaced with a custom task that spawns skeletons, zombies, and hostile wolves, all at double their natural maximum HP. For those who are worried, the hostile wolves DO despawn in a similar fashion to normal hostile mobs. As for the structure, that is generated using a custom class, and was probably the most annoying thing I’ve ever programmed. I’ll need to increase its rarity a bit, since they’re spawning too close together.

Just like last time, this map was generated in Minecraft 1.6.2, using a Spigot server and a plugin and API of my design. There have been no changes to the map shown in the picture, that is all exactly what my generator placed via code and randomized variables. Currently, the entire world generates in this fashion, and the chunks can be served fast enough to satisfy a player in creative.

http://www.youtube.com/watch?v=CREgANL5jaI

I was bored, and a friend asked for a screenshot of my mountain generator. So I figured I should go a bit further than that.

tumblr_mvt8r9ZCsW1svdy6jo1_1280.png


tumblr_mvt8r9ZCsW1svdy6jo2_1280.png


tumblr_mvt8r9ZCsW1svdy6jo3_1280.png


tumblr_mvt8r9ZCsW1svdy6jo4_1280.png


tumblr_mvt8r9ZCsW1svdy6jo5_1280.png


tumblr_mvt8r9ZCsW1svdy6jo6_1280.png


tumblr_mvt8r9ZCsW1svdy6jo7_1280.png


tumblr_mvt8r9ZCsW1svdy6jo8_1280.png


tumblr_mvt8r9ZCsW1svdy6jo9_1280.png


tumblr_mvt8r9ZCsW1svdy6jo10_1280.png


So, I was bored and pulled up one of my other Minecraft terrain generation setups. This one is an icy, glacier-covered world, essentially frozen in time. It generates with rather limited resources (no metals, sheep, wolves, hostile wolves, zombies, skeletons, only plant is spruce), and the areas are generically dangerous due to a lack of light. I’m still rather impressed with the fact that I managed to design those ice columns, much less the rest of it. Just to note: this world is completely untouched, from a player perspective. I have not modified a single block post-generation. This was generated using a custom Bukkit plugin, in a recent build of Spigot for Minecraft 1.6.4.

Sadly, that last one's visual effects have been utterly destroyed by the recent update that made it so you can see semitransparent blocks through other semitransparent blocks. It would have been fine, except that ice was given an absolutely terrible shading for the "back" texture, and it makes the glacier look absolutely retarded in the daytime.

The reason I think most people simply don't seem capable of wrapping their heads around Minecraft terrain generation is pretty simple: the last time I took one of those generators and counted the number of "dimensions" my algorithms were working in, I was somewhere near 20 before I stopped. (When I say "dimensions", I'm referring to how many different input variables there are. For example, 3 dimensions would be x, y, and z, but you experience life in four dimensions: x, y, z, and time) Most people have trouble analytically thinking in three or four dimensions, and here I am working in the double digits because I'm bored.
 
http://www.youtube.com/watch?v=zdx28cMw-kU
My experiments have led me to creating this
FPS is 2250 before optimisations, which I'm going to be doing now
 
avarisc":31k5e3hk said:
I'm curious to know the post-opt fps. Looks interesting.
Not much change, 2420 FPS on my 6970HD, this doesn't include culling which I haven't added yet, I've basically optimised away some of the matrix multiplications and made the camera write it's matrices directly to my "graphics driver" class.

I say not much because frame-rate is non-linear, a change in ~200 FPS above 2K FPS is meaningless compared to a 200 FPS change from <= 60.
The target FPS for any of my projects on this machine is 300FPS, so at the moment I'm good.


Here's the scene now (I plugged my shadow mapping code directly into this engine).
http://www.youtube.com/watch?v=lmrMK_I03Iw

In the last video there were 16 cubes in the chain, in this one there are 128 cubes in the chain + 1 floor, then there's camera pivot node, the camera and the shadow camera on the graph. It's around 1,000 FPS, when I reverted back to the original 8 cube scene with shadows (2048x2048 shadow res, 1600x900 screen res) it was around 1,400 FPS so you can tell that shadow mapping costs a fair bit of time.

Here's the drawing code before the animation is performed:
C++:
sceneManager->BuildDrawLists(); // Traverse tree and sort draw-order based on material

 

graphicsDriver->SetRenderTarget( shadowMap, xiGraphicsDriver::CLEAR_DEPTH ); // Target the shadow depth buffer and clear it's depth texture

glViewport( <span style="color: #0000dd;">0, <span style="color: #0000dd;">0, shadowTexture->GetWidth(), shadowTexture->GetHeight() );

glCullFace( GL_FRONT );

sceneManager->SetActiveCamera( shadow ); // Move to shadow's POV

sceneManager->OverrideMaterial( shadowMaterial, xiSceneManager::OVERRIDE_SOLIDS ); // Set all SOLID nodes on the graph to cast a shadow

 

sceneManager->Draw(); // Draw the scene to the buffer

            

Matrix_Mul( &biasShadowProjectionMatrix, shadow->GetViewProjectionMatrix(), &biasMatrix, MAT4 ); // Construct the shadow bias matrix

graphicsDriver->SetMatrix( <span style="color: #666666;">"shadowViewProjection", &biasShadowProjectionMatrix ); // Upload the matrix to the graphics driver

            

graphicsDriver->SetRenderTarget( nullptr, xiGraphicsDriver::CLEAR_ALL ); // Target the default context and clear the colour and depth buffers

glViewport( <span style="color: #0000dd;">0, <span style="color: #0000dd;">0, window->GetIntWidth(), window->GetIntHeight() );

glCullFace( GL_BACK );

sceneManager->SetActiveCamera( camera ); // Move the the main camera's POV

sceneManager->OverrideMaterial( nullptr ); // Reset the material overrides to their defaults

 

sceneManager->Draw(); // Draw the scene to the buffers


What I like about this system is that it is not context-bound, the "window" object you might notice in the above code is an SDL-based context, however once that is setup everything afterwards is raw OpenGL + GLSL, this is even GLES2.0 compliant so it can run on mobile devices if you're willing to re-write the shader sources.


EDIT: Came up with the genius idea of using cameras to override materials, so you can make a camera that is specifically built to do shadows or another camera to show infrared or heat maps or normals, or see through walls, etc.

Pretty handy.
 
deferred_one.png

Deferred renderer now running.

On the left you'll see the buffers that make up this image;
  • Fragment Depth
  • World Normals
  • Shadow Mask
  • Diffuse Colour

The current compositor uses the bottom three buffers; it checks the dot product between the shadow source and the world normals, if it is negative (Pointing towards the light) then it darkens based on the angle of the face (Completely facing the light is brightest, at an angle is slightly darker).

After that, the shadow mask is multiplied in to darken areas that are in shadow, this final colour is mixed with the ambient shadow colour (A tinge of purple) and then that is multiplied with the diffuse map to produce the final scene.


Last of all, the used buffers are drawn around the edge of the screen with a Debug() shader function!
 
I've had an idea for a game again... which isn't a good thing. All I can do is come up with ideas, never execute them past maybe an early demo. I need to finish something.
 

Jason

Awesome Bro

Princess Amy":3usdqy6r said:
I've had an idea for a game again... which isn't a good thing. All I can do is come up with ideas, never execute them past maybe an early demo. I need to finish something.

This is why I decided to just give up entirely... fed up of disappointing myself.
 
I used to have that problem, I believe that getting someone else on board with the idea to motivate each other and have an extra set of hands on it is the best way to resolve it.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top