garrysmod-requests icon indicating copy to clipboard operation
garrysmod-requests copied to clipboard

Reimplementation of JellyFish shader

Open VpSnipes opened this issue 1 year ago • 19 comments

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?

VpSnipes avatar May 17 '24 20:05 VpSnipes

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

robotboy655 avatar May 20 '24 16:05 robotboy655

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

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 firefox_20_17574 image

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

edit: figured I should include the vmt

Vuthakral avatar May 20 '24 18:05 Vuthakral

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

JackTheGopnik avatar May 20 '24 20:05 JackTheGopnik

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.

VpSnipes avatar May 20 '24 21:05 VpSnipes

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.

robotboy655 avatar May 21 '24 13:05 robotboy655

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

JackTheGopnik avatar May 22 '24 04:05 JackTheGopnik

"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.

robotboy655 avatar May 22 '24 08:05 robotboy655

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.

VpSnipes avatar May 23 '24 04:05 VpSnipes

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

robotboy655 avatar May 23 '24 08:05 robotboy655

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

Vuthakral avatar May 23 '24 14:05 Vuthakral

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.

robotboy655 avatar May 23 '24 16:05 robotboy655

@VpSnipes How can i contact you?

Goldermor avatar May 25 '24 06:05 Goldermor

@Goldermor You can contact me via discord at: vp_snipes

VpSnipes avatar May 27 '24 01:05 VpSnipes

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.

epicplayer40 avatar Jun 15 '24 23:06 epicplayer40

Update: I established contact and here is the fixed jellyfish shader @robotboy655 jellyfish_shader.zip Credit to ToothpasteVixen for fixing it.

epicplayer40 avatar Jul 07 '24 14:07 epicplayer40

If/when this is pushed to Garry's Mod, I'll update the post with the changes and offer any feedback to the implementation of the shader. (if it's working as intended, if there's anything missing/improper, etc.)

VpSnipes avatar Jul 08 '24 04:07 VpSnipes

bump, was the shader source provided by @epicplayer40 useful in getting this to work?

VpSnipes avatar Aug 05 '24 09:08 VpSnipes

I can confirm that the fixed shader along with the instructions provided in the zip file do in fact work. Here's me having the shader fixed in sdk 2013:

image

epicplayer40 avatar Sep 16 '24 21:09 epicplayer40

I also can confirm the fix does work.

https://github.com/user-attachments/assets/42b8ece9-92bf-4ccf-b976-4f4c90af0e8c

DrVrej avatar Sep 16 '24 21:09 DrVrej

Bumping this because there's still no response from Rubat.

epicplayer40 avatar Jan 10 '25 04:01 epicplayer40

I can also confirm these to work:

Image

But I also would like to know where the shader sources came from (.fxc files) I am not seeing these in any of our licensee repos, not even in any leaks.

robotboy655 avatar Jan 10 '25 15:01 robotboy655

But I also would like to know where the shader sources came from (.fxc files) I am not seeing these in any of our licensee repos, not even in any leaks.

I'm pretty sure that they were custom made. I'll ask the author and update if I get a response.

epicplayer40 avatar Jan 10 '25 20:01 epicplayer40

I can also confirm these to work:

Image

But I also would like to know where the shader sources came from (.fxc files) I am not seeing these in any of our licensee repos, not even in any leaks.

They are just the old .vsh/.psh shader logic ported over to HLSL along with the general boilerplate code used for studiomodel compatible shaders

RoyaleNoir avatar Jan 12 '25 02:01 RoyaleNoir

Alright, I have restored the shader.

robotboy655 avatar Jan 14 '25 17:01 robotboy655

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?

You should update the VDC documentation, or at least post some information about your experimentation here for posterity.

piqey avatar Jan 14 '25 20:01 piqey

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?

You should update the VDC documentation, or at least post some information about your experimentation here for posterity.

My "experiment" was there because of the lack of shader support for Jellyfish in order to achieve the result I needed. This is a three layer model stack with sub-surface as the top, refraction as the secondary, and the flesh shader as the primary. This is NOT a good solution and is performance taxing depending on how many instances (models) are present on screen. I'm pretty thankful Rubat got the shader up and running again, this cuts back on 3 material instances and brings it to one, @robotboy655 thank you for taking the time to do this btw it's a HUGE help with optimization.

VpSnipes avatar Jan 14 '25 20:01 VpSnipes

@robotboy655

The JellyFish shader currently present in GMod is almost fully functional except for $envmap which still tries using the old logic and ends up breaking completely, luckily however ToothpasteVixen (same person who did the original port) did make an updated version with functional/fixed $envmap/cubemap support: jellyfish_v2.zip (just includes the changed files and not the whole thing)

goodusername123 avatar Mar 06 '25 07:03 goodusername123

Alright, I have merged those changes on x86-64 beta, please let me know if it all works correctly.

robotboy655 avatar Mar 07 '25 18:03 robotboy655