Month: June 2015

Taking a break from simplex

so instead I worked on tweaking render performance, I wasn’t pushing acceptable framerates and the reason for why is of course that I was pushing almost 7,000 draw calls every frame.
Optimizing that down to 1 gave me these performance metrics:
10k tris (1 draw call) – 60 fps (vsync locked?) (before: 15 fps, 6,864 draw calls)
100k tris (10 draw calls) – 60 fps (before: sub 5 fps, 68,640 draw calls)
1M tris (100 draw calls)  – 60 fps (before: what a nice slideshow, could you perhaps move the frames a bit more often than onece a minute 686,400 draw calls)
5M tris (500 draw calls) – 60 FPS (before: never tried, closest was 3.14M tris @ pls kill me now FPS, 6,864,000 draw calls)

The drawback being that each chunk now takes 3.2 seconds to build instead of 50ms, this might not sound like an issue until you look at the fact that generating a 1km^3 (5,271,552 tris with the testing chunk spammed over and over) takes a bloody hour
oh well, you win some you lose some; at least this is in the realm of things I understand, things I can do math with, things I can plot on graphs, things I can optimize. (unlike simplex which just hurts my head and melts my brain)

another issue is that this slows down exponentially as chunks get larger, for 16^3 the time taken is 3.2 seconds.
for 32^3 it’s 5.34 minutes, orders of magnitude slower.
At least it also uses less memory as well.
I suppose you win some and you lose some, this took one huge weight off my shoulders and instead put another one on.

rant about simplex noise, incompetence and stuff.

2111111111111111221111111 … 1111122111111

FyItZUg

That’s the output of the simplex noise I’m using… what does this mean? How does it work? Don’t ask me, I’m just as baffled. My scene generates with three block types visible (at least, since I use stone as the fallback material for non-grass/air blocks), the blocks I see in my scene are:
id 1: air
id 2: grass
id 3+: stone.
How is this when the simplex only generates values of 1 and 2? I take a plain integer as block id, that should reasonably cause it to only generate grass and air, given that this only contains id 1 and 2.
simplex is weird.

What happens if I clamp it to 1-32?

1614121110910101091011 … 51413121214

The chunk generated however does not have any similarity to the screenshot at all, reasonably one would expect more than an empty shell, no?

8L0AwAP

this thing is hollow btw, in case you’re wondering.

How am I printing these numbers?
std::ofstream f;
f.open(“Chunk_plaintext.txt”, std::ios::out | std::ios::ate | std::ios::app);

are they floating point? sure, we could print them as float but my blocks have index values and I have no useful way to cast them to int that doesn’t have data loss, this would be an issue with 2D simplex as well though, given that you have to put a roundoff point somewhere to get a sample at every pixel and a pixel can’t have a floating point value,
what happens if we multiply the float by 100, divide that result by 2 and then cast to int?
I don’t know, let’s try.

2 1.83933 1.73532 1.66185 1.60199 1.56883 1.59679 1.64369 1.59767 1.53981 1.5873 1.64683 1.67224 1.74292 1.79105 1.80853 2.19107 2.05502 1.92196 1.82605 1.7717 1.72561 … 1.80914 1.76124 1.75255 1.84197

This is the raw noise, added some space padding code, still don’t see how this (when implicitly cast to int, which truncates it) would generate three different blocks when it would only truncate to 1’s and 2’s, that only covers 2 block id’s.
I am confused, I don’t understand why this black magic doesn’t work as expected and I don’t even know where to begin looking.
I’d wager I’m just incompetent, maybe I should just quit; given that I can’t even get simplex noise to work right.
</rant>

All examples truncated for brevity, I’d wager no one wants to read 2 lists of 4096 integers and one list of 4096 floating point values.

[insert witty title here]

