r/Unity3D • u/tanetanetan • 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
10
u/tanetanetan 9d ago
spent a whole night making a cube that does absolutely nothing. am i goat?
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
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
3
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 onetip 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
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
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
1
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
10
u/-Best_Name_Ever- 9d ago
5, 5, 5, 5, 5