Language:
Page Info
Skill Level:
Engine Version:

Creating a New Global Shader in a Plugin - Blueprint Setup

Choose your OS:

With the Plugin now verified to be working, in the following section you will be shown how to call the global shader using Blueprints.

  1. To see how this works, right-click in the Content Browser and create a new Blueprint Class that has Actor as its parent class with the name, DrawUVDisToRenderTarget.

    HT_ShadersInPlugins_11.png

  2. Next, create a new Render Target called RT_00 and a new Material called MAT_RT.

    HT_ShadersInPlugins_12.png

  3. Open up MAT_RT Material and then add the RT_00 Render Target to the Material Graph, connecting its output to the Base Color input on the Main Material Node, pressing the Apply and Save button when done.

    Click for full image.

  4. Next, open up the DrawUVDisToRenderTarget Blueprint and create/add the following variables and nodes to the Event Graph.

    Variables

    Default Value

    K1

    1.0

    K2

    1.0

    inc

    1.0

    Nodes

    Default Value

    W

    N/A

    S

    N/A

    Event Tick

    N/A

    Draw UVDisplacement to Render Target

    Input 1 into FOV, Aspect Ratio, and Overscan Factor

    Make FooCameraModel

    N/A

    Clear Render Target 2D

    N/A

    HT_ShadersInPlugins_14.png

  5. To easily demonstrate how the Draw UVDisplacement to Render Target will warp the supplied render target, you will need to setup your up Blueprint so that the values input into the K1 and K2 inputs on the Draw UVDisplacement to Render Target node can be increase or decrease by the press of a button. To accomplish this, setup the nodes in the Event Graph so that they match the following image:

    Copy Node Graph

    You can copy and paste this Blueprint code directly into your Blueprint.

    Do not forget to input your Render Target into the Output Render Target or you will not see anything happen.

  6. With the required Blueprint logic now setup, make sure to Compile and Save your Blueprint and then drag your Blueprint from the Content Browser into a level. When completed, select the Blueprint and under Input change the Auto Receive Input from Disabled to Player 0.

    Click for full image.

  7. Next, select the floor and duplicate it by pressing CTRL + W and then rotate it -90 degrees in the X axis then drag the Material MAT_RT onto it so you can see the effect the of the Draw UVDisplacement to Render Target.

    Click for full image.

  8. With everything now setup, press the Play button and then press the W and S keys to warp the Render Target that was input into the Draw UVDisplacement to Render Target node like in the following video.

End Result

At this point you can now distort the content inside a render target from Blueprint to create all kinds of interesting shapes. Next, try and create a new Plugin or edit the existing one and see what kind of interesting images and effects you can create.