nicoco007 / BeatSaberCustomAvatars

Beat Saber mod that allows the use of custom player avatars for in-game body presence.
GNU Lesser General Public License v3.0
261 stars 41 forks source link

Is surface illumination possible? #147

Closed Xentha closed 6 months ago

Xentha commented 1 year ago

I've been trying to find a way to cast light from a source, so that I can make it look like my sabers are lighting up my avatar as I swing my arms around.

So far as I know, this is normally done with shaders, but I've yet to find a shader that successfully does it with this mod. Is there something I'm missing, or is this just not currently possible with this mod?

nicoco007 commented 1 year ago

Shaders are only part of the equation. Basically nothing in Beat Saber actually emits light in a way that shaders can use for illumination; there's some custom directional light stuff going on for environment lighting but that's about it. I've been working on saber & environment lighting for avatars for some time now – it used to be part of this mod but I extracted it into its own thing since it was causing a lot of noise while I was experimenting. I don't think anyone else has created such a lighting mod but I haven't really done much research.

TL;DR it's not currently possible but I'm experimenting with it.

Xentha commented 1 year ago

Oh! You exist again! Went dark for a bit there, glad to see you're still alive. But, aye, I didn't specifically mean the actual sabers or environment doing light effects (as cool as that'd be), just the ability to attach a light source to the avatar, as if part of the model, that can be placed over the hands to mimic the sabers casting light.

nicoco007 commented 1 year ago

Oh okay, I see. I think the easiest way to do that would be to add a point light as a child in each hand and use a custom shader. To make a working shader, you can start with the regular "Create > Shader > Standard Surface Shader", add keepalpha at the end of the #pragma surface surf Standard fullforwardshadows line, and set o.Alpha = 0 (or whatever value you want for the glow/bloom). If you want the unlit look you can set the emission texture of the shader to your regular color texture. This is a full PBR shader though so if performance is an issue you'll have to write your own shader – I'd recommend looking at Catlike Coding's tutorials for lighting in shaders. You'd need a mod if you want to get the lights to change color.

Xentha commented 1 year ago

Alright, thank you. I won't have the space to do so until mid september thanks to an upcoming event, but I'll look into it when I can, and post here if I get it working.