Facepunch / garrysmod-requests

Feature requests for Garry's Mod
83 stars 24 forks source link

Reimplementation of JellyFish shader #2388

Open VpSnipes opened 1 month ago

VpSnipes commented 1 month ago

The jellyfish shader has been absent from Garry's Mod for quite some time now, I'm not sure as to the specifics of it; though I've had to go to great lengths in order to get similar effects via refract and sub-surface scattering as shown here: image

Problem is that this still doesn't get the desired result despite the constant material editing and param changing. Could we get this shader re-added to Garry's Mod with the adjustments it needs to get working?

robotboy655 commented 1 month ago

According to https://developer.valvesoftware.com/wiki/JellyFish the shader is all sorts of broken, is it even useful at all?

Vuthakral commented 1 month ago

I believe it's only broken in SDK 2013+, and the reason why is unknown (to me). The shader supposedly works in older SDKs, as also stated on the wiki. As for if it's useful, it's a one-of-a-kind shader that does some really cool surface texture effects that make it appear as if there's a fully modeled 3d core beneath the surface. This is gonna be a slightly large post due to images so I'm gonna spoiler most of it for browsing convenience:

What the Jellyfish shader does: Here's the actual mesh of the Hydra imported into Blender, the only known asset to make use of this shader. Note how it has just one 3D surface, and only one material. ![image](https://github.com/Facepunch/garrysmod-requests/assets/4466200/18f379e5-308a-4cf9-a5e2-6f6eeff40da8) Now with it being shown ingame, you can see how this shader creates its namesake, the "Jellyfish" effect of sub-surface detail: ![firefox_20_17573](https://github.com/Facepunch/garrysmod-requests/assets/4466200/2ef69fb6-9792-480a-bffd-06aa8a4cd403) ![firefox_20_17574](https://github.com/Facepunch/garrysmod-requests/assets/4466200/13f9d092-a244-40b4-b207-a22f1915d19f) ![image](https://github.com/Facepunch/garrysmod-requests/assets/4466200/9835314a-87c1-44eb-8a77-6b55f0a92eb2) Here are the videos these screenshots are sourced from, it's much better to convey this effect in motion than from still images. https://www.youtube.com/watch?v=zQciWVIG7zo https://youtu.be/eFEVVvEN9s8?t=48 Weirdly, the shader/hydra has multiple materials despite only one being referenced on the model, and the VMT does not have any references to these either: ``` "JellyFish" { "$basetexture" "models/hydra/bodysplit" "$gradienttexture" "models/hydra/gradient" "$model" 1 } ``` Admittedly, I do not know if there is some shader magic or possibly NPC or engine hardcode hackery involved or not with how it loads these extra materials, given the model itself only references the one material. Perhaps this could be related to breakage in steampipe versions of the engine? ![image](https://github.com/Facepunch/garrysmod-requests/assets/4466200/d75541f1-c74a-493c-98cd-82fe47dea447)

edit: figured I should include the vmt

JackTheGopnik commented 1 month ago

The reason it doesn't work in the 2013 SDK is because the sources for JellyFish are non-existent in the materialsystem sources. Theoretically speaking it should be really easy to re-implement, just grab the sources from an older ver. of the SDK and throw them into 2013. Hopefully it should work without any changes being needed.

Edit 1: Forgor to mention though you still need to reference it in the vproject file that compiles them to the game otherwise it wont work

VpSnipes commented 1 month ago

At that point, the last thing would be documentation. As for the use-case scenario, I believe @Vuthakral went over a pretty extensive means for the use of it; in my case specifically it's to recreate what Crysis does, which the JellyFish shader is pretty close to. This will at least let me get rid of refraction which can be pretty performance intensive when not set up properly or if there's more than 1 overlaying into eachother.

robotboy655 commented 1 month ago

I am unable to make it function. No matter what I tried, including using the original textures from HL2 beta, the shader just renders as completely transparent.

Looking at the HL2 beta source code and what we have, the shader code is pretty much identical, minus some API differences, so I really don't know why it just doesn't do anything.

I have updated the wiki page to include all the material parameters the shader exposes. If you can make it do anything in HL2/EP2 or something (and provide me with the files to test), I might revisit this.

JackTheGopnik commented 1 month ago

What exactly did you try with the sources to get them to be fully transparent? Are they transparent or are they completely non-existent?

robotboy655 commented 1 month ago

"completely transparent" would mean fully invisible, or "non existent". I didn't "try anything with the sources", that's just how the shader renders without any modification, using materials mentioned above.

VpSnipes commented 1 month ago

Are there no other additional parameters, similar to how the fleshshader has to be forced on via debug, or through a proxy then through an entity in LUA? If I were to guess, the Hydra itself could have some kind of "flag" or custom lua that forces that shader to run. If everything is identical, then that could be the only thing that comes to mind, at least for me.

robotboy655 commented 1 month ago

No, I did not see any special rendering code in the npc_hydra sources.

Vuthakral commented 1 month ago

Probably a stupid question, but is it possibly related to HDR that it's seemingly invisible when reimplemented?

robotboy655 commented 1 month ago

I don't see how it relates at all.

Again, if you can get it to display anything (so that I can have a known good material for testing) in some other Source engine game that has it, I could look into it further. If not, then not.

Goldermor commented 1 month ago

@VpSnipes How can i contact you?

VpSnipes commented 1 month ago

@Goldermor You can contact me via discord at: vp_snipes

epicplayer40 commented 1 week ago

I know someone who HAS successfully restored the jellyfish shader into working on Source SDK 2013, however I've been unable to contact them regarding this. I'll post again if I can get any updates.