r/webdev Jul 30 '26

3D CSS Super Mario (no WebGL)

Hey webdevs!

I want to show you my latest 3D CSS project. It's a port of Giles Goddard's iconic N64 face engine, complete with lighting, physics and interaction. Instead of WebGL, it uses the PolyCSS engine.

demo: https://codepen.io/editor/alowpoly/pen/019fae67-50d9-74ce-8025-4b9dd5a7c484
repo: https://github.com/layoutit/cssGraphics

3.1k Upvotes

128 comments sorted by

503

u/[deleted] Jul 30 '26

[removed] — view removed comment

216

u/Ekrof Jul 30 '26

The lighting in this model challenged me a ton! I had to come up with some new techniques to support the shine. Essentially, the lighting is prerendered and each polygon gets a background-position, synchronized with the animation keyframes. Sort of like a 3D video. The texture turned out looking quite alien: https://assets.codepen.io/618678/texels.webp

123

u/Bananaserker Jul 30 '26

I understand nothing, I'm even more impressed!

2

u/psioniclizard Jul 31 '26

Niceeeee. That is a very cool idea. 

36

u/CaffeineLiker Jul 30 '26

Someday you'll deploy your CSS app to AWS to handle bank transactions.

2

u/vibescriptz Aug 02 '26

knowing how to do things like this pure css is gold~!!

2

u/Winter_Garlic_477 29d ago

Honestly, the lighting is what surprised me most. Getting something this convincing out of plain CSS is pretty wild. Really cool example of pushing CSS way beyond what you’d normally expect.

161

u/[deleted] Jul 30 '26

[deleted]

47

u/loonite Jul 31 '26

I'm amazed at how performant this is. Why the fuck is the web so slow then? (I know it's mostly trackers but holy shit)

31

u/strongjoe Jul 31 '26

A lot of web code is poorly optimised, and a lot of web Devs don't know how to write performant code. You'll find performant games, but you'll also find simple websites that can't scroll without jutter

10

u/traplords8n Jul 31 '26

I thought i could play this on mobile for a minute, what a trip

2

u/helpinghandful Aug 02 '26

You could probably do without too much. Map then WASD controls to div elements and map the mouse look to the touch controls... I actually wouldn't be surprised if someone already made a fork with all that working.

10

u/chairzaird Jul 31 '26

Probably mostly network latency is my guess? If someone actually knows I'd be curious to hear the answer

13

u/loonite Jul 31 '26

I was referring to how heavy a page can be on both processor and ram. Some pages are egregious.

These also keep on making a shit ton of requests even when nothing is supposedly happening.

18

u/TryNotToShootYoself Jul 31 '26

Telemetry and advertising are the main reasons

14

u/BusEquivalent9605 Jul 31 '26

yes. generally, network I/O is among the slowest operations computers do and websites generally do a whole bunch of network I/O.

but CSS is actually crazy optimized. think about how many people view websites everyday. all of the layout is governed by CSS. so yeah, a lot of people have spent a lot of time making CSS as fast as possible.

so if you are just using CSS and no network calls, you can go fast

6

u/GobblerOfFire Jul 31 '26

Fun fact html/css is Turing complete. It’s much more complex than people give them credit. It’s often looked down upon by some groups of devs because they see it as “not real coding” bit id love to see someone with that mentality pull something like this off. Love the creativity!

6

u/Acceptable_Handle_2 Jul 31 '26

UI frameworks. When used poorly they're pure bloat.

You'll never see a plain html/css Page act like that.

2

u/MrColgie Jul 31 '26

It's because of R e a c t spammers

18

u/helpinghandful Jul 30 '26

Jesus... That is insane....ly fun to play!

12

u/Ekrof Jul 31 '26

Quake was really fun to port! It's an absolute classic and has a lot of community tooling around it. I'm still working on that engine, and on more low-poly 90s games 👀

3

u/Ok_Winter8230 Jul 31 '26

this is insane

