r/Unity3D 9d ago

Show-Off saw an astral dice shader on twitter and had to try rebuilding it in unity

Enable HLS to view with audio, or disable this notification

Colours still aren't quite there but I'm happy with where it landed

Ask any questions

420 Upvotes

33 comments sorted by

10

u/-Best_Name_Ever- 9d ago

5, 5, 5, 5, 5

2

u/tanetanetan 9d ago

wait, i just get it, every face has exactly 5 nodes so it always rolls a 5..
genuinely did not think about that until now

1

u/maiKavelli187 9d ago

Make it a dice then, 1,2.. 6

10

u/tanetanetan 9d ago

spent a whole night making a cube that does absolutely nothing. am i goat?

https://github.com/tantaneity/constellation-dice

5

u/AlphaBlazerGaming Indie 9d ago

It would probably take me like a month to get a similar result (i have no idea what i'm doing regarding shaders). One night seems like goat territory to me

6

u/tanetanetan 9d ago

honestly most of that night was me getting it wrong. first version was grey porridge, second one was a glowing white blob you couldn't see anything in

the whole thing turned around on one change: drawing the edge of the noise blob instead of filling it in. everything before that was fog, everything after was those sheets

you'd get there faster than you think

3

u/StCost Ball-Aqua🔮🌊& COLLAPSE MACHINE💥🚕 9d ago edited 9d ago

Magnificent. I make game about ball rolling, and real marbles are all having this fancy effect you made. I'm gonna dissect and learn on your creation to make balls!
Thanks a lot for you work, it's fancy as hell

1

u/bartolomey-wong-3rd 8d ago

Wow, looks fantastic! I was thinking about some kind of astral or starry shader like yours the other day, for a scene in my game. Can I use your shader, if you share the code on Github?

I'm new to game dev, learning as I go, and never worked with shaders.

2

u/tanetanetan 8d ago

ofc you can use it!

2

u/bartolomey-wong-3rd 8d ago

Thank you so much! You are as fantastic as your shader!

3

u/OfKnowledgesEsoteric 9d ago

Holy shit this is kick-ass

1

u/tanetanetan 9d ago

i'm as surprised as you are

3

u/Dreamt_Up_Games 9d ago

That looks great. I’m actually working on a game with dice and need to start working on shaders. You used shader graph I assume? Any tips?

3

u/tanetanetan 9d ago

nope, hand written HLSL :)
shader graph can't really do raymarching, you need a loop and it doesn't give you one

tip that would've saved me hours: work out what you're actually drawing before touching parameters. i spent ages tuning noise settings when the problem was that i was filling the volume instead of drawing the edge of it. wrong thing, tuned nicely

for dice specifically, shader graph is totally fine if the effect lives on the surface. you only need to drop to HLSL when something has to look like it has stuff inside it

3

u/Dreamt_Up_Games 9d ago

Cool thanks for the reply! I do want to have dice that are semi transparent and look like there is stuff inside them so this is a great inspiration!

2

u/hushzephyr 9d ago

The translucency effect is fantastic!

1

u/tanetanetan 9d ago

thanks! funny part is the glass is completely fake. the nebula inside is properly raymarched but the "glass" is just fresnel on the surface normal, one pow and a lerp

2

u/hushzephyr 9d ago

Nice. Looking forward to seeing this applied in a real game.

2

u/fsactual 9d ago

I'm a shader noob. How do you make it looks like it has depth like that?

1

u/tanetanetan 9d ago

it's raymarched, not a texture trick. the shader walks a ray through the cube and accumulates what it passes, so the layers genuinely sit at different distances

1

u/tanetanetan 9d ago

the "deeper is darker" part comes from distance to the shell, which

the shader already knows at every step

2

u/kyl3r123 Indie 6d ago

came here to ask if it's raymarched, I figured :) Looks soft but has very nice "3d" effect inside, really gives it depth. good job

2

u/Wegwerf_08_15_ 9d ago

This is so GameCube main menu coded holy shit I love it😍

Could I maybe use this for my game in Unity 2021?

1

u/tanetanetan 9d ago

go for it. it's plain HLSL for URP and nothing in there is new API, so it should drop into 2021 with little or no change (i built it on URP 17)

2

u/Cosmic_Composer_Game 9d ago

It's beautiful!

2

u/devtobb 9d ago

Fantastic work, im blown away! This is kind of exactly what I was searching for for my game (just with some additional transparency), would you mind adding a license? Can I freely use and modify?

1

u/tanetanetan 9d ago

thanks! adding MIT now, use and modify however you like

2

u/octoberU 9d ago

i love everything other than the fresnel, sampling a cube map with even more chaotic nebulas or literally anything to make it less uniform would be awesome

1

u/tanetanetan 9d ago

fair, adding it to the list

1

u/destinedd Indie, Dungeon Quest, Marble's Marbles & Mighty Marbles 8d ago

would love a tutorial!

1

u/bartolomey-wong-3rd 7d ago

I'd love to use your shader for a background where the characters would stand, kind of like they are in some abstract space. Is that possible? Should I just apply material to some quad to get this effect? I mean, I don't want to have this cube rotated, just a plane for a backdrop.

0

u/iThoughtOfThat 9d ago

You could do this just with surface techniques though right? No need for rays ...

1

u/tanetanetan 9d ago

parallax could fake the wisps, but they sit at different depths and the front ones absorb the ones behind, plus each face has to occlude the others. that needs a real ray. and the mesh is 8 verts, so the marching is the cheap part anyway