Source Shader Editor - Preview usage

From Valve Developer Community
Jump to: navigation, search


The shader editor offers different ways to preview shaders that you created with the flow graph. However not all preview modes will be suitable for every shader. To access the preview window, click on Toggle preview on the root panel.


Object/World shaders

Preview window with a basic model shader applied to a combine.

All shaders that are determined to be used on models, brushes or anything else that will be projected into the scene can be rendered onto a dynamic mesh or a model. The latter will only work as expected if your shader supports at least skinning for studio models and you may not use certain input semantics in a shader that is rendered onto a model.

Note.pngNote:Lightmaps will not be valid in the preview window.

When you're using the shader preview on the panel, it will be updated automatically every time you change the shader after a successful compilation. You can however toggle automated compiling off if your system is too slow and continuous re-compiling causes framerate issues for you. To enable/disable automated compilation, open the editor configuration panel by selecting Editor config in the File menu and (un-)check Compile enabled.

Furthermore you can load textures to use as a background image in the preview window. Selecting a cubemap file will render it as such and replace the texture used by all Texture sampler nodes that are using the Envmap parameter with the appropriate file.


Shaders applied to geometry in the scene at runtime.

It's possible to apply new shaders at runtime onto geometry in the scene, to do so make sure that you finished a Full compile first. If you haven't already, select Full compile in the Shader menu. Now load a map and go into halfscreen mode by pressing F2, make sure that the object you want to apply the shader on is visible on the right side. Select Paint world in the Shader menu and click with the LMB left mouse button somewhere on the scene to apply the shader.

Tip.pngTip:Click with the RMB right mouse button to restore the original shader of the object.

Should you apply a shader onto geometry that does not support it, the mesh may disappear, you might see errors in the console or the games stability may suffer.

You can also quickly update all materials in the scene that have the current shader applied by selecting Inject shader into world in the Shader menu. This will affect materials that use the current shader through their vmt and everything you painted by hand as described above.


Post processing shaders

Load a map if you haven't already and select post process in the dropdown menu of the preview window. The shader will now be rendered as a fullscreen quad if you followed these steps properly. As above, this preview shader will update automatically when you alter the shader in the editor, a Full compile is only necessary if you want to use the shader through vmts.