6.25.2009

Non-themed music

0 Comments
Some months ago I had a lot of ideas for music tracks and audio in general, but I reached a point where I need more orientation. A point where I actually need a reason for making music. A concept. A theme. But maybe it's just because I don't like my own creations, because I got tired of making distorted beat music, because I always wanted to make (and have) soundtracks for games - not just senseless, non-themed electronic music. Video game soundtracks always fascinated and it's truly what I want to compose (if I compose...). The problematic part is that I don't have a game yet and I really need a completely finished game where I could put my score in... Yes, I could also try to make a soundtrack for an existing game, but I'm sure that I can't make music for games I haven't created by myself. I'm looking forward to my Korg DS-10 which I ordered two weeks ago. It's an oldschool synthesizer on the Nintendo DS with modern interface and better output.

Music is shit. Let's go programming.

Finally

0 Comments
Yeah. I did it. Most work for my renderer is done (or at least the most complex work). I managed to complete rewrite all calculations, alghorithms, etc... Now it's possible to have transparent blocks which can lead to sophisticated shadow calculations and interesting color changes. And everything depends on what the player character can see and how the light get's filtered before the character actually CAN see something. It's not just a simple shadowcasting alghorithm; it's a fully functional, non-reflecting raytracer without perspective correction for third-person ASCII games.

My new graphics pipeline for each tile:
  1. Visibility trace on Z-axis from camera to map bottom
  2. Trace visibility to player / calculate color prefilter / pre-calculate negative (potential) brightness
  3. If visible: trace between lights and tile (filter light color if there are transparent blocks between)
  4. Add distance factor to pre-calculated brightness
  5. Multiply light color with tile color
  6. Multiply prefilter with final color
  7. Convert from float-based color structure to SDL color
Ten hours coding and empiric research led to a quite nice code (I actually experimented with real filter glasses, different light colors, etc...). It reaches about 100 FPS (10 milliseconds per frame) on a 40x20 tiles screen with 3 lights (10-30 tiles radius) and transparent blocks only. ~10000 tile walkthroughs per frame, no optimizations yet. Holy shit, this is faster than I had expected! I wonder how it survives a real stress test with 10+ overlapping lights and a bigger map. I should test it later.

