You copied the Doc URL to your clipboard.

3.2.3. Rendering the shader effect

The shader effect created in the previous section can be rendered in the Shader Preview view. This view shows the result of rendering a shader on the selected target.

To render the shader effect:

  1. If it is not already open, open the Shader Preview view. To open this view, select Window → Show View and select the Shader Preview view.

  2. In the Shader Preview view, click the Select Renderer icon and select an appropriate renderer from the menu displayed.

    A tick appears next to the renderer that is currently in use. See Figure 3.9:

    Figure 3.9. Selected renderer in Shader Preview view

    Selected renderer in Shader Preview view

  3. In the Shader Control view, click the Select Shader to Render icon and select SimpleTest → New Effect. See Figure 3.10:

    Figure 3.10. Selected shader in Shader Control view

    Selected shader in Shader Control view

    A Progress bar is displayed in the Shader Preview view to indicate that the selected shader is being rendered by the target. The rendered image is then displayed in the Shader Preview view.

    Note

    Although the image is rendered, no actual image is displayed in the view. This is because the geometry vertices and the camera matrix have not yet been set for the selected shader. To fix this, adjust the values of the uniforms and attributes in the shader. Two warning messages are issued about this in the Problems view, if you have it open. To assign values to attributes and uniforms use the Shader Attributes and Shader Uniforms views.

  4. Click the Shader Attributes view alongside the Shader Control view.

    The Shader Attributes view is displayed. See Figure 3.11:

    Figure 3.11. Shader Attributes view

    Shader Attributes view

  5. In the Value column, click the cell corresponding to the value of the coord attribute.

    A button is displayed in the cell.

  6. Click the button.

    The Matrix and Vector editor is displayed. See Figure 3.12:

    Figure 3.12. Matrix and Vector editor

    Matrix and Vector editor

  7. Select VERTICES from the drop-down menu.

  8. Click OK.

    This action assigns vertex values for the currently selected geometry to the coord attribute.

    Note

    The warning message about this is automatically removed from the Problems view.

  9. Click the Shader Uniforms tab alongside the Shader Attributes tab.

    The Shader Uniforms tab is displayed. See Figure 3.13:

    Figure 3.13. Shader Uniforms view

    Shader Uniforms view

  10. In the Initial Value column, click the cell corresponding to the value of the camera uniform required for inspection and modification.

    A button is displayed in the cell.

  11. Click the button.

    The Matrix and Vector editor is displayed. See Figure 3.14:

    Figure 3.14. Matrix and Vector editor

    Matrix and Vector editor

  12. Select CAMERA_MATRIX from the drop-down menu.

  13. Click OK.

    This action assigns values to the camera uniform.

    Note

    The warning message about this is automatically removed from the Problems view.

  14. Click the Render Single Frame icon in the Shader Preview view.

    A graduated-color square is displayed in the preview. See Figure 3.15:

    Figure 3.15. Render view of SimpleTest shader

    Render view of SimpleTest shader

Was this page helpful? Yes No