Jump to content

  • Log In with Google      Sign In   
  • Create Account

Hodgman

Member Since 14 Feb 2007
Offline Last Active Yesterday, 10:11 PM

#5044808 Hi.. It's quiet long time since I use OpenGL what is most common GL math...

Posted by Hodgman on 20 March 2013 - 02:21 AM

D3D isn't directly tied to a specific math library either. Yes, there is D3DX, XnaMath.h and DirectXMath, which have all been designed by Microsoft to provide math code that works with D3D, but the actual D3D API doens't directly interact with any of them, so it's just as valid to use GLM with D3D, or DirectXMath with GL!




#5044739 Correct compiler syntax for compiling shader using fxc

Posted by Hodgman on 19 March 2013 - 06:31 PM

IEEE strictness will prevent any optimization that doesn't exactly comply with the floating point specification, for if you need deterministic processing. E.g. The compiler can fuse a multiply and an add into a single mul-and-add operation, but the result will be rounded ever so slightly differently than if you'd done them separately.

For release, I use /O3


#5044729 How to edit "Inheritance" in Object Oriented Programming?

Posted by Hodgman on 19 March 2013 - 06:04 PM

Lets say I am making a FPS game. I have 4 different weapon types, Pistols, Shotguns, Rifles and Rocket Launchers. Obviously all of these weapons are going to have functionality that is the same like ammo, accuracy, damage and so on. So you would make a parent class with all of the common functionality and extend from that class when programming your weapons so in the child class you didn't have to rewrite all of that code.

