Questions about Engines and Games

Started by
6 comments, last by pcmattman 16 years, 4 months ago
Hi guys, It's been a while since I've been around here, and in that time I've built my engine to a level I like a lot. At the moment I haven't yet implemented a sound system into the game (it's designed to be ready to plug in though) but the graphics engine works nicely. It's fully scriptable with Python (levels are just python scripts, the game is run from python scripts, entities are controlled by python scripts), and that's working well at the moment. However, I'm having some trouble now... Firstly, how can I light my worlds when the hardware only supports a maximum of 8 lights? Is it too slow to compute lighting information JIT (EDIT: JIT meaning as the level is loaded, not when the player views the light)? How do commercial games solve this problem? Secondly, I'm planning on licensing my engine (as it is quite versatile). As an entity in my game is a C++ class, how would I go about distributing the code? Would I just license the entire engine, or maybe put the non-changeable parts into a library that needs to be linked into the final game? Thirdly, how exactly do I make a game from an engine? I know this sounds a little stupid, but at the moment I have a really cool engine that works and does what it's meant to, but I'm not so sure about integrating menus, level loading, and gameplay in such a way that I don't have to hardcode it. Finally, due to the non-standard level format (a Python script) I was thinking I might be able to write an export script for Blender that converts all the geometry into relevant entities and generates a level script. Would this work, and if so, any resources that could point me towards writing that script would be great. Thanks in advance.
Advertisement
Quote:Original post by pcmattman

Firstly, how can I light my worlds when the hardware only supports a maximum of 8 lights? Is it too slow to compute lighting information JIT (EDIT: JIT meaning as the level is loaded, not when the player views the light)? How do commercial games solve this problem?



The traditional way of solving this problem is through pre-calculated lightmaps. Lightmaps are usually created as part of an offline pass in a level editor, and not at runtime (since they may use GI and shadowing techniques that can cause it take a very long time for computation). This would make rendering cheaper and allow you to bypass the 8 light limit, but it consumes memory and also requires that light sources and affected objects are static. I'm not really sure if this is something you can build into a blender export script, or whether that application has built-in facilities for aiding in this. You could always create a command-line utility for generating the lightmaps from your blender output file.

Also, what hardware are you working with where you can't use programmable shaders?
Quote:Original post by MJP
Also, what hardware are you working with where you can't use programmable shaders?


I can use shaders, I just don't know when and how to use them. Any resources would be great.
Quote:Original post by pcmattman
I can use shaders, I just don't know when and how to use them. Any resources would be great.


You do know that you're writing that question in one of the best places in the whole world/Internet to search (and get tons of results) for the answer to that question and many more, right?
I've since searched the site and found some articles on shaders. I'm reading them now.

The other three questions still stand though (and I'm not sure about how I integrate shaders and lighting, though I'm sure that'll become clear as I read).
Quote:
Thirdly, how exactly do I make a game from an engine? I know this sounds a little stupid, but at the moment I have a really cool engine that works and does what it's meant to, but I'm not so sure about integrating menus, level loading, and gameplay in such a way that I don't have to hardcode it.


I dont know how much experience with programming, and what your aims are, but some people think you should make games not engines (link not to hand). Still, I went against, but not by making an engine per se. More like a load of features i think Ill need in the game. It is still coded as a sepereate independent codebase to the game code, but it has been making my game coding a lot faster as Iv already got all the primitives in place (App level stuff, input, sprites and opengl etc).
If you plan to make a game as your main goal, Id recommend rethinking your engine or at least giving it suitable features for the game you wish to make. Things like gameplay, menus, AI and stuff like that can be entirely Game code based if you wish it to be, or you can add it to your engine. To much higher level abstraction makes it harder for your engine to maintain a decent state of independence from its own modules and other bits of code about your projects youll use it with.

There are hundreds of ways to code a game, and I probably know less than 1% of them, so Id just say read up a little bit on th subject then give it a go. If you mess up, at least you learnt one approach may not be suitable for this sort of thing, and you just start again.
Quote:Original post by pcmattman
Quote:Original post by MJP
Also, what hardware are you working with where you can't use programmable shaders?


I can use shaders, I just don't know when and how to use them. Any resources would be great.


In that case, I definitely suggest integrating them into your engine as much as possible. Shaders allow you to approach situations (such as lighting, materials, shadows, effects) with a vastly higher degree of flexibility than what the fixed-function pipeline offers. Newer GPU's (Nvidia 8-series) don't even have any fixed-function hardware anymore, its simply emulated through shaders. So in that regard when you use them will depend on the level of hardware you're targeting. My own renderer is fully shader-based, and I'd suspect the same for most new game engines. Regardless...if you're serious about licensing your engine, integrating shaders in some capacity is a must.

Which graphics API are you using for your engine? I'm mainly a Direct3D/HLSL guy myself, and if that's what you're using I can direct you to some tutorials and give you some pointers. As for OpenGL, I'm sure one of the other members can help you out.

MJP: My engine uses DirectX 8. I'm pretty sure integrating shaders into my engine will be a worthwhile experience, but some tutorials would be nice (specifically, I'm still a bit confused as to how lighting is emulated using shaders, and what I can do with them).

ConorH: The main reason I want a high-level abstraction is that I want to make a game but I don't want to have to worry about fiddling around with the C++ code (I feel comfortable with it, it's just that there's a lot of it). So far the only primitive supported in my engine is a box (because I'm testing out the whole Python thing, and because a box is a really simple shape) but there's the interface ready to go for as many primitives as I want.

Quote:Original post by ConorH
I dont know how much experience with programming, and what your aims are, but some people think you should make games not engines (link not to hand).


I've been working on an OS since January and decided to do something more interesting. I've been programming in C++ for the past 4 years, and feel confident with teaching myself things.

This topic is closed to new replies.

Advertisement