Pawn storm, should I start with h4 or g4? If Black has castled kingside and White castled queenside or kingside, and White wants to launch an attack by a pawn storm. How do you know that you should start with h4 first or g4 first? I know that it depends on the pawn structure of Black. 

1) Black can have a kings-indian or dragon sicilian setup around the king (Bishop on g7, knight on f6, and pawns on f7 g6 h7). In these examples, how should white start the pawn storm

[fen "rnbq1r2/pp2ppbk/2pp1npp/8/2PPP3/2N1BP2/PP1Q2PP/R3KBNR w KQ - 2 9"]




[fen "r1bqr1k1/pp2ppbp/2np1np1/8/3NP3/2N1BP2/PPPQ2PP/2KR1B1R w - - 6 10"]




[fen "r1bq1rk1/p4p1p/2p1p1p1/3n4/3Q4/2N2P2/PPP3PP/2KR1B1R w - - 0 14"]


2) A QGD pawn setup (knight on f6, pawns on f7 g7 h7). 

In this example where black committed g6, how should white start the pawn storm?

[fen "r3r1k1/pp2bp1p/4pnpB/q3N3/2Pp1Q2/8/PP3PPP/3RR1K1 w - - 4 20"]


If Black plays pawn to h6 to defend, then with which pawn should White start the attack? g4 or h4? And if Black doesn't move the pawns (pawns on f7 g7 h7), then how should white start the pawn storm?
Typically you use a pawn storm to exchange pawns around the castled enemy king and thereby to open lines and diagonals for an attack. Most of the time you want a closed (to some extent) center in order to avoid counterplay in the center.

In this sense your example 4 is not a typical use case for a pawn storm. It might make sense to push the pawns here as well, but the reason for that are concrete tactical motifs. E.g. by playing g4-g5 you seem to force black to exchange the bishop for the knight after which there are ideas with Qg7 mate...

Other than that, it depends a lot on the actual position. 

A typical defensive strategy is to block the advancing pawns, thereby halting the pawn storm. In your first example you need to consider that if you play g5 black can block with h5, if you play h5, black can block with g5. To break such blockades, you could consider piece sacrifices (for a pawn or two) or what options you have by pushing the f pawn. 

In your second example, if you play g5, black can block with Nh5. In your third example, playing first g4 leaves you with lots of weak dark squares that are eyed by the black queen and knight. Playing first h4 here seems like a much better choice (if you had to decide between g4 or h4).



Some general guidelines (but as mentioned above, don't follow these blindly) depending on the opponent's pawn structure (of course the same applies to exchanged colors):

Pawns on f7-g7-h7


typically broken by playing g6 supported by a pawn from h5. See English attack in the Najdorf Sicilian.
You could also attack with h6, but this really only makes sense if you can make use of the dark squares, e.g. if you have a queen, dark squared bishop... that can enter via the a1-h8 diagonal or if you have a knight that could use the outpost that forms on f6.


Pawns on f7-g6-h7


Break with h5. Most of the time you want rooks on the h-file for the attack, when the h-file opens. See Yugoslav attack in the Sicilian Dragon.
Need to consider whether black can close the position with g5 after you play h5. Therefore in some cases, white wants to play g5 before h5.


Pawns on f7-g6-h6


This is a flexible setup for black, because whether you play h5 or g5, black can always block replying g5 or h5 respectively. 
One idea to break it is with a pawn on f4, so as white you aim for h5 but have a pawn on f4 (ready or can play later) in order to prevent the blocking with g5.
Another idea to break it is tactically. Often you end up with such positions, like in your first example, with Qd2, Be3 and Kh7. A typical tactical idea then is to play Ng5 with a white pawn on h4 and a rook on h1. If black takes the pawn hxg5, white opens the h-file with hxg5 check which very often is deadly.


Pawns on f6-g7-h7


You'd go for the f6 pawn by playing g5. Need to consider, whehter black can reply with f5 after which there is not much of an attack.
Sometimes you could follow up with h5-h6 with the idea that the g7 pawn moves and cannot recapture on f6.
See attacks against the Sämisch in the Kings Indian. (i.e. pawn storm by black)




As mentioned these don't work all the time and depend on the concrete position. If you consider the potential for blocking the pawn advance, by closing the structure, which pawn to push often comes naturally.

I'd recommend to look at some of these attacks in actual games. You can use the openings mentioned above as a guideline.