This is called 'implementation inheritance', and while it is a common pattern in OOP languages (especially 90's C++ and Java), it wasn't originally a part of Object Oriented Design, so it's not the only option. The OO approach to this situation would be to put all that common code into a class / classes, and then having your new class gain access to / reuse that code by using that class / those classes as member variables (aka 'composition').


#5044727 OpenAL why is there no group working on it?

Posted by Hodgman on 19 March 2013 - 05:57 PM

32 sources compared to hundreds of sources with proper occlusion and implicit environmental effects (I.e. they echo if they happen to be next to a stone wall, not because you explicitly told the source to use the 'stone room' effect) is an unimaginably huge difference. Audio really has been stagnating.

A lot of people have shitty PC speakers, yeah, but a lot of people also have cinema-grade speakers and/or very expensive headsets. Surround sound headsets are becoming very common with PC gamers at least.

Is it possible that in the future, instead of a dedicated audio processing card, we'll just be able to perform our audio processing on the (GP)GPU?


#5044480 Should a game engine support "general" file formats at runtime?

Posted by Hodgman on 18 March 2013 - 11:42 PM

Absolutely not, but also yes/maybe. No as in: the engine shouldn't parse COLLADA files. But yes/maybe as in: that doesn't mean the engine can't load COLLADA files at runtime.

IMHO, data processing should be moved out of the engine runtime and into the toolchain. This greatly simplifies the engine runtime, which keeps it flexible/maintainable.

If you want to support some extra file format, it's of no concern to the engine runtime; you just add that file loader into the data processing part of the code-base, which is completely decoupled from the engine runtime.

Forgive the ASCII art -- the architecture I use separates the developer's PC from the game via the data toolchain:

________________     _________________     _____________________________
| Developer's  | --> | Data compiler | --> | Abstract game file system |
| Windows file |                              ||
| system       |     _________________     ___\/___
|              | --> | Code compiler | --> | Game |

During development, there's no reason that the game can't talk to the data toolchain. When loading a file, the game can send a message to the data toolchain saying "I want to load the file 'blah'", and if that file is some JSON config file, then the data compiler can load it, parse it, compile it, and then send the resulting bytes on to the runtime.

Every game engine that I've used in the past 4 years has implemented it's "development file system" (the one that's used in non-shipping builds) over a TCP/IP connection to the data processing tools, which makes this kind of configuration pretty straightforward.




#5044476 Eight, Nine, Ten...

Posted by Hodgman on 18 March 2013 - 11:32 PM

I think we should pool our efforts and make a programming language where this kind of thing is sane.

http://thedailywtf.com/Articles/The_Secret_to_Better_C.aspx




#5044447 DirectX 11 free engine?

Posted by Hodgman on 18 March 2013 - 08:47 PM

Ogre is widely known to be extremely inefficient on the CPU side, due to being written in the infamous typical C++ style

e.g. my first hit for "why ogre is garbage" on google was this: http://www.ogre3d.org/forums/viewtopic.php?f=1&t=71836

It's performance is good enough for a lot of people, evidenced by the commercial games that have shipped using it, but the source code design is very 1999...

 

Years and years ago, I switched over to Horde3D from Ogre, because it had a much simpler design, but even it has terrible CPU-side overheads compared to professional/proprietary graphics engines.

 

A game engine is generally more than just a graphics engine (unless your game is nothing but graphics)...

 

Jason, is it just modesty that's stopped you from suggesting your own D3D11 graphics engine? 

If so, I'll suggest it for you biggrin.png

@OP: Check out Hieroglyph 3




#5044446 Game/Controller Idea (I don't think its been said before)

Posted by Hodgman on 18 March 2013 - 08:38 PM

I'm pretty sure hundreds of people have had this same idea, but it's pretty darn costly to implement biggrin.png

 

VR and motion capture keep getting cheaper though, so maybe one day soon it would be feasible. Like you say though, you'd also need to rent a huge space to host the game, which would have to be close to a metropolitan area in order to get customers, which is another huge expense. Then on top of that, there's the actual game development part!

 

I had the same idea when I was a teenager, but as an FPS instead of a melee game -- other players could be in the same arena as you, and the VR goggles could draw 3D models for them using their exact poses, so they line up with reality. You could then play with a laser-tag gun, which is registering shots against their real-world body.

Having walls and obstacles in the arena would be fine, as long as your motion capture and VR tech is accurate enough that it can draw virtual walls in the exact same places as the real walls are.

 

To build this, you would need an existing, talented games studio that can build the software, and you would need a bunch of hardware engineers to concoct your VR environment for you. Each of those teams would then need millions of dollars in each of their budgets... And then you'd need to attract enough players, and charge a high enough price to make back your money.

At the moment, it's probably cheaper to scrap the whole VR part and just use reality, like Patient 0 did: 




#5044199 multiple threads, OpenGL, and worker threads...

Posted by Hodgman on 18 March 2013 - 07:12 AM

@cr88192, with all your mutexes about the place, how much of a performance increase have you measured over your original single-threaded GL code?




#5044197 3ds max plugin which allows me to upload to a git repository

Posted by Hodgman on 18 March 2013 - 07:01 AM

You don't neeed cool.png   a plugin for 3DS max to use Git -- a plugin would just make it easier. You can use the git command line, or the TortoiseGit GUI from windows explorer to commit your changes to the repository. 

 

Personally, I prefer to use Git from Windows explorer and/or the command line, rather than having it integrated into my code editor, so that my interactions with the repository are more explicit.

 

 

Echoing what Simon said though, the reason that it's hard to find a 3ds integration with Git, is because Git is actually a really poor solution for game art files. It's fantastic for text source code (really fantastic), as it's really smart when it comes to merging different versions of text files together... but none of those features works with 3DS Max files, so they're useless to you.

If you ever do end up in a situation where two people have edited the same art file, then Git will be less than useful, as it can't even prevent that situation from occurring  and can only give you the option of choosing which person's work gets deleted.

 

Also, a large part of Git's power comes from the fact that it stores the entire history of all files on every user's PC. With text files, this is generally only a few megabytes, which is no problem at all... but with art files, this could be gigabytes to terabytes, depending on the size of your project, and how many changes to each file you have to make.

 

I would talk to your programmer and check that they're really sure that they want to use Git to store game art...




#5044165 C++ Concurrency Library

Posted by Hodgman on 18 March 2013 - 04:23 AM

TBB seems to be a very common choice.
 
[Provided you've had practice with memory re-ordering issues and esoteric C language rules, then] Writing your own isn't that hard.
I like to use a SPMD style of programming quite a bit these days. What I do is:

  • Create a bunch of threads -- typically 1 per core.
  • Assign each thread a number from 0 to numThreads-1. Store this number using TLS so it can be retrieved like a global variable at any time.
  • Write a pure function that can distrubute a range of a problem between threads, e.g.
inline void DistributeTask( uint workerIndex, uint numWorkers, uint items, uint &begin, uint& end )
{
	uint perWorker = items / numWorkers;
	begin = perWorker * workerIndex;
	end = (workerIndex==numWorkers-1)
		? items                      //ensure last thread covers whole range
		: begin + perWorker;
	begin = perWorker ? begin : min(workerIndex, (u32)items);   //special case,
	end   = perWorker ? end   : min(workerIndex+1, (u32)items); //less items than workers
}
  • Run the same main loop on all threads. Upon reaching a processing loop, use this function to determine the range of the loop that should be processed.
  • If the results of one loop become the inputs to another loop, then make sure you synchronize the workers appropriately. e.g. increment an atomic counter as you leave the first loop, and before the second loop, wait until counter == numThreads.
  • In my implementation, I combine this SPMD model with a job-based model, where while any thread is busy-waiting on a condition such as the above, they continually try to pop 'job packets' from a shared queue for processing, to make good use of this waiting time.



#5044134 Loaded scene form COLLADA is inverted in DirectX

Posted by Hodgman on 17 March 2013 - 11:44 PM

In 3DS, is Y your "up" axis, or is "Z" up?

You probably shouldn't be multiplying individual components of the matrix by -1, but should be scaling an entire axis of the matrix by (-1,-1,-1,-1).

 

DirectX uses whatever handedness you choose to use. You can use it with left handed or right handed matrices.

 

Transposing a matrix does not convert between handedness; it converts between column-major storage and row-major storage. D3D's HLSL and GL's GLSL both operate on column-major storage by default, though fixed-function D3D, and the D3DX helpers often use row-major storage.

 

It also converts matrices that are designed to operate on row-vectors to ones that will work on column-vectors, and vice versa.

Whether you're using row-vectors or column-vectors depends on whether you write vector * matrix, or matrix * vector in your shader code.




#5044125 Light Prepass output color differences

Posted by Hodgman on 17 March 2013 - 10:16 PM

To get the same results with deferred-lighting and deferred-shading, your deferred-lighting "lighting accumulation buffer" has to accumulate diffuse and specular light seperately, so that later you can multiply them with the diffuse surface colour and specular surface colour, respectively. As long as you do that, they'll be the same.

 

The reason that many deferred-lighting systems are different, is because the above setup requires 6 channels in the accumulation buffer. As an optimization, you can instead just accumulate 4 channels -- the diffuse light RGB, and the specular light without any colour information. Later on, you can either treat all specular light as monochromatic, or you can 'guess' it's colour by looking at the accumulated diffuse colour.

[edit]

So if an object is affected by multiple lights, it will only apply the surface color to the output once vs the deferred shading approach which multiplies in the surface color for each light

Deferred shading does:

light0 * material + light1 * material + light2 * material

Deferred lighting does

(light0 + light1 + light2) * material

 

Both of these are exactly equivalent.




#5043894 How to build mesh position Matrix from COLLADA file?

Posted by Hodgman on 17 March 2013 - 01:03 AM

You just need to be able to parse the translate/rotate elements and build from them translation matrices and axis-angle rotation matrices, then multiply them all together in order. My parsing code for collada node transforms looks like:
            Matrix4 matrix = Matrix4.identity.Clone();
            XmlNodeList transforms = node.SelectNodes("c:rotate | c:translate | c:scale | c:skew | c:matrix | c:lookat", nsm);
            foreach (XmlNode transform in transforms)
            {
                string type = transform.Name;
                switch (type)
                {
                    case "rotate":
                        Vector4 rotation = Vector4.Parse(transform.InnerText);
                        matrix.MultiplyRotation(rotation);
                        break;
                    case "translate":
                        Vector4 translation = Vector4.Parse(transform.InnerText);
                        matrix.MultiplyTranslation(translation);
                        break;
                    case "scale":
                        Vector4 scaling = Vector4.Parse(transform.InnerText);
                        matrix.MultiplyScaling(scaling);
                        break;
                    case "matrix":
                        Matrix4 transformMatrix = Matrix4.ParseRowMajor(transform.InnerText);
                        matrix.MultiplyInPlace(transformMatrix);
                        break;
                    default:
                    case "skew":
                    case "lookat":
                        throw new ApplicationException(String.Format("The {0} transform type isn't implemented!", type));
                }
            }
            newNode.local = matrix;
            newNode.global = Matrix4.Multiply(global, newNode.local);



#5043020 Magical if-statement

Posted by Hodgman on 14 March 2013 - 06:18 AM

Couldn't foo and bar also be declared volotile?
 

Yeah, without volatile foo==foo compiles to pseudo-asm like:

int reg0 = read(&foo);
bool reg1 = compare( reg0, reg0 );

But with volatile, it would compile to something like:

int reg0 = read(&foo);
int reg1 = read(&foo);
bool reg2 = compare( reg0, reg1 );

So if the memory at &foo is constantly changing, the comparison could possibly be false.

However, that kind of code should probably never be written. Generally if your code contains volatile, then you have a bug tongue.png 

About the only place it's valid to see that keyword used, would be inside the implementation of std::atomic.






PARTNERS