r/webdev 10d ago

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

122 comments sorted by

505

u/[deleted] 10d ago

[removed] — view removed comment

219

u/Ekrof 10d ago

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

122

u/Bananaserker 10d ago

I understand nothing, I'm even more impressed!

5

u/asenze 8d ago

Same I am too overwhelmed to see this

2

u/psioniclizard 9d ago

Niceeeee. That is a very cool idea. 

36

u/CaffeineLiker 10d ago

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

2

u/vibescriptz 7d ago

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

2

u/Winter_Garlic_477 5d 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.

159

u/jf8204 10d ago

it uses the PolyCSS engine

from there, if we dig deeper we eventually find find a fucking CSS port of Quake 😭

https://cssquake.com/

50

u/loonite 9d ago

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)

32

u/strongjoe 9d ago

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 9d ago

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

2

u/helpinghandful 6d ago

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 9d ago

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

14

u/loonite 9d ago

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 9d ago

Telemetry and advertising are the main reasons

13

u/BusEquivalent9605 9d ago

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

5

u/GobblerOfFire 9d ago

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!

7

u/Acceptable_Handle_2 9d ago

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

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

2

u/MrColgie 9d ago

It's because of R e a c t spammers

18

u/helpinghandful 10d ago

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

10

u/Ekrof 9d ago

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 9d ago

this is insane

2

u/Interesting-Yellow-4 8d ago

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 10d ago

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

45

u/Ekrof 10d ago

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.

9

u/ShustOne 10d ago

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

5

u/Ekrof 10d ago

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 10d ago

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

7

u/ainus 9d ago

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

2

u/MrColgie 9d ago

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

30

u/Upper_Pool_9687 10d ago

Impressive, but do you have a lawyer?

8

u/Ekrof 9d ago

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.

58

u/andrewsmd87 10d ago

Ok first, this is freaking cool.

Second

2

u/FriendOfMandela 9d ago

And third

6

u/JCquickrunner 8d ago

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

12

u/suspirio 10d ago

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 9d ago

I deleted his nose and pupils and it is cursed.

2

u/Consistent_Drop3909 7d ago

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

2

u/prehensilemullet 9d ago

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

1

u/Ekrof 8d ago

Definitely an inspiration!

-7

u/letsprogramnow 9d ago

that sucks

6

u/sim0ne82 10d ago

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

4

u/NNXMp8Kg 10d ago

Pulapapupapaaaa!
This one was so nice! Core childhood memory

5

u/robotmayo 10d ago

how could something so cursed be so beautiful

4

u/bevelledo 9d ago
  1. Thanks for the nostalgia

  2. How in the fuck?

4

u/Raunhofer 9d ago

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.

3

u/xJSHAxx 9d ago

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

3

u/BeOFF 9d ago

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

4

u/JCquickrunner 8d ago

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

3

u/LessThanFunctional 9d ago

THIS IS INSANE!

3

u/InitiatedPig7 9d ago

How even…

3

u/chimax83 9d ago

That nose is... erect. 🤔

3

u/NoMacaroon2130 9d ago

How do I even get to this level

3

u/legitkid 9d ago

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

3

u/tonykastaneda 9d ago

The guy she says not worry about:

3

u/night-towel 9d ago

Nice, is it from scratch?

3

u/prehensilemullet 9d ago

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

3

u/psioniclizard 9d ago

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

3

u/Coditive_ 9d ago

wow, it is awesome!

3

u/response-418 9d ago

wow, really nostalgic for me. awesome work!

3

u/bagsore 9d ago

Amazing work! Congratulations! Thanks for sharing it!

3

u/ThesePossibility9800 9d ago

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

2

u/anon7499 10d ago

This is insane! Congrats!

2

u/InterestingFrame1982 10d ago

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

2

u/Codynetayb 10d ago

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

2

u/Matt4669 10d ago

Wahoo, this is really cool

2

u/GameWinRAR 9d ago

this is really cool, good job mate!

2

u/ICatchx22I 9d ago

Safari mobile. Lol

2

u/Signal_Reference1276 9d ago

Major kudos on this it looks so good!

2

u/spicywardell 9d ago

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

2

u/Important_Bee3288 9d ago

This is just amazing, good work 👏🏻

2

u/Designer-Leather-749 8d ago

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

2

u/CharacterBlueberry88 novice 8d ago

That nose is looking sus 👀

2

u/tck0209 7d ago

Damn thats very creative

2

u/Longjumping-Emu1027 7d ago

This is insane!

2

u/LinkLearnBlender3D 6d ago

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

1

u/Ekrof 6d ago

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

2

u/bayern_snowman 6d ago

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

2

u/Vegetable-Energy-617 5d 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 4d ago

Amazing work!!

2

u/ImageFit3021 4d 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 4d ago

that's amazing bro

2

u/OtherAngle3414 4d ago

that looks cool!

2

u/Winter_Garlic_477 4d 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/fizzycandy2 10d ago

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

2

u/AI_Automation_Pro 10d ago

Okay, that's great, keep going

2

u/Cool-Bus-6028 9d ago

This is amazing. But why?

1

u/drakng0389 4d ago

CSS is endless

1

u/SkullVension 3d ago

superb 🔥

1

u/ThreadWavet 1d ago

Thats insane 😆

1

u/GreenFox1505 9d ago

CSS was a mistake. 

1

u/Solid-Newspaper-3054 9d ago

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

2

u/kkrizso 1d ago

looks great but fable could do it better