Facepunch / sbox-issues

175 stars 12 forks source link

[Shader Graph] Opacity Support #2930

Closed Jammie3d closed 1 year ago

Jammie3d commented 1 year ago

For?

S&Box, Other

What can't you do?

I'm unable to plug a value into the Opacity socket on the Result node and have the effects be reflected in the Preview window.

How would you like it to work?

I'd like to be able to use a texture (or any other 0-1 value) as an opacity mask in a shader, with options for blending i.e Alpha test or Translucent.

What have you tried?

I have tried inputting values into the Opacity socket, saving the shader and checking it in the Material Editor. Currently if a texture is only plugged into Opacity it wont appear in the Material Editor.

Additional context

A two sided option would also be good to have when using Opacity.

aylaylay commented 1 year ago

Just a heads up, any textures set in the graph are just a preview, you still have to hook up the actual texture in material editor

Jammie3d commented 1 year ago

This might be a bug but this is how it is currently. Texture plugged only into Opacity: image

Texture plugged into Albedo image

aylaylay commented 1 year ago

Thanks, yeah I just don't handle transparency or alpha testing yet, will look into it.

aylaylay commented 1 year ago

You can now choose the blend mode

https://user-images.githubusercontent.com/1667289/220272261-cad8221c-f711-422c-a526-be548edb82fe.mp4

Jammie3d commented 1 year ago

Awesome thanks! Masked is working really well but it seems like Translucent isnt working for me, with a 0.5 float plugged in nothing appears in the preview window.

Jammie3d commented 1 year ago

The Translucent bug mentioned above is solved.

However, the masked blend mode appears to be broken when in-game, it looks fine in Hammer, Modeldoc etc.

I believe this only happens with custom shadergraph shaders and not the complex one.

Hammer: image

In-game: image

// Copy this into your graph to add 2 nodes.

{"nodes":[{"_class":"SimplexNoise","Coords":{},"Identifier":"0","Position":"-368,-48"},{"_class":"Result","Albedo":{},"Emission":{},"Opacity":{"Identifier":"0","Output":"Result"},"Normal":{},"Roughness":{},"Metalness":{},"AmbientOcclusion":{},"DefaultOpacity":1,"DefaultRoughness":1,"DefaultMetalness":0,"DefaultAmbientOcclusion":1,"Identifier":"1","Position":"160,-96"}]}
ShadowBrian commented 1 year ago

Looks like it's not a shader graph issue, only happens if the initial material on hammer geo isn't transparant and then changed to be a transparant material, probably a hammer issue?

Jammie3d commented 1 year ago

https://github.com/sboxgame/issues/issues/2930#issuecomment-1472948365 This seems to be fixed now, I think I just needed to tick Disable Z Prepass.