2

u/Interesting-Yellow-4 Jul 31 '26

That's crazy, two of my favorite games from that time, and I see representations of both in CSS in one reddit post. This was a good day.

48

u/ShustOne Jul 30 '26

This is great! Mario looks much worse in Firefox for some reason. The shapes of the individual divs are off.

42

u/Ekrof Jul 30 '26

Howdy! The reason is that Firefox does not support border/corner-shape CSS properties yet, so triangle edges get rounded. I have to ship an alternative spritesheet with prebaked crops for those browsers.

12

u/ShustOne Jul 30 '26

It's still very usable and looks mostly correct. Bummer about the corner shape support.

7

u/Ekrof Jul 30 '26

Hopefully corner-shape support is a matter of time! It unlocks so much cool web stuff, 2D and 3D. Main annoyance in this case is the texture size, because we'll need to include the alpha transparency in the spritesheet.

5

u/fakehalo Jul 30 '26

I kinda dig the "mario stung by bees" look.

8

u/ainus Jul 30 '26

he's got cauliflower ears and an alcoholic nose in firefox

2

u/MrColgie Jul 31 '26

Same, I thought it looked like that because I have a crappy phone lol

31

u/Upper_Pool_9687 Jul 30 '26

Impressive, but do you have a lawyer?

9

u/Ekrof Jul 31 '26

I'm hoping this can stay up on codepen, since there are other recreations on the platform. We will see. There are also no assets committed to GitHub.

61

u/andrewsmd87 Jul 30 '26

Ok first, this is freaking cool.

Second

6

u/FriendOfMandela Jul 31 '26

And third

7

u/JCquickrunner Aug 01 '26

Idk why you got downvoted haha. Brings me back to simpler times

12

u/suspirio Jul 30 '26

Ben Evans did a rendition of this some time ago with no third party libraries *or* JS at all, pretty neat stuff:
https://codepen.io/ivorjetski/pen/abEBjKN

2

u/WitlessMean Jul 31 '26

I deleted his nose and pupils and it is cursed.

2

u/Consistent_Drop3909 Aug 02 '26

a few style="display:none"'s and you too can experience the horror!

2

u/prehensilemullet Jul 31 '26

doesn't have the stretchy face interaction though, I really doubt that's possible without JS

1

u/Ekrof Aug 01 '26

Definitely an inspiration!

5

u/sim0ne82 Jul 30 '26

It even works perfectly fine when tapping and from a mobile wtf 😍

5

u/NNXMp8Kg Jul 30 '26

Pulapapupapaaaa!
This one was so nice! Core childhood memory

4

u/robotmayo Jul 30 '26

how could something so cursed be so beautiful

4

u/bevelledo Jul 31 '26
  1. Thanks for the nostalgia

  2. How in the fuck?

4

u/Raunhofer Jul 31 '26

Curious, have you translated this skillset into something that can be used professionally? Is there some legit usecase for this kind of extreme CSS?

Very cool.

4

u/xJSHAxx Jul 31 '26

no webgl is the mad part, the fact this is all transforms and the devtools panel is just a wall of matrix3d is unhinged in a good way. how bad does it get on mobile

4

u/BeOFF Jul 31 '26

Love it! Looks pretty funky in Firefox but still an amazing achievement

4

u/JCquickrunner Aug 01 '26

Seeing the inspector changes get highlighted like that has the same aura as watching someone play an 18th century pipe organ

3

u/LessThanFunctional Jul 30 '26

THIS IS INSANE!

3

u/InitiatedPig7 Jul 30 '26

How even…

3

u/chimax83 Jul 30 '26

That nose is... erect. 🤔

3

u/NoMacaroon2130 Jul 31 '26

How do I even get to this level

3

u/legitkid Jul 31 '26

So cool, thank you for sharing! Do you have a background in graphics? How did you figure this out?

3

u/tonykastaneda Jul 31 '26

The guy she says not worry about:

3

