Source Shader Editor - Загрузка & Установка

From Valve Developer Community
Jump to: navigation, search
English (en)русский (ru)
... Icon-Important.png
Info content.png
This page has not been fully translated.

You can help by finishing the translation.

Also, please make sure the article tries to comply with the alternate languages guide.

Эта статья описывает, как установить библиотеки редактора в ваш мод. You will be required to compile the client library at the end, so make sure that you can compile the source code from the SDK successfully.

Note.pngNote:На данный момент поддерживаются Source SDK Base 2007, Source SDK 2013 и Alien Swarm моды.
Confirm:Некоторое оборудование AMD / ATI, кажется, показывает ошибочное поведение при чтении отрицательных значений из текстур. Это влияет только на предварительный просмотр 2D на графике.


Swarm информация

Поддержка Alien Swarm основана на портированном SDK 2007 года, поскольку нет официального источника реализации шейдеров / материалов для Swarm. Поэтому вы можете столкнуться с несоответствиями в первую очередь с шейдерами сцены, здесь перечислены некоторые известные различия:

  • Применение альфа-смешанных шейдеров к геометрии в сцене, которая раньше была непрозрачной, может потребовать перезагрузки карты, объекты могут просто исчезнуть первыми.
  • Swarm может поддерживать пользовательские текстуры вершин.

Cписок Nзменений

Версия 0.5 Изменения:

  • Добавлена поддержка Source SDK 2013 (Windows)
  • Added the possibility to override all relevant editor paths in code
  • Fixed flashlight not working on custom shaders in Alien Swarm
  • Удалено автоматическое копирование в "platform/", в Alien Swarm



Версия 0.4 Изменения:

  • Added startparam '-graphrtsize' to allow changing the resolution of the RT used for the node graph preview
  • Fixed param error getting triggered by locked textures (i.e. framebuffer)
  • Fixed some nodes drawing text implicitly after being culled
  • Fixed error in GetPPEMaterial
  • Fixed crash on shutdown in swarm
  • Fixed crash when loading a canvas that references a userfunc which is missing locally
  • Fixed recompile all dialog not being removed properly



Версия 0.3 Изменения:

  • Добавлена поддержка для SWARM SDK
  • Added more primitive types to the 3d preview
  • Added tabs for flow graphs
  • Added some help texts to the general tab in the node properties and a tooltip to the flowgraph
  • Added unique texcoord dim setting for each stage of the vs input semantics
  • Added support for alpha to coverage
  • Added custom grass rendering code with morphing (optional)
  • Added vertex compression support to the fallback shader
  • Added vertex texture sampler implementation (SWARM ONLY)
  • Added dialog to recompile all shaders that were selected for precaching. You will have to recompile old shaders once yourself first though.
  • Added Miscellaneous nodes: group
  • Added HLSL nodes: custom code, vertex decompress
  • Added post processing nodes: RT, Material, Copy RT, Draw Material, clear buffers, update FB copy, Render view, push VP, pop VP, set RT


  • Changed layout and color scheme (old scheme can still be found as ShaderEditorScheme_Old.res)
  • Changed Skinning node to flip the binormal automatically (to compensate the inverted green channel in normalmaps)
  • Changed flowgraph screenshots to use jpeg compression


  • Fixed some memory leaks
  • Fixed packed editor materials to unpack 'insert' keys improperly
  • Fixed custom texcoord dimensions not being applied correctly
  • Fixed mutable vparam node not updating hierachy on datatype change
  • Fixed max amount of pixelshader constants being displayed as 14 instead of 13
  • Fixed vparam static ignoring first occurance of '-' in the vmt string
  • Fixed tangentspace being broken on sphere mesh under certain conditions (will only work while you use the default texcoord input dimensions in the VS Input node!)
  • Fixed flashlight code not binding cookie texture from dynamic flashlight state
  • Fixed post processing shader preview + 2D preview not performing FB copy properly



Версия 0.2.1 Изменения:

  • Fixed parallax amount being dependent from relative uv/world scale
  • Fixed shaders on prop_static requiring $bumpmap to be defined for lighting
  • Fixed gaussian weights being calculated wrongly in some cases
  • Fixed a crash with morph node


  • Добавлены ноды: clip



