Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major update for visual shader system #26164

Merged
merged 1 commit into from
Apr 7, 2019

Conversation

Chaosus
Copy link
Member

@Chaosus Chaosus commented Feb 22, 2019

I know you guys like visual shaders so I've decided to attempt to improve it.
And with the proposed changes it will be possible to create much more complex effects.

1. Redesigned Add menu

  • Now its a dialog with tree instead menu

image

  • Have categories and subcategories

image

  • Exposed all math functions in easy manner with description !

image

image

  • Support context search

image

  • Have a drag & drop capacity

test

  • All of items in the tree are sorted alphabetically

  • Can be resized for best looking, and save its transform for next time user called it

  • Have options to collapse and expand all items

  • Called by right-click as usual

  • Will create node at last cursor position instead always center

  • The Add nodes... button remains its functionality - dialog has been placed on the top left corner and created node pushed to center as it was

image

2. New functions.

  • Several new API functions from glsl has been pushed to visual shaders.

  • I also exposed all scalar functions to Vector.

  • Almost all GLSL functions now be available for developers !

  • Exposed Input's for easy access - category Input will contains all the inputs for different types of shader modes. Dont worry the parameters which are exist in all three shader modes(Fragment, Light or Vertex) will be under "All" sub-dir..

image

Clicking on each one just created Input node with specified parameter

image

New API :

  • ColorFunc - Contains Grayscale and Sepia effects

image

  • BooleanUniform and BooleanConstant
    These nodes can be translated to scalar or vector and can be useful to achive some effects based on boolean logic.

image

  • TransformFunc - Contains Inverse and Transpose

  • ScalarDerivative and VectorDerivative - Contains Ddx(dFdx), Ddy(dFdy), Sum(fwidth)

image

New Builtins :

  • ACosH
  • ASinH
  • ATanH
  • Clamp
  • Distance
  • Exp2
  • Log2
  • SmoothStep
  • Step
  • FaceForward
  • Radians
  • Reflect
  • Refract
  • RoundEven
  • Degrees
  • Determinant
  • Trunc
  • InverseSqrt
  • Reciprocal for scalars
  • OuterProduct
  • matrixCompMult has been added to TransformMult

Exposed to VectorFunc :

  • Abs
  • ACos
  • ACosH
  • ASin
  • ASinH
  • ATan
  • ATanH
  • Ceil
  • Cos
  • CosH
  • Degrees
  • Exp
  • Exp2
  • Floor
  • Frac
  • InverseSqrt
  • Log
  • Log2
  • Radians
  • Round
  • RoundEven
  • Sign
  • Sin
  • SinH
  • Sqrt
  • Tan
  • TanH
  • Trunc

Separate classes which has been added into core :

  • VisualShaderNodeBooleanConstant
  • VisualShaderNodeBooleanUniform
  • VisualShaderNodeColorFunc
  • VisualShaderNodeTransformFunc
  • VisualShaderNodeDeterminant
  • VisualShaderNodeScalarDerivativeFunc
  • VisualShaderNodeVectorDerivativeFunc
  • VisualShaderNodeScalarClamp
  • VisualShaderNodeVectorClamp
  • VisualShaderNodeFaceForward
  • VisualShaderNodeOuterProduct
  • VisualShaderNodeVectorScalarStep
  • VisualShaderNodeScalarSmoothStep
  • VisualShaderNodeVectorSmoothStep
  • VisualShaderNodeVectorScalarSmoothStep
  • VisualShaderNodeVectorDistance
  • VisualShaderNodeVectorRefract

Notes :

  • Majority of new functions reused standart classes such as ScalarFunc or VectorFunc.

  • So for example if you click on Cos under scalar section - it will create a ScalarFunc with Cos parameter

  • I tried to achive backward compatibility - all new functions added above existed

  • I opened for any acceptable critic and will improve this PR to end (merge) :) Please suggest your fixes or ideas.

  • Where is a demo ? - https://youtu.be/wZRL2UpIDGo

Fixes :

@Chaosus Chaosus requested a review from a team as a code owner February 22, 2019 18:07
@Chaosus Chaosus added this to the 3.2 milestone Feb 22, 2019
@Chaosus Chaosus force-pushed the vshader_improvements branch from e61c024 to bf75d51 Compare February 22, 2019 18:26
@Chaosus Chaosus requested review from reduz, akien-mga, Calinou, JFonS and Paulb23 and removed request for a team February 22, 2019 18:27
@Chaosus Chaosus force-pushed the vshader_improvements branch 8 times, most recently from c703aff to f63cb34 Compare February 23, 2019 07:52
@Chaosus Chaosus requested a review from groud February 23, 2019 07:54
@Chaosus Chaosus force-pushed the vshader_improvements branch 8 times, most recently from 2a615c2 to 5709c95 Compare February 24, 2019 07:28
@Chaosus
Copy link
Member Author

