Jump to content

  • Log In with Google      Sign In   
  • Create Account

Ashaman73

Member Since 10 Nov 2006
Offline Last Active Aug 25 2016 11:09 PM

#5184222 Threading question

Posted by on 30 September 2014 - 10:54 PM


It feels like having to grab a mutex every time I want to modify some data will quickly turn my multi-threaded game engine into an effectively single-threaded one, as all other threads will be blocked.

Yep, therefor you should avoid this as much as possible. This is somewhat special about game-development, sometimes an application developer will rejoice when a process finishes after just below 200ms, whereas a game developer will break down once a process needs more then 2ms. And synchronisation is one of the fastes ways to surpass the 2ms wink.png

 

 


This works fine if there aren't many objects to draw, but if I understand this correctly, some synchronisation problems could occur if the rendering frame rate ever drops to the rate of game loop updates.

How do you balance the need for thread-safety

You dont need to balance thread-safety, because your code must be thread-safe period. It is just the matter how hard it is to ensure thread-safety. If you use mutex/semaphores/critical sections etc. it is quite easy, but potentially slow. If you use lock-less sync by contract, you are at a much higher risk of including bugs, but it is much faster.

 

On the other hand, maximum CPU usage is not always needed, and modern, powerful CPUs remove the burden of hobby/indie developer of squezzing out the last drop of performance. So, as long as you don't try to invent the next block-buster AAA engine, I would sugguest to use a good mix of manageable code and block-less concurrrency behavior, which feels comfortable. Just remember, the best, fastest code is worth nothing, if you can't handle it over a long period.




#5184033 Strange GLSL Behavior (Debug vs Release)

Posted by on 30 September 2014 - 05:29 AM


everytime upon launching the program in Debug mode only works about 1 / 3 of the time when I'm trying to launch the Release mode version of the program.

This is often a result of not properly initialised variables. In debugmode, every variable will be initialised with atleast some debug information whereas in release mode, for the sack of performance, only variable which you have initialised in your code get proper values, everything else contains some random, not defined data.

 

This has nothing do to with the glsl shader, more likely the initialisation of the shader, setting of uniforms etc. will use some uninitialised variables.




#5184010 Threading question

Posted by on 30 September 2014 - 02:32 AM


Why is this working fine?

This way of handling threading is dangerous. It will work most of the time, but sometimes something unexpected occurres. The real difficulty is to analyse the unexpected bug.

 

 

 


Is it safe for me to continue doing this?

Yes,no, maybe...

 

In other words, there is only a small time window when one thread writes data and one thread read this data. An unexpected bug occurred whenever these two windows overlaps, which might happen really seldomly.

 

There are some ways to ease this kind of stuff.

 

1. Using system synchronisation: This is often the worst case to handle multithreading in games. Whenever you use or read shared data, you ensure that your thread is the only one who read/manipulate the data by using some kind of system supported syncronisation (mutex,semaphore etc.). The issue is, that your other threads will get blocked for some time (=wasted time).

 

2. Atomic operations: This is pretty cool. Atomic operations ensure that there's no real blocking of threads. Check CAS operations, these are really useful for lockless lists/queues .

 

3. Synchronisation by contract (no official term): This is more like what you have done. You ensure, that if multiple threads read only from a shared data, that no other thread will manipulate it concurrently and if one thread manipulates shared data, no other thread read from or write to it. This in combination of a few sync points (see 1. and 2.) will ensure that your threads can work concurrently most of the time without utilising explicit sync mechanism.

 

One example:

10 threads animate the skeletons of a pool of entities (pulled from a list by using atomic CAS), writing the animation data to buffer B.

while 1 thread renders all animated entities from data buffer A.

After all threads has finished, swap data buffer A and B (synchroinsation point).

 

In this example, you use double buffering, some CAS operation and a short synchronisation phase at the end.




#5183669 Hand painted textures **UPDATED**

Posted by on 29 September 2014 - 12:51 AM

Wow, great improvement. Good work.smile.png

 

To improve further test out the following:

1. Wood:

The spirals in the wood, as element of stylization, is good. But the notches/cuts along the wood structure are too regulary. You should use cuts and other outstanding details with care to break up an otherwise monotom surface. One or two larger cuts would be better.

 

2. Metal bands:

You already have a pretty good color/value variance in your wood texture. The metal texture is lacking this variance. The surface looks too flat, the details too obviously. Use rustt and some wear. Metal as material lives not much from color , but from reflection (it is important to note, that the metal will filter the color of the reflected world, eg. silver will most likly be like a mirror, whereas gold will tint the reflection in yellow) . So imagine the impression of a reflected world in your metal bands. Eg. a bluish color is always associated with the reflection of the sky which will give you a metalish look even if the sky is not visible in the scene. The roughness of a metal will define how clear a reflection is visible. A polished chrome,silver,gold surface will be like a mirror, whereas a rough, dirty iron surface will reflect the surrounding in a vague manner.

 