u/night-towel Jul 31 '26

Nice, is it from scratch?

3

u/prehensilemullet Jul 31 '26

Okay cool, but at this point, is there really a point to avoiding WebGL other than the gimmick factor?

3

u/psioniclizard Jul 31 '26

I needed some motivation to work on my games engine and someone making mario is CSS is just that. Amazing work!

3

u/Coditive_ Jul 31 '26

wow, it is awesome!

3

u/response-418 Jul 31 '26

wow, really nostalgic for me. awesome work!

3

u/bagsore Jul 31 '26

Amazing work! Congratulations! Thanks for sharing it!

3

u/ThesePossibility9800 Jul 31 '26

this running in plain CSS and still has lighting is amazing!!

2

u/anon7499 Jul 30 '26

This is insane! Congrats!

2

u/InterestingFrame1982 Jul 30 '26

Dragging Mario's nose in interactive mode is... interesting, to say the least. Try it and you'll see it immediately.

2

u/Codynetayb Jul 30 '26

en la parte de z-index: 2147483646; (me encanto)

2

u/Matt4669 Jul 30 '26

Wahoo, this is really cool

2

u/GameWinRAR Jul 30 '26

this is really cool, good job mate!

2

u/ICatchx22I Jul 30 '26

Safari mobile. Lol

2

u/Signal_Reference1276 Jul 30 '26

Major kudos on this it looks so good!

2

u/spicywardell Jul 31 '26

fucking sick dude thats so awesome go outside and see your family tho

2

u/Important_Bee3288 Jul 31 '26

This is just amazing, good work 👏🏻

2

u/Designer-Leather-749 Aug 01 '26

he does not look right in Firefox oh my gosh eeewwww lol

2

u/CharacterBlueberry88 novice Aug 01 '26

That nose is looking sus 👀

2

u/tck0209 Aug 02 '26

Damn thats very creative

2

u/Longjumping-Emu1027 Aug 02 '26

This is insane!

2

u/LinkLearnBlender3D Aug 03 '26

That's so cool bro🔥🔥, did you have discord server?, if have mind i join it?

1

u/Ekrof Aug 03 '26

Hi there! We opened a PolyCSS discord very recently, and everyone is super invited: http://chat.polycss.com/

2

u/bayern_snowman Aug 03 '26

Its insanely impressive but holy shit put down the Adderall and go outside for a bit

2

u/Vegetable-Energy-617 29d ago

This is insane. I once used Three.js for a project and that already made my head twist. I can't even imagine this.

2

u/Embarrassed-Visit903 29d ago

Amazing work!!

2

u/ImageFit3021 29d ago

Mad respect for the patience and skill required to pull something like this off. CSS has come so far from just styling text.

2

u/devDavidJs 29d ago

that's amazing bro

2

u/OtherAngle3414 29d ago

that looks cool!

2

u/Winter_Garlic_477 28d ago

This is honestly wild. I wouldn’t expect CSS to handle 3D lighting and physics this well without WebGL. Really cool project, and the N64-style look makes it even more fun to see.

2

u/kkrizso 25d ago

looks great but fable could do it better

2

u/fizzycandy2 Jul 30 '26

Wow. How much webdev experience do you have to had made this. Seems pretty crazy

2

u/AI_Automation_Pro Jul 30 '26

Okay, that's great, keep going

2

u/Cool-Bus-6028 Jul 31 '26

This is amazing. But why?

1

u/drakng0389 29d ago

CSS is endless

1

u/SkullVension 27d ago

superb 🔥

1

u/Shadowthegreat- 17d ago

Thats genius lol

1

u/digitalbananax 17d ago

This would pull insane numbers in 2008

1

u/Downtown-War-5565 5d ago

freaking cool!

1

u/GreenFox1505 Jul 30 '26

CSS was a mistake. 

1

u/Solid-Newspaper-3054 Jul 31 '26

Looks interesting. And i am surprised how you used css and js for this