Shapecasts and Slopes

I'm trying to model character movement a bit better using "shapecasts." What I can't figure out is how to avoid climbing steep slopes.

Here's the algorithm I use to shapecast:
Code:
forward = normalized direction to move in
distance = distance to move in that direction
startingPosition = GetBodyPosition()
step = width of the thinnest shape in the body / 2

distanceSoFar = 0
while distanceSoFar < distance:

    // Move the body forward
    distanceSoFar = max( distance, distanceSoFar + step )
    SetBodyXForm( startingPosition + forward * distanceSoFar )
   
    // Figure out the maximum penetration in the forward direction, updating contacts
    maxPenetration = 0
    for each contact:
        contact.update()
        penetrationScale = dot( point.normal, forward )
        if penetrationScale <= epsilon:
            continue
        for each contact point:
            maxPenetration = max( -point.separation * penetrationScale, maxPenetration )
   
    // If there is any penetration, we're done
    // move back a bit so it's no longer penetrating
    if maxPenetration > 0:
        if maxPenetration > epsilon:
            SetBodyXForm( startingPosition + forward * ( distanceSoFar - penetration ) )
        break

// Return the distance traveled
return distanceSoFar


The simplest way I can make it work is to shapecast up, forward, then back down to try to touch the ground. This way, the character can both up and down slopes and stairs, and not get stuck on little pieces of rubble on the ground or rough surfaces. However, it fails when the ceiling slopes downward, and I can't figure out how to get it so the player treats steep slopes like walls, while still being able to climb them. Any ideas?
I've been trying this again, and nothing I do seems to work. The first thing I tried was a variation of the above, attempting to shift up or down as the player comes across obstacles. I got movement looking smooth, but I couldn't figure out how to get the character to not move up slopes.

Looking at old Quake code, I figured out a promising method involving sliding off surfaces:

Code:
displacement = amount to move
repeat over X iterations:
    Shapecast over displacement, moving as far as possible
    if close to end, return
    adjust the displacement vector so it slides up the slope based upon the normal of the object hit
    if we passed the original destination, return


The problem I'm having is how to find the normal of the object hit. The shapecast in the previous post may end up with many or no normals. I tried a different method for shapecasts involving time of impact, but that doesn't calculate normals, and slop makes it difficult to figure them out.

Original thread: https://box2d.org/forum/viewtopic.php?t=2893