Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Ashaman73

Member Since 10 Nov 2006
Offline Last Active May 17 2013 04:55 AM
*****

#5062035 MVC: Struggling to remove graphics from the model

Posted by Ashaman73 on 15 May 2013 - 07:22 AM

What is the best way to solve this? I could add an enumerated "type" field to the Unit class, but this feels wrong as it's polluting the model with data that it doesn't care about, but I really can't see any other way of doing this.

This is the way I would do it. The model should contain all important information, not only information you need for some calculations, but although data which are used to communicate important infos to the player, like a unit type (ah.. a goblin which seems to be quite weak).

 

Even a model name would be ok, all other model related data, like textures, mesh, animation description etc. are then included in view/controller.




#5055933 Is UML worth learning for a beginner in OOP?

Posted by Ashaman73 on 22 April 2013 - 11:19 PM

But that aside, do you think learning system modelling with UML will actually help to refine my concept and skills of OOP?

Besides being an industry standard, UML is a very good visualisation of OOP. Though not all diagram types will be of personal use, at least the class diagrams will be of help to visualize OOP better.




#5054468 Glsl - Which is faster: lots of if statements or lots of seperate shaders?

Posted by Ashaman73 on 18 April 2013 - 01:53 AM

There's no general rule. On one hand, a specialist shader is often faster than a more general uber-shader with a lot of branches. But if you need to subdivide a shader into mutliple passes, you could get in trouble with bandwidth or with state changes if you over-do the number of shaders (e.g. each object get its own shader, so that batching is impossible).

 

An other option is, to write an uber shader, but to use pre-processor statements instead of dynamic conditions to generate the shader you need on-the-fly.




#5054447 Spherical harmonics in pixel shader

Posted by Ashaman73 on 17 April 2013 - 11:38 PM

Am I on the right track with this ? As I can see from other demos, the compute spherical harmonics per vertex ? I tend to do it in my deferred lighting pass per pixel ?

How to sample a spherical harmonics "matrix" ( a set of float values ) using my direction normal to get the illumination value at that point ? I now sample my cube maps with my direction normals, but I want to use spherical harmonics to store the data more efficiently.

I'm not an expert with SH, but here are some directions which might be helpful.

 

Spherical harmonics, like a standard sphere or a cube map, is an approximation of the incoming light from a certain direction. A cube map is really hi-quality with an according resolution. SH on the other hand is a compression. A very simple compression would be to have a direction vector and an intensity to describe from which direction the most light is coming, this case would be a 4 component vector (dirX,dirY,dirZ,intensity). This is basically, more or less (not 100% correct ?), a simple SH, which is often refered as AO term (though often only the intensity without direction is saved as single component).

 

Now to expand the idea, you can use SH, which improve the resolution of the approximation by adding more components to the vector, so a 9 component SH has a better resolution as a 4 component SH. So, some games (Halo??) use a SH X-component term and save this as lightmap (not only on vertex base) to simulate a pre-computed global illumination. But it should be clear, that you will need huge amounts of memory to save this term in a proper resolution (9 floats per pixel are not really light weight).




#5054106 Projective Texturing

Posted by Ashaman73 on 17 April 2013 - 12:13 AM

I've tried to mimic a sort of spotlight shadow technique but wasn't able to get that to work since there are pretty much no tutorials on shadows for deferred shading pipelines.

I fear, that you need a shadow mapping approach to solve this problem.The benefit of projective textures is, that you often don't need a shadow mapping approach (which makes it a lot slower), therefor my first tip would be, to accept the artefact and restrict the projection range (quantity vs quality). You've already implemented CSM and point light shadows, the principle is all the same:

 

Reconstruct the point in camera space and reproject it into the projection (shadow camera) space, then get the shadow value, if it is in shadow, discard the pixel. If it is not in shadow, use the xy shadowmap coord to access the projection texture.




#5054105 Write to FBO vs CopyTexImage

Posted by Ashaman73 on 17 April 2013 - 12:05 AM

In this special case I would say, that when you write to multiple targets (FBO+screen buffer), that you save bandwidth by not reading from the source buffer when using the copy operation.

 

If you like to use the copy operation, remember, that a copy operation will most likely be like a single full-screen (simple)shader pass, therefor try to add more value to the copy operation by using a customized shader. E.g. instead of a simple copy operation use a shader which downscales the image to 1/4 of the original screen size which can be used to further operations like blur, heat etc.




#5053814 Starting a FPS game ideas on where to begin?

Posted by Ashaman73 on 16 April 2013 - 07:07 AM

An other option is to modify an existing game (preferable a FPS game) to your liking. This is quite common, games like Counter Strike, Team Fortress or Natural Selection starts all as mods and even today mods like DayZ are really popular. The benefit is, that you already have a working basic game at hands, you can use art and still you can learn to script your own game, see how game engines works etc.




#5053812 Alpha blending, deferred + forward pass issue

Posted by Ashaman73 on 16 April 2013 - 07:03 AM

Shouldn't the depth test tell it that this pixel should be discarded becaused the opaque geometry is in front of it ?