Really more of a screenshot dump than a real post with a lot of text content.
nootextors
That’s some fine programmer art right there, I got the noise function working (this being a 32^3 chunk of the world just ripped out and displayed on its own, the triangle count is ludicrous because I haven’t implemented greedy meshing yet (because I haven’t implemented texture atlas loading or shader parsing yet, both of which are required to do greedy meshing and more importantly texturing said meshes)

interestingly the scaled octave noise is not significantly slower than raw noise (I expected it to be, but it was surprisingly insignificant compared to the rest of the chunk building), a potential optimization to that would be to generate the noise once per chunk and then just sample it once per block instead of generating samples on the fly per block, although it would spike memory usage and only slightly improve speed since this process is really rather prone to be optimized by the compiler and branch prediction would work very well on it since the algorithm runs thousands of times per chunk.

Anywho, there was something else I wanted to ramble about but I’ve since forgotten what that was merely through the process of writing this post so I’ll just dump this here, apologize for the lack of incoherency and then go to sleep.

… on that matter, I don’t know how featured images work… will it insert the image twice into the post since I already attached it? will it only show on the front page? I don’t know, but I will soon enough (by the time you’re reading this I’ll already know… so this paragraph is rather pointless), either way I won’t bother editing it if the results aren’t as expected.

EDIT: it did what I expected, well you’ll just have to deal with the same image showing up twice.

Chi-Coder: Free-To-Play and Microtransactions Part 1: My Thoughts.

What a rather delightful post, I should share it to my pretty much nonexistent readerbase.
maybe next week I’ll write another post to my empty blog with a more or less entirely devoid userbase, until then this’ll do.

The Chi-Scroller

I know this isn’t completely fair but I really like the idea of pointing the finger directly at Apple when it comes to the rise of the free-to-play model and microtransactions in general.  Without the iOS app-store I feel that the gaming landscape might be a vastly different one.  Of course you might also be able to point the finger at the guy who originally authored the Defense of the Ancients mod for Warcraft 3.  I won’t hold you in suspense over my feelings on the matter; I’m not a huge fan of either free-to-play, or microtransactions in general.  That’s not to say I don’t play any free-to-play games, or that I’ve never made a microtransaction purchase, but that doesn’t mean that I have to wave my hands in support of either model.  Before we go any further I’d like to be clear that microtransactions and the free-to-play model, while…

View original post 1,843 more words

Chocolate is the new gravel

As usual I don’t really have anything to write about so therefore I should write random inchoerent things instead, but I don’t really have anything incoherent to write either so I’ll instead just post a code snippet from my project.

chunk::chunk(int p)
{
cPosition = p;
//I don’t remember why I’m multiplying by 5 but it works so I’m not touching it.
poteto = core::vector3df( fieldIndexX.at(cPosition)*5, fieldIndexY.at(cPosition)*5, fieldIndexZ.at(cPosition)*5 );
t1 = steady_clock::now();
b_blocks = new block**[CHUNKSIZE];
for(int8_t i = 0; i < CHUNKSIZE; i++)
{
b_blocks[i] = new block*[CHUNKSIZE];
for(int8_t j = 0; j < CHUNKSIZE; j++)
{
b_blocks[i][j] = new block[CHUNKSIZE];
}
}
BlockType BT_T = BT_NULL;
int tst;
for(int x = 1; x < CHUNKSIZE-1; x++)
{
for(int y = 1; y < CHUNKSIZE-1; y++)
{
for(int z = 1; z < CHUNKSIZE-1; z++) { //loBound, hiBound, algo (0-3), octaves, persistence, x, y, z, scale b_blocks[x][y][z].setBlock(tGen->chunkGen(0.0f, 2.0f, 2, 6.0f, 10.0f, x, y, z, 1.0f));
// 0.0f, 2.0f, 2, 6.0f, 10.0f, x, y, z, 1.0f yields very weird straight pillars of solid matter with large airgaps.
}
}
}
createMesh(p);
t2 = steady_clock::now();
time_span = duration_cast<duration>(t2 – t1)*1000;
std::cout << “Time: ” << time_span.count() << “ms” << std::endl;
}

Whoever can tell me what that code does get’s a free letter ‘a’, mind I already know so no cheating 😉
oooh and that’s actually pretty incoherent and somewhat unprovoked so mission success?

Anyway, back to figuring out how to modulate simplex into something useful, infinite vertical columns is rather useless.
perhaps I should be using scaled octave noise instead of scaled raw noise… or maybe just octave noise? Anywho, here’s a screenshot.
bars