Jump to content

Shader Master (Node Editor for Custom Shaders)


SpiderPig
 Share

Recommended Posts

Thought I'd show off my node editor for Ultra Engine Shaders.  Currently I'm developing it as I develop my game, so features get added as I need them.  But I'd love to hear your feedback and if you'd like me to add something I'm sure I can oblige. :)

Discord for ShaderMaster

ShaderMaster_v1.3.zip

Before use, you need to set the path to UltraEngine like this so it can find the tools and shaders.  You will also need to copy 'FragmentCustom.glsl' to 'UltraEngine\Templates\Common\Source\Shaders\PBR' in order to use the fragment shader nodes.

Preferences.thumb.png.e08bba9906a0d6df9e7fa866dd1d0d7d.png

Then to create a new project go to File->New Project and enter in a name.  PBR is the only available at the moment and you can choose PostEffect from the right drop down - but this has not been tested in some time!  Feel free to explore it though.

NewProject.png.96af94df3b2ce90a0dbd3df73404a3cf.png

Add a file to the project by clicking the file icon with the '+'.  Below are the files associated with one of my projects.  Macros are also visible when the checkbox is checked.  Macros are functions that can be used between projects.  Create a function, right click the function file and choose 'Convert to Macro'.  The function will be removed the current project and added to the macro folder.

AddButton.png.0f6ea291557ca9466a6ef03625fede52.png

 

Choose a file type, this is either a shader stage or a function or definition.  I've used the fragment shader extensively.  I have used the vertex and geometry shaders though there may be bugs here.  Please let me know.  Tessellation and Compute stages aren't working yet.

NewShader.png.13710f6c4515f5653a9a6ff5fdb8f321.png

 

Select a file from the list on the right to open it and right click in the node area to get a menu of all the available nodes.

I'll make in depth tutorials on this later if any one is interested as there's a lot more to cover.  Right now it's there to play with. :)

An example of the fragment shader for my voxel terrain.

Example.thumb.png.3f3ff2b460b2d18e09be738d9e76b02f.png

  • Like 6
Link to comment
Share on other sites

  • 1 month later...

I'm implementing the new flowgraph editor now. I am going to try to make 'Flowgraph" and "FlowgraphNode" as custom widgets so maybe you can use them if you want.

  • Like 1
  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 4 weeks later...

While there is no viewer in the shader editor (probably will be once Ultra supports C#) you can create a file watcher in your application to watch the changes you make in real-time.  Within a second or two ;)

Add this at the start of your program.

auto watcher = CreateFileSystemWatcher("Materials");

And add this to your loop.

while (PeekEvent()) {
    auto ev = WaitEvent();

    if (ev.id == EVENT_FILECHANGE or ev.id == EVENT_FILECREATE)
    {
        //Look for a loaded asset with this file path
        auto asset = FindCachedAsset(ev.text);
        if (asset)
        {
            //Reload the modified asset
            if (asset->As<Material>() != nullptr) {
                auto material = asset->As<Material>();
                vector<shared_ptr<Texture>> textures;
                for (int id = 0; id < 16; id++) {
                    auto tex = material->GetTexture(id);
                     textures.push_back(tex);
                }
                asset->Reload();

                //If you assign textures progmatically you need to do this to make sure the newly loaded material has them too.
                material = asset->As<Material>();
                for (int id = 0; id < 16; id++) {
                material->SetTexture(textures[id], id);
                }
            }
            else {
                asset->Reload();
            }
        }
    }
}

You can also setup the shader project to automatically compile and export to multiple projects that may use it.

In 'Preferences' under 'Export Options' you can browse to any one of your Ultra projects and add them to the list.  This list will be saved between any shader project.  You then need to check which Ultra project you want the shader to be exported to and then check 'Auto Export' and 'Save'.

Every time the shader project is changed it will attempt to compile.  If the compile is successful and 'Auto Export' is checked it will copy all relevant files over to each of the selected Ultra projects in the 'Materials' folder.

If 'Auto Export" is disabled, you can go to File->Export All.

This is mine.

ExportOptions.thumb.png.3b44c883fbb960894b6489515656dddb.png

If you have the code above running in your application and your app is running as you edit your shader, you should see it update as you make changes. :)

  • Like 2
Link to comment
Share on other sites

  • SpiderPig changed the title to Shader Master (Node Editor for Custom Shaders)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...