Daddy needs a new pair of RAM!

edit: the fps are way better in smaller terminal windows with lower character count but then it's hard to make out the dice. D:

edit2: code here (expires in 2 weeks)

all 98 comments

sorted by: hot top controversial new old
[–] 41 points 2 months ago (2 children)

One of my favourite things in the entire world is what I call "high effort shitposts". Running DOOM on absurd devices like pregnancy tests is the archetypical example I use when explaining this.

Well, congrats, because this is absurd enough that this makes the list too. You are ridiculous and delightful, and I am glad that you exist to create impressive horrors like this.

  • source
  • hideshow 2 child comments
  • [–] [S] 18 points 2 months ago

    Thank you so much! I love high effort shitposts too!

    And if you liked that, you're going to love this: A while ago I also wrote a 3d renderer from scratch inside the picotron, an emulated fantasy console that never existed, to display a 3d model of a pudu.

    I have a few more of these you might appreciate, non 3d related.

  • source
  • parent
  • [–] 36 points 2 months ago (28 children)

    Get this on the berg I wanna render my dice rolls over SSH stat

  • source
  • hideshow 28 child comments
  • [–] [S] 15 points 2 months ago (18 children)

    lol but it's not finished and everyone will see how stupid my code (and brain) is D:

  • source
  • parent
  • hideshow 18 child comments
  • [–] 9 points 2 months ago (2 children)

    My suggestion is do it. Its a cool project, and clearly there is interest from others who could contribute to the project by suggestions, bug fixing, or general collaboration, helping you learn. Just add some kind of disclaimer in the project that its not ready yet, and that youre still learning and it should be fine.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 6 points 2 months ago (3 children)

    The only way to do it is to do it - me, 2026

    Nah, but seriously, that insecurity is a disease that will actually make you produce embarrassing code. As soon as you feel confidence feedback take off, you will paint the functions brilliant once you de-neuter your inner codebeast. It wants to fuck. Let it.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 8 points 2 months ago (4 children)

    I hope you change your mind.

    Most people care about features, not the implementation.

    Those who dislike your code are probably going to generally dislike others’ code anyways, so in a sense they don’t even need to see your code to already disapprove of it 🤷‍♀️

  • source
  • parent
  • hideshow 4 child comments
  • [–] [S] 6 points 2 months ago

    Well, you guys are making some p good points. I'll probably end up sharing it, but'll give it a clean up, try to fix some bugs and improve my comments before posting it publicly. For now whoever really wants it (including you) can just ask and I'll dm it, understanding it will be a hard read and still has bugs.

  • source
  • parent
  • [–] [S] 3 points 2 months ago (2 children)
  • [–] 2 points 2 months ago

    Haha there is no shame in shell code, it’s already monstrous to start!

    I’ve written things in shell that would look sooo nice and concise in any other language, but it became a Cthulu-ass demigorgon so quick in shell! Have no fear, fear is the mind killer, the little death!

  • source
  • parent
  • [–] [S] 6 points 2 months ago (8 children)
  • [–] 4 points 2 months ago (7 children)

    When I opened the code I immediately scrolled to the bottom to see how many lines, and hell yeah. I read through it and I'm horrified, but I'm even more horrified it works. This is truly an chievement

    Here it is running over SSH https://files.catbox.moe/qkwd4q.mp4 what more could I ask for, thank you for making this insane thing and sharing it!

  • source
  • parent
  • hideshow 7 child comments
  • [–] [S] 5 points 2 months ago (6 children)

    holy shit, I'm so flattered! Thank you for your kind support and encouragement!

    It's crazy that it looks okaish right? quaternions, dude. I have implemented them in 3 projects and still have no fucking idea how they work.

    Also, you can run it in --quality low if you're struggling with framerate. :)

  • source
  • parent
  • hideshow 6 child comments
  • [–] 3 points 2 months ago* (last edited 2 months ago) (5 children)

    It's insane how many features this has for being insane in of itself!

    Edit: that was running on anemic "1 core" VPS, bumping it up to 4, hooboy do those dice fly

  • source
  • parent
  • hideshow 5 child comments
  • [–] [S] 2 points 2 months ago (4 children)

    nice! I'm still working on and have kept adding features. the encouragement was really motivating, so now I'm finishing multi-dice rolls that later add the result of all rolls.

    If you want an updated version later on, would be glad to share w you. :)

  • source
  • parent
  • hideshow 4 child comments
  • [–] 2 points 2 months ago (3 children)
  • [–] 33 points 2 months ago (11 children)

    I'm curious why it seems the time slows down at the end compared to reality? Because more computation is needed to check if it's a stable state?

  • source
  • hideshow 11 child comments
  • [–] [S] 29 points 2 months ago (10 children)

    the final resolution stage was a huge headache and as you can see, one I didn't fully solve. Basically when the dice finally settle, particularly those with more sides, lots and lots of micro collisions happen in close sequence, each one having to apply friction and bounce back. As velocities come close to be rounded to 0, the bounce back effect and force of gravity no longer provide movement, but the final angle of the bottom face may not be fully settled on the floor. So basically if i don't ignore all these tiny collisions I get the frame rate drop you see and if I do, I can arrive at not fully settled states which can become ambiguous result-wise in, say, the 20-sided die.

  • source
  • parent
  • hideshow 10 child comments
  • [–] 8 points 2 months ago (5 children)

    Can you predict the resolution when it is close enough to settled? Worst case maybe have an algorithm that estimates the probability of each face ending up on top, and if one face is overwhelmingly more probably, choose it. Otherwise let it settle using your physics engine

  • source
  • parent
  • hideshow 5 child comments
  • [–] [S] 7 points 2 months ago (4 children)

    I can easily check for when motion stops, but checking for when any particular face is both parallel to the floor and at the same level can be computationally expensive, particularly in the dice with more sides. What you're suggesting is likely a good idea, but I wouldn't know how to get probabilities without doing what I just mentioned. I'm sure there's an optimization i can do with this that I can't think of rn.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 7 points 2 months ago* (2 children)

    maybe just "if velocity < 0.01, find which side is closest to the floor, and if its within 1mm of the floor, take the opposite side (the one facing up) as the answer"

    The only edge case I can think of is if it gets close to balancing on an edge, and then finally tips over to one side or the other. But in that case I don't think the face closest to the floor would be within 1mm of the floor, so it should still work.

  • source
  • parent
  • hideshow 2 child comments
  • [–] [S] 5 points 2 months ago (1 child)

    that's how it's implemented, mostly, but sometimes dice "stop" while they're still tilted and standing on a corner (and then roll back down, possibly going back more than 1 face) so there's also that.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 3 points 2 months ago*

    Cross products! If you take the cross product of two edges of a face, you get a perpendicular vector for that face. It shouldn’t be too bad to do 20 of those per frame to find if a face is level with the ground (cross product points straight up and/or down depending on how you’re doing them)… now I don’t know about the velocity/acceleration numbers (including rotation)…

  • source
  • parent
  • [–] 2 points 2 months ago (1 child)

    Since you're rolling on a plane, can't you simplify the collisions to only check the corners? I think that should be all that's needed. There shouldn't be a time where the edges or faces are below the lowest corner on a plane, so they can be skipped I believe.

  • source
  • parent
  • hideshow 1 child comment
  • [–] [S] 2 points 2 months ago

    i need to check the corner collisions but when the die start settling and an entire edge comes close to the floor, gravity keeps pulling back on several of them making them bounce back just a tiny bit, not reaching the velocity that gets rounded to zero.

    I fixed that on the current version doe!

  • source
  • parent
  • [–] 1 point 2 months ago (1 child)

    why not save the state of the di(ce) in the settling phase and choose (or allow user assignable) value for how many consecutive identicle states before freezing the di(ce) and reporting the result?

    my only concern would be a "spinning" di but short of colliding with other dice, that seems technically solved

  • source
  • parent
  • hideshow 1 child comment
  • [–] 21 points 2 months ago (1 child)

    Are you often described as a masochist?

    It looks neat. I can't imagine wanting to write it in bash, though, heh.

  • source
  • hideshow 1 child comment
  • [+] 18 points 2 months ago (1 child)
  • [–] 16 points 2 months ago (3 children)

    I just woke up and this is the first thing I see. Did I really woke up?

  • source
  • hideshow 3 child comments
  • [–] 15 points 2 months ago (11 children)

    Haha nice! How long did it take you? Integer-only math?

  • source
  • hideshow 11 child comments
  • [–] [S] 15 points 2 months ago (3 children)

    Jebus I don't even know how long I've been working on this. It started out as a way to teach myself bash, combined with my long obsession with rendering platonic solids. I previously coded a huge galaxy of hundreds of thousands of polyhedra you could fly across in python with opengl shaders and got to reuse/translate a lot of that code. The quaternion stuff I was grateful to not have to rethink that much again. haha. And yes, integer-only! Some params are "floating point" but i just parse them and add a bunch of zeroes so i can later do all the operations with equally blown up values of pi and trig stuff from "lookup tables" (case matching).

  • source
  • parent
  • hideshow 3 child comments
  • [–] 21 points 2 months ago (6 children)

    All computer math is integer math if you go deep enough

  • source
  • parent
  • hideshow 6 child comments
  • [–] 8 points 2 months ago (5 children)

    I'm sure implementing floating point directly in bash would work great

  • source
  • parent
  • hideshow 5 child comments
  • [–] 16 points 2 months ago (2 children)

    I didn't have the patience to do it myself bit wanted to see just how complex it would get:

    fp32_mul() {
        local a=$1 b=$2
        local sa=$(( (a >> 31) & 1 ))
        local sb=$(( (b >> 31) & 1 ))
        local sign=$((sa ^ sb))
    
        local ea=$(( (a >> 23) & 0xff ))
        local eb=$(( (b >> 23) & 0xff ))
        local fa=$(( a & 0x7fffff ))
        local fb=$(( b & 0x7fffff ))
    
        # NaN / infinity / zero handling
        if (( ea == 255 )); then
            if (( fa != 0 )); then
                printf '%08x\n' $((0x7fc00000))
                return
            fi
            if (( eb == 0 && fb == 0 )); then
                printf '%08x\n' $((0x7fc00000))   # inf * 0 = NaN
                return
            fi
            printf '%08x\n' $(((sign << 31) | 0x7f800000))
            return
        fi
    
        if (( eb == 255 )); then
            if (( fb != 0 )); then
                printf '%08x\n' $((0x7fc00000))
                return
            fi
            if (( ea == 0 && fa == 0 )); then
                printf '%08x\n' $((0x7fc00000))
                return
            fi
            printf '%08x\n' $(((sign << 31) | 0x7f800000))
            return
        fi
    
        if (( ea == 0 && fa == 0 || eb == 0 && fb == 0 )); then
            printf '%08x\n' $((sign << 31))
            return
        fi
    
        # Convert subnormals to a normalized significand/exponent.
        # m is a 24-bit significand for normals.
        local ma mb
        if (( ea == 0 )); then
            ma=$fa
            ea=1
            while (( (ma & 0x800000) == 0 )); do
                ma=$((ma << 1))
                ((ea--))
            done
        else
            ma=$((fa | 0x800000))
        fi
    
        if (( eb == 0 )); then
            mb=$fb
            eb=1
            while (( (mb & 0x800000) == 0 )); do
                mb=$((mb << 1))
                ((eb--))
            done
        else
            mb=$((fb | 0x800000))
        fi
    
        # Multiply the two 24-bit significands.
        # Product is up to 48 bits.
        local p=$((ma * mb))
        local e=$((ea + eb - 127))
    
        # Normalize product.
        #
        # ma*mb has binary point after bit 46.  If bit 47 is set,
        # product is [2,4), otherwise [1,2).
        local shift
        if (( p & 0x800000000000 )); then
            shift=24
            ((e++))
        else
            shift=23
        fi
    
        # Extract 23 fraction bits plus guard/round/sticky information.
        local frac=$(( (p >> shift) & 0x7fffff ))
        local guard=$(( (p >> (shift - 1)) & 1 ))
        local round=$(( (p >> (shift - 2)) & 1 ))
        local sticky=0
    
        if (( shift >= 3 )); then
            local mask=$(( (1 << (shift - 2)) - 1 ))
            (( (p & mask) != 0 )) && sticky=1
        fi
    
        # Round-to-nearest, ties-to-even.
        if (( guard && (round || sticky || (frac & 1)) )); then
            ((frac++))
            if (( frac == 0x800000 )); then
                frac=0
                ((e++))
            fi
        fi
    
        # Overflow -> infinity.
        if (( e >= 255 )); then
            printf '%08x\n' $(((sign << 31) | 0x7f800000))
            return
        fi
    
        # Normal result.
        if (( e > 0 )); then
            printf '%08x\n' $(((sign << 31) | (e << 23) | frac))
            return
        fi
    
        # Underflow into the subnormal range.
        #
        # At this point the normalized significand represented by
        # (1.frac) must be shifted right by 1-e positions.
        local mant=$((0x800000 | frac))
        local rshift=$((1 - e))
        local lost=0
        local halfway=0
        local low=0
    
        if (( rshift >= 25 )); then
            # Everything rounds to zero (unless the exact value is
            # sufficiently close, which it cannot be here).
            mant=0
        else
            low=$((mant & ((1 << rshift) - 1)))
            mant=$((mant >> rshift))
    
            halfway=$((1 << (rshift - 1)))
    
            if (( low > halfway || (low == halfway && (mant & 1)) )); then
                ((mant++))
            fi
        fi
    
        # Rounding a subnormal can produce the smallest normal.
        if (( mant >= 0x800000 )); then
            printf '%08x\n' $(((sign << 31) | (1 << 23)))
        else
            printf '%08x\n' $(((sign << 31) | mant))
        fi
    }
    
  • source
  • parent
  • hideshow 2 child comments
  • [–] 15 points 2 months ago

    Absolutely insane. Part of me wants to see the source code, but part of me is terrified of how complex it must be. Plus I've only been writing bash for 20 years, so it would probably look incomprehensible to me.

  • source
  • [–] 14 points 2 months ago (1 child)

    @Pudutr0n@lemmy.world - You are certifiably insane. There are a million more effective ways to achieve this, with less resources... I LOVE IT.

  • source
  • hideshow 1 child comment
  • [–] 14 points 2 months ago (2 children)

    (hopefully) Constructive critique:

    • it looks like you're handling the dice in physics as a ball? Takes forever to settle at the end.
    • the throw has a visual glitch.
  • source
  • hideshow 2 child comments
  • [–] [S] 14 points 2 months ago (1 child)

    Thanks! Yeah, there's definitely A LOT of room for improvement. collisions are handled per vertex, but torque is applied to angular impulse to the dice as a whole (like a ball I guess). The settling is a huge issue, yes. the visual glitches I've been trying to get rid of but man... fix one and then another one pops up in a different case. Thanks for your critique. :)

  • source
  • parent
  • hideshow 1 child comment
  • [–] 13 points 2 months ago (1 child)

    This is beautiful, and insane! But truly beautiful hahaha

  • source
  • hideshow 1 child comment
  • [–] 8 points 2 months ago* (last edited 2 months ago) (1 child)

    3D dice rolling...ok...😐 ... in bash ...🤨 !?

    PS: I remember seeing something vaguely like this recently...this you?

  • source
  • hideshow 1 child comment
  • [–] 8 points 2 months ago (1 child)

    I didn't know I needed this.

  • source
  • hideshow 1 child comment
  • [–] 7 points 2 months ago (1 child)
  • [–] 6 points 2 months ago

    Holy crap how cool

  • source
  • AI killed like 10 whales for this.

  • source
  • [–] 5 points 2 months ago (1 child)

    Looks like a great sl replacement! Gonna need this on every machine.

  • source
  • hideshow 1 child comment
  • [–] 8 points 2 months ago (12 children)

    I'm viewing this thread in Lemmy and am unable to find any mention of a link to the source code or a demo, and I can't see the attached media (genetic image icon - is it an animated gif or a video?).

    Based on all the comments, I appear to be in the [significant] minority. Would you mind posting a link to your source or demo or image/video?

  • source
  • hideshow 12 child comments
  • [–] [S] 19 points 2 months ago (10 children)

    I haven't shared the source code yet because criticism is terrifying and I'm a horrible coder, but with the encouragement of the the community I might give it a shot. I don't even have a codeberg account yet though.

    The post contains these two video links: https://files.catbox.moe/8rz9m7.mp4 https://files.catbox.moe/5d3n2k.mp4

    If you still can't see them, maybe you can suggest a different hosting service, one that works for you? Or if you really really want the source code I suppose I could send it by DM on the meantime.

  • source
  • parent
  • hideshow 10 child comments
  • [–] 6 points 2 months ago (5 children)

    Just letting you know the original post video didn't load and gave a 500 error in jerboa but those two links work. Looks impressive but I'm confused on how to read the die. Yes there is a giant banner telling me the value it chose but I'm struggling to figure out how the visuals map to those values, can you give some details on how to read the die?

  • source
  • parent
  • hideshow 5 child comments
  • [–] [S] 6 points 2 months ago* (last edited 2 months ago) (4 children)

    Yes, the values are rendered on top of each face with "pixel" maps (ascii art) that have the character of the digit they represent as each pixel. These are later manipulated by the perspective projection.

    For example on this d6 you can see the top face has 1s written down (in the shape of a sideways one) and the front one has 4s written down in the shape of a skewed and sideways 4.

    In this specific color scheme there's not a lot of contrast between the values, but even in the palettes with better contrast, good readability is something I'm kind of giving up on solving well.

    edit: might be clearer here:

  • source
  • parent
  • hideshow 4 child comments
  • [–] 2 points 2 months ago (3 children)

    In the second picture (with the d20) I'm guessing the face with "999" is actually a 9 but what is the value of the face with "999#111"...there is no value of 91 on a d20 :)

  • source
  • parent
  • hideshow 3 child comments
  • [–] [S] 1 point 2 months ago (2 children)

    actually I was working on the code and realized i got the textures mirrored due to negative-positive mix up. so it was reflecting the mirror image of 19

  • source
  • parent
  • hideshow 2 child comments
  • [–] 3 points 2 months ago

    this is fucking CONTENT, baby!!! Great work, honestly great code. This is an achievement.

  • source
  • [–] 2 points 1 month ago* (1 child)

    Any chance you can share the code again please?

  • source
  • hideshow 1 child comment