So, the penalties that are applied when two characters are in darkness, attacking each other, are perfectly clear in the Pathfinder rules:
In an area of dim light, a character can see somewhat. Creatures within this area have concealment (20% miss chance in combat) from those without darkvision or the ability to see in darkness.
In areas of darkness, creatures without darkvision are effectively blinded. In addition to the obvious effects, a blinded creature has a 50% miss chance in combat (all opponents have total concealment), loses any Dexterity bonus to AC, takes a –2 penalty to AC, and takes a –4 penalty on Perception checks that rely on sight and most Strength- and Dexterity-based skill checks.
Clearly, two enemies in the same light level are going to have a miss chance and possibly no dex bonus and a penalty to AC.
Where the problem comes in is when there are two enemies in different light levels attacking eachother. In the following situations, who gets what penalty?
Xylitol, a wizard in bright light, is firing a scorching ray at Aspartame, a wizard in dim light. Aspartame fires a scorching ray back at Xylitol. By RAW, which wizard(s) get a 20% miss chance?
Aspartame casts deeper darkness, placing himself in darkness. Xylitol and Aspartame fire more scorching rays at each other. By RAW, which wizard(s) have a 50% miss chance, and which one(s) lose their Dex bonus to AC, take -2 to AC, and -4 to Perception checks?
Best Answer
In uniform, shared light levels, vision penalties due to darkness work fine, intuitively, and exactly as written (no surprises). The deeper the darkness, the more trouble you have seeing, hitting things, and protecting yourself.
This, however, isn't the case you're asking about.
Mixed lighting conditions
Let's stick with RAW to analyse this situation of two people in different lighting conditions. The results are almost entirely the same whether whether Aspartame is in magical darkness or the (possibly very dark) shadow of an oak tree. The results are going to be weird.
While Aspartame is in darkness, he is blinded.
Xylitol has a 20% miss chance still, if we interpret Aspartame as still having dim light concealment. Natural darkness doesn't provide concealmnet explicitly, just blinds people in it.
These results are pretty counter-intuitive. In real life, the rogue sneaking through the shadows has an advantage on everyone else, and you've probably handled it as such — the rogue themselves isn't blinded by being in the shadows, but they are in Pathfinder!
Pathfinder's vision penalties are counter-intuitive and weird because they don't correctly model vision as we know it: they give you trouble depending on the light level you're standing in, instead of giving you trouble based on the light level of the thing you're looking at. In reality I don't have trouble reading things in the dark because I'm in the dark, I have trouble because those things are.
Like I said though, they work fine when people are sharing the same light levels. They just weren't written with differing lighting conditions in mind and don't handle them well. The sacred RAW should be burned in this case upon the altar of This Could Have Been Written Better For These Cases. Rules are worth the results they produce, and here the results they produce are kinda dumb. Those who wish to apply it exactly because those are the rules can go ahead and suffer the headaches.
Drawing sense out of the ashes.
Pathfinder should probably just be modelling how things really work: darkness affects you based on what you're looking at, not what light level you're in. Accordingly, I'm making a recommendation that in mixed light levels, the RAW be interpreted for what it was probably intended to do — which just requires a small adjustment of the original RAW:
Wyrmwood brings up in comments that due to firing through concealment, firing past/through dim light introduces a 20% miss chance. This causes sense-making problems if you're on a long archery range, and a tall tree off to the side is casting a shadow across part of the middle of the range: those rules assert your target dummy now has concealment, despite still being in the bright daylight. These rules work fine for actual obstructions like black smoke, but not for light. I suggest that for the purposes of firing through concealment, don't count dim or dark squares — just count what it is you're targeting.
That produces these results, which are probably actually intuitive:
We get these results, again, whether the dim light or darkness is due to magic or the shade of an oak tree.