Source Shader Editor - Implementation info
- 1 ShaderEditorSystem.cpp
- 2 SEdit_ModelRender.cpp
This article covers all relevant information about the implementation of the shader editor. While the editor is enabled, the ConVar mat_queue_mode will be forced to -1. However, running with an asynchronous material system while the editor is disabled should be safe, you will still be able to use editor shaders in that case.
This file loads the shader editor library and initializes it. Furthermore it is responsible for updating the editor every frame with relevant view information and defines all available client callbacks.
The library is initialized here. The boolean bCreateEditor defines if the editor itself should be allocated or not. By default this is dependent from the command line parameter -shaderedit. If you want to add logic based on whether the editor is enabled or not, this is the place for it. You may want to only allow sv_cheats 1 servers when the editor has been enabled or even completely disable it for a release. However you must call this function in any case or otherwise you won't be able to use any editor shaders ingame.
Furthermore you can use the variable iEnableSkymask to enable the allocation and update of the sky mask texture which is named _rt_SEdit_Skymask. The operations to create the sky mask involve four copy operations from backbuffer to RTs and four fullscreen quads (with rather simple shaders) all in all. Make sure that you only enable this if you will actually use it.
The skymask will only be updated properly if you edited viewrender.cpp as described in this article.
The function invoked in here will copy the current backbuffer content to the RT _rt_FullFrameFB and render the post processing preview. Make sure that you add a line to call this function in viewrender.cpp as described here. Should the RT copy operation somehow interfere with your code, change the argument used in
shaderEdit->OnPostRender(...) to false. You can freely move the call to
CustomPostRender() around as you see fit.
All client callbacks are registered here. For a more detailed explanation on how to use them refer to client callbacks.
This files purpose is to allow model rendering requests from the shader editor on client library level. Doing it this way makes the editor library more lightweight, as the functionality to render models is only relevant for the model preview. It is safe to exclude this class and to not pass a pointer to its instance through
bool SEditModelRender::LoadModel( const char *localPath )
Handles a model request from the editor library.
Renders the preview model. Various overrides are active when this is called, like IVModelRender::ForcedMaterialOverride and IVModelRender::SuppressEngineLighting. If you want to add model lights or change the ambient lighting for the preview, this is the right place. This function also forces all pose parameters to zero. You can for example set move parameters to an arbitrary value and make the preview model walk (3x3 walk blends would require this).
int SEditModelRender::QuerySequences( char ***list )
Sends all available sequences via names to the editor. By default sequences flagged with 'hidden' will be filtered.
int SEditModelRender::MaterialPicker( char ***szMat )
This function lists all materials at the current cursor position. It is used to apply editor shaders onto world materials on the fly or reset materials.