Three things do still remain:
  • Different tile graphics depending on distance
  • Different brightness/distance formulas
  • Directed lights (Or was it called aligned? Too bad I'm not a native english speaker...)
The last point isn't so important (and a bit spacious in terms of experimentation) I'm also trying to get better depth illusion by reducing light source brightness and size depending on Z distance to player/camera... It's hard to tell what is better for depth illusion: different tile graphics or different brightness? Different brightness isn't possible - I already used it for distances and in general. So... the only way to get better depth is to change tile graphics and/or light attributes...

I'm fucking tired. I'm in need for sleep X( .... I should make some vids of it... Or at least some decent screenshots. Holy hog, I'm so goddamn exausted... *jaws and falls off his chair*

6.23.2009

Rendering vs. Reallife

0 Comments
Realistic light calculations is easy and strange at once. My light engine is close to real life light: white light does affect brightness only, but not the tile's color. Pure red light will make tiles red, independent from tile color. And I started wondering about how "real" it really looks and feels... It's strange; a combination of weird colors with even weirder results... I tested some light colors in a special geometry, took screenshots and compared them with similar a real life situation. The result was interesting - colors and brightness in RL and my renderer matched, because RL lighting bases on "pretty simple calculations" which I also did in my program. It was a single, limited experiment, but I think it's the way how I can simplify real light in my game.

I'm not happy about it - why is RL lighting so simple? Ok, it's actually NOT that simple, but I wonder how it works in modern 3D shaders/engines. I wished RL lighting would be more... complex. More variation, more parameters! The only thing I can do in my engine is to implement simplifications of more complex, light-influencing architectures as parameters. In theory (like directed light), I could create giant maps with reflections and visibility-limiting geometry to get directed light sources, shortened light ranges, etc... But then it wouldn't be capable of realtime rendering or wouldn't work on smaller maps. Oh nose!

Physical VS. computed light is like simple vs. complex. Programmers always had to implement tricky alghorithms to get comfortable control over lighting. That the way how it works, I guess.

Graphics pipeline

0 Comments
For each tile in screen rect:
  1. Trace camera visibility (on ONE axis)
  2. Change tile symbol depending on Z distance to camera
  3. Trace visibility for player (from player's x/y/z position)
  4. Check which light affects the tile's appereance
  5. Calculate tile color via light color
  6. Calculate tile brightness via light distance
  7. Convert from float-based color structure to SDL color
Things I did yesterday:
  • Multiple, colored lights
  • Realistic light model (white light doesn't affect color)
  • Removed unnecessary light data
Things I have to do:
  • Trace visibility to player position
  • Raytracing refinement
  • Raytracing limit adjustment
  • Directed Light sources
  • Some light model settings
  • Different formulas for brightness calculation
  • Different tile graphics/symbols for depth illusion
  • Add transparent tiles to change light ray color/intense

6.19.2009

The shadow on the wall

0 Comments
I'm so damn happy! I FINALLY DID IT! 3D Raytracing in my roguelike engine! I'll upload some pics when my current map is better to demonstrate all the tricky shadows there... It's very maths heavy and I doubt that it will get better in time. But I have the possibility to add some low-math features like transparent or translucent objects to change the color of a light ray. It's just awesome to look at! I love light engines - they can do all the magic you ever dreamed of... Oh, nose! I'm the mood to praise myself! Yay! Holy shit, it's the most awesome day in this month!

Next Steps:
- create a final light formula
- add transparent, light-changing objects
- change char graphics depending on distance to camera (for more depth illusion)
- OPTIMIZE

The last point is killing me. I thought about having an un-optimized version and an optimized version (to implement new features easier) because it's hard so implement new things with a lot of optimized code. Optimization isn't really what I want to look at - it's more necessary and useful in the final version. But I have another idea - a seperate class for bigger 3D array walkthroughs... Naaah, I need to think about that.

6.06.2009

Programmer's music

0 Comments
Sometimes programming is hard and consuming. To avoid being grumpy all the time, I consume whatever-awesome music I can find to cool down. Somebody told me listening music while programming isn't that good... Was he right? I say no. It depends on what you like and no psychological telltale can change my opinion. Music is my essential source of power... Albeit I do various kinds of electronic and energetic tracks, my musicial taste is pretty diverse and for programming I prefer orchestral-sounding video game scores. Ambient is also nice for coding, but listening to my Legend of Mana OST cannot be replaced by any other kind of music. Especially electronic orchestra is somewhat... pleasing. So harmonic I want to apply it to all my programming journeys... Well, listening music got a highlight for my at the age of... say 12. The RPGmaker induced my to LOVE video game music (you know - playing your game's background music all the time with an inbuild MIDI player!) . I still remember all my favorite themes and first MP3 downloads... It's was awesome, a completely new world to discover for me! Music is hard, much harder than programming. And you can nearly FEEL that work when listening to some soundtracks. Music. Just awesome. However... a lot of programmers seem to be fascinated by music and the general idea/effect of it.

I wonder where the actual connection is... Is it the structure? No, some music can't have structure. Is it the hard work behind music? Hm, I don't think so. But... is it the developing process of sound? The change over time? Yeah, that could be true. A piece of music is like developing software. Everyday it's going further and further - like a sound changing it's pitch and volume over time... A hidden if not invisible link between the process of programming and music. For me, making music is programming light. Just add some notes, take another instrument, vary the theme (HAVE A CONCEPT)... like typing another algorythm.

6.02.2009

C++--

1 Comments
C++ is a demake of C. That's all.

....

Ok, it's cool to have things like Methods for structs and overloadable operators, but C++ is still pretty much superfluous, especially STL-wise.

3D visibility

0 Comments
A tiled 2D game with a 3D world is kinda complicated to display. Especially if you to want to have an invisible ceiling like in modern 3D games, but also zoomable camera and fucking tiny rooms. I came across a design problem which can get pretty elementary... If I limit the display/camera to tiles under the hero (or atleast to the same height level) I can't give zoom abilities... Zooming is a pretty cool and useful feature, especially for a randomly generated worlds where everything can go everywhere in every direction. It's less a typical zoom-in as you can see it in action-adventures, but more a z-axis movement of the camera (you know, 2D-displayed games are a bit... easier). Therefore a zoom-out would mean possible collision between camera light rays and the ceiling/walls OVER the hero. If we take a look at nowadays Nintendo games like Zelda, Mario or whatever... we can see a nice method to avoid screen-flooding walls: circular transparency around the hero figure. It's a nice idea, but also another "specialisation" I always wanted to avoid. But hey - I'm a code monkey, this can't be a problem.