Yes, this should work. First render the opaque with depth test and depth write, then render the (sorted) transparent geometry with only depth test. Therefor check your depth test/write parameters.




#5053772 Multipass forward rendering?

Posted by Ashaman73 on 16 April 2013 - 04:16 AM

I've read something about multipass forward rendering.. but I don't know really what it means, and I cannot find any good sources. From what I've gathered so far, it involves rendering each mesh a number of times equal to the number of lights that affects it and then somehow add the results? So for example if I have one mesh affected by 3 lights, I would render it three times and blend the results?

Yes, light is additive and you can calculate one or more lights in a single pass and add it (blend one/one) to the buffer. Basicly you have two shaders, a base light shader (containing emissive/ambient light) and an additive light shader. The base shader should already handle more than one light (8 sounds good), and for each (8-) block of additional lights render the scene in an additional pass using additve blending.

 

As you can already see, this will scale really badly with scene complexity/number of lights, therefor you should either optimize it (not each light affects each face) or switch over to deferred rendering/lighting which scales really great only with number of lights.




#5049529 Some basic questions from a beginner

Posted by Ashaman73 on 03 April 2013 - 05:42 AM

1) Now that I plan on starting again, I don't know if I should either expand on my base or start all over again. Meaning, should I stick with C++ as hard as it is, or give in to the people who suggest Java? I'm asking this mostly because I have to buy a book, but my budget is limited so I can buy only one book at a time.

Both languages are valid for game development, though C/C++ seems to be still the main AAA game industry language around. If you want to develop for PC and are familiar with C++, then stick to it. If you consider to make a web-based game or android etc., Java is a good idea.

 

So, what knowledge is needed to mod a game? Will this knowledge be included in the regular path (learning how to program in general, making simple games, then moving into modding) or is it a separate route to follow?

Modding is a good way to learn game development. You have an already working game, including art, and you will get into contact with game tools and programming languages, though often only scripting languages. If your primary goal is to learn a programming language, the other way around (e.g. start small with a text adventure ) might be more suitable.

 

4) Any other suggestions for a beginner are more than welcome!

Start small and simple, complexity will come without invitation :)




#5049487 Structured code incorrectly? References are bad choice in provided case? Help...

Posted by Ashaman73 on 03 April 2013 - 02:33 AM

I think, that the goal is to have a utility/worker class which accepts two external units which will be proceed later (actually it is quite hard to guess what is the goal of this code smile.png ). Maybe something like this:

//I have a class that is like this
class WorkerClass
{

private:
Unit *unit1;
Unit *unit2;

public:

void DoStuff();
void SetUnits(Unit &unit1, Unit &unit2);
};
void WorkerClass::SetUnits(Unit &pUnit1, Unit &pUnit2)
{
unit1 = &pUnit1;
unit2 = &pUnit2;
}

void WorkerClass::DoStuff()
{
//Change data around in unit1
//Change data around in unit2
}

The set method enforces real objects as parameter (NULL is not allowed), yet the workerclass works internally on pointers only.




#5049146 Coming up with new, but recognisable races. Reinventing the wheel in a good way.

Posted by Ashaman73 on 02 April 2013 - 06:12 AM

If you want to create a new and recognisable race you should start with the name. Many people tend to rate a fantasy race just by the name, which gets even harder if the name or description of a race sounds similar to any stereotypically fantasy race.

 

The (arguable) "new" race in my game is called Gnoblins, a mix of Gnome and Goblins, is always recognised as a 'lame try to rename Goblins to Gnoblins', nobody will ever read the part where you explain, that these are not goblins at all..

 

PS: nice art work




#5049109 java.lang.String split

Posted by Ashaman73 on 02 April 2013 - 03:42 AM

There's an optional second parameter, try this

"xyz".split(",",-1)




#5046809 for each, in - copying std::map elements?

Posted by Ashaman73 on 26 March 2013 - 03:07 AM

The description hereof the for each method has been corrected at the bottom of the page:

for each returns read only objects There is an error under the section Remarks in paragraph 1.

It is not possible to update the elements in a collection by updating the element that is returned by the for each command. The for each command returns an object by value, not by reference.

 

 

This should not lead to a const error:

void KeyMap::update() {
  std::map<unsigned int, VirtualKey>::iterator iter = m_keys.begin();
  iter->second.update();
  return;
}
}



#5046787 Is it bad to use an IDE when you're just starting out with programming in...

Posted by Ashaman73 on 26 March 2013 - 01:29 AM

An IDE is not for learning stuff, it is to increase your efficiency once a text editor limit it. Getting into an IDE is not really trivial, especially eclipse etc. are not trivial at all. Therefor I would always sugguest to start with a simple text editor which supports syntax highlighting, much like Notepad++. Come on, it is just

 

javac test.java
java -cp . test

 

to compile and run a simple test java class.

 

Once you feel, that you have a good hold of the language and you think that a text editor is a clumpsy way to develop, you should consider using an IDE.

 

PS: this is java, not C++. Developing your first "Hello World" in java is really simple without using an IDE. An IDE is just a tool, which will not make a better developer out of you (thought a faster one).






PARTNERS