Версия 0.2 Изменения:

  • Добавлены ноды: array, condition, sampler object, flashlight origin, parallax uv, parallax shadow
  • Добавлено отменить/возвратить в меню "файл", ctrl+z/ ctrl+shift+z
  • Added custom matrices: projection, view projection, view inverse, projection inverse, view projection inverse
  • Added sampler datatype
  • Added ( 4x3 * 4x4 ) for multiply node
  • Added examples: lightmap_parallax, postproc_depthglow, postproc_gaussblur_2d_singlepass (note: really just a POC for previewing!)


  • Fixed datatype of custom matrix - view
  • Fixed hierachy not updating when float3x3 was toggled on the multiply node
  • Fixed lightscale settings of Final output node not being applied correctly
  • Fixed lightmap lookups not automatically enforcing SRGB read in LDR mode


  • VS texture samplers are now identifiable. This may break old shaders using the Morph node, re-compile them.
  • Exposed datatype of texcoords/color for VS input semantics
  • Bridges of input jacks can now be overridden more easily
  • Changed refraction example to use newer float3x3 cast on multiply + user matrix in PS
  • Improved solver algorithm for stacked containers
  • Changed default texture names of fallback textures
  • The precache dialog will now sort all entries by name



Версия 0.1.2 Изменения:

  • Fixed binary path being cut off
  • Fixed solver crash
  • Added 3dskybox support for the skymask (viewrender.cpp needs to be updated)



Версия 0.1.1 Изменения:

  • Fixed framebuffer copy texture 0 staying undefined
  • Fixed potential stability issue for fast material reload
  • Fixed material picker errors in singleplayer mods


Внедрение файлов*

Загрузка

Установка

  • Скопируйте содержимое source_shader_editor/mod в директорию вашего мода (Steam/steamapps/SourceMods/MY_MOD). Among these files are the libraries that contain the editor and shader implementation, content resources and script files. The folder ../mod/shadereditorui will contain all content generated by the editor; for example your canvases can be located in ../mod/shadereditorui/canvas and temporary plus final HLSL source files will be stored in ../shadereditorui/shader_src.
  • Скопируйте директорию source_shader_editor/code/ShaderEditor в кодовую базу вашего мода, в ../src/game/client/. If you want to change the directory, make sure that you adjust the #includes in all files accordingly! The folder source_shader_editor/code/ShaderEditor/Grass does not have to be copied along, only if you plan on using it. If you're wondering what it looks like, check out the map sdk_vehicles in the demo below. For its specific installation instructions, refer to the readme in the same folder.

Компиляция