3. Overall:

Use details more sparsly, try to get the material down first and use color/value variance to break up a surface (avoid flat look). Use details to set highlights and to break up monotom surfaces.




#5183062 problem with my text rendering

Posted by on 25 September 2014 - 10:38 PM

Looks like a fitlering problem, check the following:

1. pixel exact rendering

2. no linear filtering

3. no mipmapping (eg auto-generated rendering)

4. no compression




#5182582 matrix/coordinates?

Posted by on 23 September 2014 - 11:39 PM


I don't understand some of the setup stuff, it's mostly pieced together code from other examples until I found something that worked somewhat.

Stop here, delete your project, look for tutorials and start over again. This time concentrate on understanding the stuff you are using and why it does/doesn't works this way. tongue.png

 

It is the most safe and eventually quickest way to get into something new. Building your project on something which magically works sometimes, without knowing why it works at all huh.png .. will often end at the point , where you can't figure out a show-stopper (a bug, which ruins your whole project).

 

My first really big project ended this way, it was a pretty cool learning experience, still it hurts a lot if you consider the progress made sad.png .




#5182575 Help in modeling ramps and curves!

Posted by on 23 September 2014 - 10:54 PM

I can't tell you the way to approach this in max, but in blender I would do it this way:

1. create a cylinder

2. half it (throw other half away)

3. extrude surface to apply a thickness

4. build a simple cage (subdivided cube,rect).

5. use the lattice modifier to form the curves.

 

I think, that max will have similar tools/modifiers. Best to google for an useful mapping.




#5182040 Hand painted textures **UPDATED**

Posted by on 22 September 2014 - 01:04 AM

It is a start. Some thoughts.

 

1. Ignore normal maps for now. Normal maps only works with technical lights (ingame engine), whereas handpainted textures is the art of applying light and shadows directly on your texture. As you see, it is conflictive and therefor not really easy to pull off.

 

2. Your texture will benefit more from material maps than from normal maps (eg make the dark crevices between the boards non reflective and the wood a little bit reflective, will have an more important impact in game rendering then to apply normal maps).

 

3. If you apply stylization (stylized spiral in wood structure), then you should be consistent. The wood boards are just too clean and plain. Make them more rough.

 

4. Less is more, dont add too much detail. More variance in the color and overall look will be more helpful.

 

Hereare some wood texture tutorials.

 

Nevertheless, your texture reminds me of my first wood-barrel attempts. Just keep practising and you will be suprised of how much your skills will improve.




#5182035 world maps

Posted by on 22 September 2014 - 12:26 AM

It is hard to answer, but I got two favorites: Elder Scrolls II: Daggerfalland Bard's Tale I . If you take a look at the games you will wonder why not oblivion or skyrim. The reason is the following:

Bard's Tale I had a mini world map, just a single town with only a few usable buildings, and every single usable building had some use. Daggerfall on the other hand had a large, procedurally generated world which delivers a generic, still living world.

 

When I play a RPG, I dont need all this story threads, and mindless talking about the common gossip. Modern games try to go into great details, but on the other hand they need to reduce the overall scale so much, that it is often cluttered with non-functional blah-blah and really small scale on the other hand. The result is often that you encounter villages with 5-10 villager, a dark castle, which is just 20 meter down the street, goblin hords consisting of 4 goblins and dungeons which are as small as your common medieval cellar.

 

Eventually, in my opionion, a world should be large  and a game should be functional and consistent. I don't need a detailed, unbelieveable world simulation, when it comes at the costs of really small scale.




#5181221 Walking through the debugging process

Posted by on 18 September 2014 - 03:32 AM

