Antistar,
Funny you should ask.
The main muscle groups involved in vertical jumping are the thighs (quads & hams) and the glutes (buttocks). Of course, whether or not one can dunk will also be affected by other factors – such as height, arm length, over all bodyweight and other genetic factors (such as ratio of white [fast-twitch] muscle fibers to red [slow-twitch] muscle fibers in those 2 muscle groups – thighs & buttocks). But I believe that anybody can improve their vertical jump, and by several inches at least.
What I recommend are BB Squats – but not the way that powerlifters do them (bar low on the back, below the delts; torso bent way forward; and taking thighs only to parallel). Screw that, that’s just for squeezing out every pound you can at a contest.
Do the squats Olympic style – “high bar” (bar up on the traps, at base of neck), torso straight up (perpendicular to the floor), and take it “into the bucket” (as deeply as you can possibly go) – besides, this is the best style of squatting to hit those jumping muscles (thighs & glutes both).
First stretch out well (quads & hams – especially hams, because if they’re tight you’ll put unnecessary strain on your lower back). Start out slowly, always warming up well – especially if you’re training in an environment below 70°F. Do each rep slowly and deliberately, focusing your “work sets” in the 4-8 range for the 1st few months. Attempt a new max every couple weeks. Train like this until you can fullsquat at least 1.5 x bodyweight. This phase trains your ROM for squats, conditions your muscles, and develops the requisite levels of absolute strength for the next phase.
Phase II: 2 times per week (attempt max about 1x per month – but don’t do any worksets that day, just the warmup, then the max, then pack it in).
Heavy Day: stretch, warmup, then: 73% x 1, 77% x 1, 83% x 1, 88% / 2-3 singles;
“Plyometric sets”: 77% / 1 or 2 singles, 82% x 1
Light Day: stretch, warmup, then: 50% x 5, 56% x 3;
“Plyometric sets”: 62% / 3 x 3, 65% / 2 x 3, 68% / 2 x 2
Plyometric sets are to be done: (1) only after you can squat at least 1.5 x bodyweight, (2) have squatted at least a few months, and (3) are thoroughly stretched & warmed up.
How: These are basically “speed reps,” and as such, carry some risk (though I was never injured doing them – and, as you can see, you rarely go above 68% of your 1RM while doing them - and never above 82%). You’re doing fullsquats, as described above, and maintain perfect form at all times. You descend quickly, but NOT “out of control.” You take advantage of the rebound effect at the bottom, and you propel yourself upwards AS QUICKLY AS POSSIBLE. I mean, it’s like a deep vertical jump with a bar on your back. Always strive to ascend ever faster – that’s where the real benefits are (but never at the expense of perfect form).
BUT ALWAYS MAINTAIN PERFECT FORM & BREATHE PROPERLY (inhale on descent, exhale on ascent – never hold your breath while squatting – there’s something I believe is called “Valsalva Effect” which can cause you to pass out – not good, especially with a weight on your shoulders).
A few tips: Try not to let your knees drift out in front of your toes (puts too much strain on patella area); also, don’t allow your knees to drift together, keep them where they are throughout the lift); and focus your eyes on a spot on the wall, and stare at it throughout the movement – also, always keep your head up, never look down at the floor.
I’ve trained 4 guys over the years who desperately wanted inches on their vertical jump – and all of them saw significant progress in 6 months or less.
If you wanted to continue beyond 6 months, then cycling would come into play - although that's a bit detailed for now. If you're interested, give this approach a shot - I bet you'll be very pleasantly surprised.