Files
renderdoc/docs/HowTo/HowToEditShader.aml
T
baldurk c38affcded Initial commit of existing code.
* All renderdoc code up to this point was written by me, history is available by request
2014-05-02 08:33:01 +01:00

73 lines
5.0 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<topic id="6d0b6532-6da2-485d-85cd-e83e8c9e0183" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This page details how to edit shaders. This applies both to
<link xlink:href="a00964a1-733f-4288-a79e-c28238bc6018">custom visualisation shaders</link> for the
<link xlink:href="2c540574-0b81-4a40-8119-ba0283fddf41" />, but can also be used to temporarily replace or
edit a shader used in the actual scene.</para>
</introduction>
<section address="EditCustom">
<title>How to edit a custom shader</title>
<content>
<para><link xlink:href="a00964a1-733f-4288-a79e-c28238bc6018">Custom visualisation shaders</link> allow you to define
your own transformation on any texture you're viewing before it is displayed. Mostly this is useful for decoding
packed or custom-format data, or displaying some data in a more visually intuitive fashion.</para>
<para>These shaders live as .hlsl files in <codeInline>%APPDATA%\RenderDoc\</codeInline>, and can be edited in your
editor of choice, any changes saved will be reloaded. Note however that there is currently no way to see the
compile warnings or errors produced. This is probably best for when you have an existing shader to drop-in.</para>
<para>To edit a shader inside RenderDoc simply click the edit button
<mediaLinkInline><image xlink:href="page_white_edit"/></mediaLinkInline> when you have selected your custom shader
for use. This will launch a new window with the custom shader and any changes you make to this shader will be
saved to the .hlsl file and compiled and reflected in the texture viewer as long as you have that custom shader
selected.</para>
</content>
</section>
<section address="EditLive">
<title>How to edit a scene shader</title>
<content>
<para>RenderDoc allows you to edit a shader used in the capture and make changes to it and see the effects in real-time.</para>
<para>To launch the shader editor, go to the pipeline stage you wish to change in the <link xlink:href="A44E2304-6C11-451D-89C4-0A7397F5D1C6" />
windows, and click on the edit button <mediaLinkInline><image xlink:href="page_white_edit"/></mediaLinkInline>
next to the shader.</para>
<para>Note: this feature is intended to be used when shader debug info is available and the hlsl source can be used.
If the hlsl isn't available, RenderDoc will generate a stub function with the input and output signatures available from
the reflection data that you can fill in if you wish.</para>
<para>Any changes to the shader will affect any drawcall using this shader, not just the currently-selected drawcall.
The changes will persist until the edit window is closed.</para>
<alert class="caution">
<para>One unfortunate artifact of how the shader debug info works, not all #included hlsl files will come along with the debug info,
only those files that contain compiled code. RenderDoc automatically replaces any #includes
to missing files with just an empty comment, but unfortunately this can lead to compile errors in unused code.</para>
<para>This can also interact badly with another artifact - macro definitions passed directly to the compiler are not
included in the debug info and so RenderDoc can't include them when recompiling. If you rely on any defines, you
will need to add them manually to the top of your root hlsl file.</para>
</alert>
</content>
</section>
<section address="ShaderEditor">
<title>Using the built-in shader editor</title>
<content>
<para>When you have launched the shader editor, the main window will be filled with the hlsl of your shader.
In here you can make edits and changes with the basic controls and syntax highlighting available with the
Scintilla editor.</para>
<para>To compile the shader and apply your changes, either click the save button in the toolbar or press
Ctrl-S. This will compile the shader and apply it, any warnings and errors will be added to the box below
the main source.</para>
<para>Custom shaders are built with a simple set of flags, any shaders from the scene will be compiled with
the flags that were originally passed to the compiler.</para>
<alert class="caution">
<para>If there are errors compiling a visualisation shader, it will be removed from the texture viewer and normal RGB display
will be used until you fix the error.</para>
</alert>
<para>In addition, when editing visualisation shaders a button will be available to insert several useful snippets
for custom shaders with the pre-defined variables that can be bound. For more detail, see
<link xlink:href="a00964a1-733f-4288-a79e-c28238bc6018" /></para>
</content>
</section>
</developerConceptualDocument>
</topic>