Try something like this:

            for (int t = items.Count() - 1; t >= 0; t--)
            {
                if (player.rectangle.Intersects(items[t].ItemRectangle))
                {
                    int bestSlot = -1;
                    for (int i = 0; i < player.PlayerInventory.itemSlots.Count(); i++)
                    {
                        if (player.PlayerInventory.itemSlots[i].IsSlotOpen == true)
                        {
                            if(bestSlot<0) {
                               bestSlot = i;
                             }
                        }
                        else if (player.PlayerInventory.itemSlots[i].IsSlotOpen == false)
                        {
                            if( (player.PlayerInventory.itemSlots[i].item is Twig && items[t] is Twig) ||
                                (player.PlayerInventory.itemSlots[i].item is Rock && items[t] is Rock)) {
                                bestSlot = i;
                            }
                        }
                   }

                   // add now
                   if(bestSlot>=0) {
                      if(player.PlayerInventory.itemSlots[bestSlot].IsSlotOpen == true) {
                            player.PlayerInventory.itemSlots[bestSlot].item = items[t];
                            player.PlayerInventory.itemSlots[bestSlot].IsSlotOpen = false;
                      } else {
                            player.PlayerInventory.itemSlots[bestSlot].item.NumberOfItems += 1;
                     }
                     items[t].ItemPickedUp = true;
                  }




#5180936 Deferred rendering shader spaces issue

Posted by on 17 September 2014 - 01:38 AM


Also, are there any clarifications what exactly are: Model-Space, View-Space, Camera-Space? Are they exactly as I told?

Model space or object space, is the space in which your mesh is defined. When you load your mesh, each vertex is in model/object space.

Eye,view or camera space , is the space around wink.png  your camera, with the camera position (center of projection) being the center (0,0,0).

 

The common transformation is

objectspace ==model-transform==> wordspace ==view transform==> viewspace ==projection transform ==> screenspace

 

When using deferred rendering, the g-buffer is typically in view/camera space.

 

 

 

 


But how do I need to calculate Positions texture?

If you are in camera-space, you only need to save the depth, that is all. You dont need the position, because you can reconstruct the camera-space position from the screen-pixel position (aka fragment position) which is available in the fragment/pixel shader and the depth (there are different approaches to do it, best to use the search function/google for more detailed informations).




#5179774 Can concave polygons be used in pathfinding?

Posted by on 11 September 2014 - 11:10 PM


Most of the times I heard about the

usages of convex polygons which are plenty.

But can a concave polygon be used in the pathfinding process?

You can use both of them in both fields, AI and graphics. The reason for using primary convex polygons is, that if you have a convex polygon, then the whole matter of calculating stuff gets a lot easier and faster and that you suddenly get some knowledge for free (eg. in a convex polygon you know that whatever two points you choose, the can be connected by a line without hitting the boundary of the polygon, which is good to know if you want to navigate an AI entity on top of a polygon, aka nav-mesh).

 

With this in mind, it is often better to subdivide your concave polygons into convex polygons and to use the easy stuff smile.png




#5179770 2D Geometry Problem

Posted by on 11 September 2014 - 10:54 PM


The problem I'm having is getting a uniform thickness

The issue will be, that you have to change the topology of the mesh. The light gray mesh right silhouette consists of 3 lines, a uniform thickness hull will need circles to be uniform. Eg take the corner of the light-gray section between the two lower blue lines and draw a circle around it to see the corner part  of a uniform thickness hull.

 

With this in mind you can construct a hullmesh by a selection of geometry objects. In 3d you need a box for a plane, a cylinder for a edge and a sphere for a vertex. The combination (union including the original mesh) of all this will define the hull mesh with a uniform thickness.




#5178801 How can i make objects have completely different outcomes?

Posted by on 08 September 2014 - 12:02 AM


So i was wondering if there is a more elegant way to achieve what i am talking about

There's no simple answer to this question.

 

I think, most game are planned with some major features in mind (a feature, which will require the support of the underlying engine), like flying entities or unique AI behavior. Then the game designer will try to design the game around this major features. If they desire some new feature, they often will try to use the available stuff first(you will be surprised, how much you can archive with a few fixed game features). Often you can get away with some compromise, instead of flying entites, you could use a long jump entity with an similar gameplay effect for example.

 

Eventually, but rather seldomly, some major feature will be added to let the designers create new behavior/effects. But, as you already said, adding a major feature is often really difficult and therefor embedded in a major game update, an addon or even the next release in a series.

 

 

 


I thought that maybe adding a Script engine to the game would work

A scripting engine is more of a designer tool then a major feature. A scripting engine will help your game designer to access the game features more easily and to prototype some game design more rapidly, therefor it is a very useful addition to a game (!). But it will not add new major features to the game, that is the difference. If your engine only supports moving entities on a 2d plane in a 3d environment, a scripting engine will not allow you suddently to have a free 3d roaming environment.




#5177617 Beginners Observation: Fundamental Lack of Source Code Examples?

Posted by on 02 September 2014 - 02:43 AM


I don't believe 'Best Implementation Examples' should be patented or relegated to super-secrecy.

Well, the issue is, that they do not exist. Once you are knee deep into development, you will understand, that there isn't anything like the 'best solution to solve problem <x>', other then some standards (like A*) which has already been docuement all over the internet and wiki.

 

The second problem is, that as experienced developer, you can only provide one of many working (not necessarily good) solutions, often limited by a NDA if you work in the game industry (a working solution embedded in a game is often not your property and you are not allowed to distribute it).

 

The third problem is, that your solution is often embedded in a quite complex program which will most likely not help any noob at all. A week ago someone asked me to show off my behavior tree implementation. Even if I have provided my 5000 lines of code, it would communicate with so many other sub-systems, that a noob coder would most likely not understand a single piece of code.

 

Well, as experienced coder, the best option would be to write dedicated example code (lot of unpaid work!) or to provide some of your knowledge in a forum.






PARTNERS