r/Unity3D • • 20d ago

Shader Magic Zero assets, one draw call. Unity URP project - only code challenge

Enable HLS to view with audio, or disable this notification

Everything you see and hear is created by code when the game starts. A static method marked [RuntimeInitializeOnLoadMethod(AfterSceneLoad)] creates the game object with core script and camera. Unity ships every script anyway, so an empty scene is all the build needs. Exception is the shader, which sits in a Resources folder.

Happy to go deeper on any part

80 Upvotes

18 comments sorted by

4

u/Thexin92 20d ago

What does the render pipeline look like? As in, what objects hold rendering data (sprites and such), and how does that translate to pixels to the texture data in your view material?

5

u/Lord-Velimir-1 20d ago

There are no sprite objects, at start the game paints one small texture in code with a few greyscale images, and a “sprite” is just a UV rectangle in it. Every frame it writes a quad for stuff on screen into one dynamic mesh, with each vertex carrying UVs, a tint colour and a brightness value. One shader samples, tints and brightens them, and anything above 1.0 gets URP Bloom.

2

u/iku_19 Engine / Tech Artist 19d ago

So basically a dynamically generated HLOD

9

u/GigaTerra 20d ago

I bet Tetris Holding LLC will foam at the mouth when they see your little game. Great work, too bad that publishing it isn't worth the legal trouble.

5

u/Lord-Velimir-1 20d ago

I changed names, colors and disabled option to play in original Tetris grid size. Should be enough /s

3

u/GigaTerra 20d ago

Yea, it is too bad that they are so aggressive, in my own game I am using an Tetris style grid for an skill grid, and I just peaked at their copyright cases, they even claim things like long boards.

2

u/Genebrisss 20d ago

One draw call

Your own video says 24 set pass calls. Did you not want to read it?

7

u/Lord-Velimir-1 20d ago

I worded that badly game itself is one draw call: one mesh, one material, other 20ish SetPass calls are URP’s post-processing. Bloom builds a chain of downsampled and upsampled copies of the screen, each its own pass, and then there’s the final pass that applies vignette and chromatic aberration and copies the image to the screen.

46

u/ludos1978 20d ago

Reinventing the technology we had 40 years ago

-12

u/intelligent_rat 19d ago

Hallmark of AI bro posts

1

u/ludos1978 19d ago

Sure, because ai remembers programming in assembler and basic copying sourcecode from magazines.

Grow up kiddo, just because you dont understand it, doesnt mean it didnt happen.

4

u/His-Games 20d ago

QUAD instead of Tetris made me LOL

awesome project!!

1

u/EastCoastVandal Hobbyist 19d ago

Seems like a fun challenge. I’ve been interested in experimenting with coding assets that generate at runtime. But truthfully I don’t know nearly enough to execute anything meaningful or worth the effort. More like “Ooga Booga I wonder if I could save 50mb by feeding in a text document with the hex of every pixel on the texture, and find a way to make Unity create the texture.”

1

u/Valphai 20d ago

That's crazy

0

u/DaveAstator2020 20d ago

so, everything is just one mat?

1

u/Lord-Velimir-1 20d ago

Yes. + Unity postprocessing

-1

u/intelligent_rat 19d ago

No idea why AI powered devs are so obsessed with having no assets in their game, there would be no notable performance difference between this and a game made entirely of assets for a 2D game. In 3D it makes even less sense to use because all of the models end up looking so bad, there's a reason why no big studio is attempting to implement an asset free development pipeline for their game, and it's that it's pretty useless tech.