Warning.pngWarning:The Alien Swarm code may look slightly different, but you should be able to find the correct places easily.
  • Откройте Visual Studio и загрузите решение вашего мода.
    • (optional) Add a new filter in the Source Files folder of your client project.
  • Add all implementation files (and headers) from ../src/game/client/ShaderEditor to your new filter or elsewhere into your client project. For the SDK 2013, you should add the files to your client VPC project with the following snippet (place it right after $Folder "Source Files" { ):
		$Folder "Shader Editor" [$WIN32]
		{
			$Folder	"Header Files"
			{
				$File	"$SRCDIR\game\client\ShaderEditor\ISEdit_ModelRender.h"
				$File	"$SRCDIR\game\client\ShaderEditor\IVShaderEditor.h"
				$File	"$SRCDIR\game\client\ShaderEditor\ShaderEditorSystem.h"
				$File	"$SRCDIR\game\client\ShaderEditor\SEdit_ModelRender.h"
				//$File	"$SRCDIR\game\client\ShaderEditor\Grass\CGrassCluster.h"
			}
		
			$Folder	"Implementation Files"
			{
				$File	"$SRCDIR\game\client\ShaderEditor\ShaderEditorSystem.cpp"
				$File	"$SRCDIR\game\client\ShaderEditor\SEdit_ModelRender.cpp"
				//$File	"$SRCDIR\game\client\ShaderEditor\Grass\CGrassCluster.cpp"
			}
		}
  • Если вы используете SDK 2013, добавьте следующее определение в $PreprocessorDefinitions переменную вашего client VPC проекта: SOURCE_2013. Стандартные проекты уже имеют эту переменную в их $Compiler блоках. Добавьте новое определение в конце, после точки с запятой.
  • Откройте viewrender.cpp и добавьте #include "ShaderEditor/ShaderEditorSystem.h" сверху, прямо над #include "tier0/memdbgon.h".
  • В viewrender.cpp перейдите к функции void CViewRender::RenderView(...) и добавьте три выделеные линии в соответствущушие им места:
		// if the 3d skybox world is drawn, then don't draw the normal skybox
		CSkyboxView *pSkyView = new CSkyboxView( this );
		if ( ( bDrew3dSkybox = pSkyView->Setup( view, &nClearFlags, &nSkyboxVisible ) ) != false )
		{
			AddViewToScene( pSkyView );
			g_ShaderEditorSystem->UpdateSkymask(false, view.x, view.y, view.width, view.height);
		}
		SafeRelease( pSkyView );

[...]

		// Now actually draw the viewmodel
		DrawViewModels( view, whatToDraw & RENDERVIEW_DRAWVIEWMODEL );

		g_ShaderEditorSystem->UpdateSkymask( bDrew3dSkybox, view.x, view.y, view.width, view.height);

		DrawUnderwaterOverlay();

		PixelVisibility_EndScene();

		// Draw fade over entire screen if needed
		byte color[4];
		bool blend;
		vieweffects->GetFadeParams( &color[0], &color[1], &color[2], &color[3], &blend );

		// Draw an overlay to make it even harder to see inside smoke particle systems.
		DrawSmokeFogOverlay();

		// Overlay screen fade on entire screen
		IMaterial* pMaterial = blend ? m_ModulateSingleColor : m_TranslucentSingleColor;
		render->ViewDrawFade( color, pMaterial );
		PerformScreenOverlay( view.x, view.y, view.width, view.height );

		// Prevent sound stutter if going slow
		engine->Sound_ExtraUpdate();	
	
		if ( !building_cubemaps.GetBool() && view.m_bDoBloomAndToneMapping )
		{
			pRenderContext.GetFrom( materials );
			{
				PIXEVENT( pRenderContext, "DoEnginePostProcessing" );

				bool bFlashlightIsOn = false;
				C_BasePlayer *pLocal = C_BasePlayer::GetLocalPlayer();
				if ( pLocal )
				{
					bFlashlightIsOn = pLocal->IsEffectActive( EF_DIMLIGHT );
				}
				DoEnginePostProcessing( view.x, view.y, view.width, view.height, bFlashlightIsOn );
			}
			pRenderContext.SafeRelease();
		}

		g_ShaderEditorSystem->CustomPostRender();

		// And here are the screen-space effects

		if ( IsPC() )
		{
			// Grab the pre-color corrected frame for editing purposes
			engine->GrabPreColorCorrectedFrame( view.x, view.y, view.width, view.height );
		}


However, at this stage, you'll notice that UpdateSkymask is throwing an error in visual studio as there's too many arguments in the function call. There's multiple steps to fix this.


Наперво, перейдите в ShaderEditorSystem.h и замените следующие строки кода с этих:


              void UpdateSkymask( bool bCombineMode = false );

На это:

	      void UpdateSkymask(bool bCombineMode, int x, int y, int w, int h);


Далее, перейдите в IVShaderEditor.h и найдите эту строчку:


	virtual void OnUpdateSkymask( bool bCombineMode ) = 0;

Замените на это:

	virtual void OnUpdateSkymask(bool bCombineMode, int x, int y, int w, int h) = 0;


Наконец, перейдите в ShaderEditorSystem.cpp и отредактурийте этот блок кода:


void ShaderEditorHandler::UpdateSkymask( bool bCombineMode )
{
	if ( IsReady() )
		shaderEdit->OnUpdateSkymask( bCombineMode );
}

Замените на это:

void ShaderEditorHandler::UpdateSkymask(bool bCombineMode, int x, int y, int w, int h)
{
	if ( IsReady() )
		shaderEdit->OnUpdateSkymask(bCombineMode, x, y, w, h);
}

Это должно решить проблему.


Вернитесь обратно в viewrender.cpp и перейдите к функции void CViewRender::ViewDrawScene(...) и добавьте выделеные строчки в соответствущушие им места:

	ParticleMgr()->IncrementFrameCode();

	DrawWorldAndEntities( drawSkybox, view, nClearFlags, pCustomVisibility );

	VisibleFogVolumeInfo_t fogVolumeInfo;
	render->GetVisibleFogVolume( view.origin, &fogVolumeInfo );
	WaterRenderInfo_t info;
	DetermineWaterRenderInfo( fogVolumeInfo, info );
	g_ShaderEditorSystem->CustomViewRender( &g_CurrentViewID, fogVolumeInfo, info );

	// Disable fog for the rest of the stuff
	DisableFog();
  • Скомпилируйте решение.
  • Для того чтобы включить Shader Editor добавтье -shaderedit в свойства зпуска мода.

Stand-alone демо

Скачать предварительно скомпилированный мод основанный на Source 2007 SDK.

Загрузка

Установка

Скопируйте папку мода в Steam/steamapps/SourceMods/ как обычно. Эдитор появится при запуске без нужды добавлять что либо. Демо не позволит вам сразу же использовать шейдеры везде, однако вы можете взять исходные файлы HLSL и реализовать их вручную в своей библиотеке шейдеров.