Chaosus commented Mar 25, 2019

So if you clicked on Node(by mouse) you just want to immediate focus on Search ? Currently focus on search does not allows you to press Enter to add node - it just filter the entire list for the comparsion - and after that you should choose the required one - after that there are 3 ways for add a node 1) Create button, 2) Hit Enter 3) Double mouse Click

@reduz
Copy link
Member

reduz commented Apr 4, 2019

This looks seriously amazing. I would also make the type icons remain there as default, no need for a toggle.

@Chaosus
Copy link
Member Author

Chaosus commented Apr 4, 2019

Great!

I would also make the type icons remain there as default, no need for a toggle.

Will fix it tomorrow..

@Chaosus Chaosus requested a review from a team April 5, 2019 05:37
@cbscribe
Copy link
Contributor

cbscribe commented Apr 5, 2019

There's currently a shader docs PR at godotengine/godot-docs/pull/2323 but it doesn't include any visual shader content (yet). Merging this would be a great time to add one. It's going to need a lot of screenshots, though, so I'd recommend waiting until it's merged in case of any last-minute changes.

@Chaosus
Copy link
Member Author

Chaosus commented Apr 5, 2019

@cbscribe Yes, of course, will wait if its needed

Can you check the shader nodes descriptions on editor/plugins/visual_shader_editor_plugin.cpp - majority of them has been taken from official OpenGL site however I changed them a bit..

Also, should I need to add xml docs for new classes (there are plenty of them) or they are generated automatically or something ?

@Chaosus Chaosus force-pushed the vshader_improvements branch 3 times, most recently from 3cba339 to f66b871 Compare April 5, 2019 09:31
@Chaosus
Copy link
Member Author

Chaosus commented Apr 5, 2019

I've added drag&drop - I found it is very useful method to add nodes to the graph

test

The only downside is (currently) you cannot interact with added nodes without closing dialog due to PopupDialog limitation(please correct me if im wrong), however you can delete them without closing dialog by using CTRL+Z(undo)

@Chaosus Chaosus force-pushed the vshader_improvements branch from f66b871 to a283a96 Compare April 5, 2019 10:00
@groud
Copy link
Member

groud commented Apr 5, 2019

@Chaosus couldn't you simply hide or disable the "Fragment" category when in vertex mode (and the other way around), instead of displaying an error message when you drag a wrong node ?

@Chaosus
Copy link
Member Author

Chaosus commented Apr 5, 2019

@groud yeah, good point, will fix it soon..

@Chaosus Chaosus force-pushed the vshader_improvements branch from a283a96 to a1c01b6 Compare April 5, 2019 13:34
@Chaosus
Copy link
Member Author

Chaosus commented Apr 5, 2019

Ok, now Vertex/Fragment/Light in Input will show only in associated mode, also "Special" will not show in Vertex mode cuz its currently have only Derivative functions which are not supported by vertex anyways

@lentsius-bark
Copy link
Contributor

Im back after a few weeks and mate, you're even more of a legend! My jaw dropped so hard my neighbours form three floors down had to bring it to me.

@Chaosus Chaosus force-pushed the vshader_improvements branch 2 times, most recently from b7983d8 to 62b2e79 Compare April 6, 2019 20:12
@Chaosus Chaosus force-pushed the vshader_improvements branch from 62b2e79 to 5fd671b Compare April 7, 2019 05:17
@akien-mga akien-mga merged commit 3dabe86 into godotengine:master Apr 7, 2019
@akien-mga
Copy link
Member

Thanks a ton!

@Chaosus Chaosus deleted the vshader_improvements branch April 7, 2019 12:42
@lentsius-bark
Copy link
Contributor

It got merged in! Wow!

@ZX-WT
Copy link
Contributor

ZX-WT commented Apr 15, 2019

This looks amazing :) I want to cry. I just have a brief look so I don't know whether some improvements are already included. Would you like to have a look at some github issues related to the visual shader system. Here's one of them for example :#21662

@Chaosus
Copy link
Member Author

Chaosus commented Apr 15, 2019

Well, I can look at them and solve, from time to time ^^

@spyres
Copy link

spyres commented May 11, 2019

This is great stuff, but I wonder if anyone will look into the usability updates suggested here:

https://www.youtube.com/watch?v=vCIqblA2-dA

@clayjohn
Copy link
Member

@spyres Thanks for your interest, but this PR is closed.

If you would like to suggest enhancements please open an issue laying out what you would like to see changed in text. Posting a video is not helpful for other contributors.

Please also note that the video you provided was made before this PR was merged and does not reflect the current state of the visual shader system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet