<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.wiki.obsidianconflict.net/?action=history&amp;feed=atom&amp;title=Procedural_Materials</id>
		<title>Procedural Materials - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://www.wiki.obsidianconflict.net/?action=history&amp;feed=atom&amp;title=Procedural_Materials"/>
		<link rel="alternate" type="text/html" href="https://www.wiki.obsidianconflict.net/?title=Procedural_Materials&amp;action=history"/>
		<updated>2026-06-10T01:01:30Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://www.wiki.obsidianconflict.net/?title=Procedural_Materials&amp;diff=1236&amp;oldid=prev</id>
		<title>HeadCrabD at 09:55, 20 September 2011</title>
		<link rel="alternate" type="text/html" href="https://www.wiki.obsidianconflict.net/?title=Procedural_Materials&amp;diff=1236&amp;oldid=prev"/>
				<updated>2011-09-20T09:55:59Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 09:55, 20 September 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Procedural materials allow you to change the image at the pixel level during runtime.&amp;#160; To create a procedural material you will need 4 things.&amp;#160; You will need a &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/del&gt;VMT&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;]] &lt;/del&gt;file to define the texture for Hammer, a &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/del&gt;VTF&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;]] &lt;/del&gt;file to act as the base texture, a Material Regenerator to do the down and dirty pixel changing, and a [[Material_Proxies|Material Proxy]] to link the regenerator to our texture.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Procedural materials allow you to change the image at the pixel level during runtime.&amp;#160; To create a procedural material you will need 4 things.&amp;#160; You will need a VMT file to define the texture for Hammer, a VTF file to act as the base texture, a Material Regenerator to do the down and dirty pixel changing, and a [[Material_Proxies|Material Proxy]] to link the regenerator to our texture.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== The VMT file ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== The VMT file ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Let's start by defining our VMT file.&amp;#160; In here we will need to start by defining the type of shader this texture &amp;quot;inherits&amp;quot; from, is the best way I can describe it.&amp;#160; So, if I pick something like, &amp;quot;LightmappedGeneric&amp;quot;, I wont be able to make a procedural material because that shader is not setup for being changed at runtime, even if you flag your &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/del&gt;VTF&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;]] &lt;/del&gt;as being procedural.&amp;#160; You will just end up with a black image :).&amp;#160; So, for our purposes I would choose something like, &amp;quot;UnlitGeneric&amp;quot;.&amp;#160; Another option is &amp;quot;MonitorScreen&amp;quot;.&amp;#160; Because these shaders do not limit me to having a static material.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Let's start by defining our VMT file.&amp;#160; In here we will need to start by defining the type of shader this texture &amp;quot;inherits&amp;quot; from, is the best way I can describe it.&amp;#160; So, if I pick something like, &amp;quot;LightmappedGeneric&amp;quot;, I wont be able to make a procedural material because that shader is not setup for being changed at runtime, even if you flag your VTF as being procedural.&amp;#160; You will just end up with a black image :).&amp;#160; So, for our purposes I would choose something like, &amp;quot;UnlitGeneric&amp;quot;.&amp;#160; Another option is &amp;quot;MonitorScreen&amp;quot;.&amp;#160; Because these shaders do not limit me to having a static material.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The next step is to choose a basetexture.&amp;#160; More than anything this texture is there for purposes of having a canvas to paint on.&amp;#160; You can always change it at runtime to increase its size...but I'm going to try and keep this as simple as possible.&amp;#160; So for now, just come up with a name for your texture, we will actually create it in the next step.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The next step is to choose a basetexture.&amp;#160; More than anything this texture is there for purposes of having a canvas to paint on.&amp;#160; You can always change it at runtime to increase its size...but I'm going to try and keep this as simple as possible.&amp;#160; So for now, just come up with a name for your texture, we will actually create it in the next step.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;After choosing a base texture, we need to come up with our proxy name.&amp;#160; We will define it later, but for now just come up with something creative.&amp;#160; PixelRenderer, excellent choice.&amp;#160; Now your &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/del&gt;VMT&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;]] &lt;/del&gt;file should look something like this.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;After choosing a base texture, we need to come up with our proxy name.&amp;#160; We will define it later, but for now just come up with something creative.&amp;#160; PixelRenderer, excellent choice.&amp;#160; Now your VMT file should look something like this.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l24&quot; &gt;Line 24:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 24:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== The VTF file ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== The VTF file ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;I'm going to recommend you use &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/del&gt;VTFEdit&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;]] &lt;/del&gt;for this, because it's a great program.&amp;#160; Start off by opening up your Paint program of choice.&amp;#160; I'm not rich so I'll stick with MS Paint.&amp;#160; Go ahead and make it 512x512, it doesn't need to be anything special...a red background with the words &amp;quot;Procedural Screen&amp;quot; work wonderfully.&amp;#160; Now, in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/del&gt;VTFEdit&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;]]&lt;/del&gt;, you will need to import your newly created texture.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;I'm going to recommend you use VTFEdit for this, because it's a great program.&amp;#160; Start off by opening up your Paint program of choice.&amp;#160; I'm not rich so I'll stick with MS Paint.&amp;#160; Go ahead and make it 512x512, it doesn't need to be anything special...a red background with the words &amp;quot;Procedural Screen&amp;quot; work wonderfully.&amp;#160; Now, in VTFEdit, you will need to import your newly created texture.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Here is what mine looks like.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Here is what mine looks like.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[Image&lt;/del&gt;:&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;vtfedit_import_options&lt;/del&gt;.png&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;|center|Import Texture Options]&lt;/del&gt;]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;img]http&lt;/ins&gt;:&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;//developer.valvesoftware.com/w/images/b/be/Vtfedit_import_options&lt;/ins&gt;.png&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[/img&lt;/ins&gt;]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So, after you are finished importing we need to set some flags.&amp;#160; These flags tell us an abundance of information about the image.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So, after you are finished importing we need to set some flags.&amp;#160; These flags tell us an abundance of information about the image.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l41&quot; &gt;Line 41:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 41:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:This one tells source that our base texture can change at runtime, without it everything else means nothing.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:This one tells source that our base texture can change at runtime, without it everything else means nothing.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/del&gt;VTFEdit&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;]]&lt;/del&gt;, it looks something like this:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So in VTFEdit, it looks something like this:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[[Image&lt;/del&gt;:&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;vtfedit_screen&lt;/del&gt;.png&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;|center|My Texture]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;http&lt;/ins&gt;:&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;//developer.valvesoftware.com/w/images/e/eb/Vtfedit_screen&lt;/ins&gt;.png&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== The material regenerator ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== The material regenerator ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>HeadCrabD</name></author>	</entry>

	<entry>
		<id>https://www.wiki.obsidianconflict.net/?title=Procedural_Materials&amp;diff=1235&amp;oldid=prev</id>
		<title>HeadCrabD: Created page with &quot;Procedural materials allow you to change the image at the pixel level during runtime.  To create a procedural material you will need 4 things.  You will need a VMT file to de...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.wiki.obsidianconflict.net/?title=Procedural_Materials&amp;diff=1235&amp;oldid=prev"/>
				<updated>2011-09-20T09:49:17Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;Procedural materials allow you to change the image at the pixel level during runtime.  To create a procedural material you will need 4 things.  You will need a &lt;a href=&quot;/?title=VMT&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;VMT (page does not exist)&quot;&gt;VMT&lt;/a&gt; file to de...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Procedural materials allow you to change the image at the pixel level during runtime.  To create a procedural material you will need 4 things.  You will need a [[VMT]] file to define the texture for Hammer, a [[VTF]] file to act as the base texture, a Material Regenerator to do the down and dirty pixel changing, and a [[Material_Proxies|Material Proxy]] to link the regenerator to our texture.&lt;br /&gt;
&lt;br /&gt;
== The VMT file ==&lt;br /&gt;
Let's start by defining our VMT file.  In here we will need to start by defining the type of shader this texture &amp;quot;inherits&amp;quot; from, is the best way I can describe it.  So, if I pick something like, &amp;quot;LightmappedGeneric&amp;quot;, I wont be able to make a procedural material because that shader is not setup for being changed at runtime, even if you flag your [[VTF]] as being procedural.  You will just end up with a black image :).  So, for our purposes I would choose something like, &amp;quot;UnlitGeneric&amp;quot;.  Another option is &amp;quot;MonitorScreen&amp;quot;.  Because these shaders do not limit me to having a static material.&lt;br /&gt;
&lt;br /&gt;
The next step is to choose a basetexture.  More than anything this texture is there for purposes of having a canvas to paint on.  You can always change it at runtime to increase its size...but I'm going to try and keep this as simple as possible.  So for now, just come up with a name for your texture, we will actually create it in the next step.&lt;br /&gt;
&lt;br /&gt;
After choosing a base texture, we need to come up with our proxy name.  We will define it later, but for now just come up with something creative.  PixelRenderer, excellent choice.  Now your [[VMT]] file should look something like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;UnlitGeneric&amp;quot;&lt;br /&gt;
{&lt;br /&gt;
	&amp;quot;$basetexture&amp;quot; &amp;quot;nicks_materials/prodscreen&amp;quot;&lt;br /&gt;
	&amp;quot;$translucent&amp;quot; 1&lt;br /&gt;
	&lt;br /&gt;
	&amp;quot;Proxies&amp;quot;&lt;br /&gt;
	{&lt;br /&gt;
		&amp;quot;PixelRenderer&amp;quot;&lt;br /&gt;
		{&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The VTF file ==&lt;br /&gt;
I'm going to recommend you use [[VTFEdit]] for this, because it's a great program.  Start off by opening up your Paint program of choice.  I'm not rich so I'll stick with MS Paint.  Go ahead and make it 512x512, it doesn't need to be anything special...a red background with the words &amp;quot;Procedural Screen&amp;quot; work wonderfully.  Now, in [[VTFEdit]], you will need to import your newly created texture.&lt;br /&gt;
&lt;br /&gt;
Here is what mine looks like.&lt;br /&gt;
&lt;br /&gt;
[[Image:vtfedit_import_options.png|center|Import Texture Options]]&lt;br /&gt;
&lt;br /&gt;
So, after you are finished importing we need to set some flags.  These flags tell us an abundance of information about the image.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;No Compression&amp;lt;/code&amp;gt;&lt;br /&gt;
:This one is chosen for us because, we chose a non-compressed format for our image.&lt;br /&gt;
;&amp;lt;code&amp;gt;No Mipmap&amp;lt;/code&amp;gt;&lt;br /&gt;
:Mip maps create problems when dealing with the LOD system and a dynamic image.  If we change the pixels in the image, the mip maps would need to be regenerated, and if you don't you will end up with random memory spew obfuscating parts of our beautiful procedural image.&lt;br /&gt;
;&amp;lt;code&amp;gt;No Level of Detail&amp;lt;/code&amp;gt;&lt;br /&gt;
:We don't want our image futzed the further away we get.&lt;br /&gt;
;&amp;lt;code&amp;gt;Procedural&amp;lt;/code&amp;gt;&lt;br /&gt;
:This one tells source that our base texture can change at runtime, without it everything else means nothing.&lt;br /&gt;
&lt;br /&gt;
So in [[VTFEdit]], it looks something like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:vtfedit_screen.png|center|My Texture]]&lt;br /&gt;
&lt;br /&gt;
== The material regenerator ==&lt;br /&gt;
Now, comes the part you've all been waiting for...and probably skipped right down to.  So lets get to it.  This is the brains of the operation, the meat of the can, the...you get the idea.  Start out by defining our class.  It will need to inherit from [[ITextureRegenerator]], because that's the regenerator interface.  There are 2 methods that we will need to overwrite for this to work.  RegenerateTextureBits(), which will be doing the pixel changing and Release(), which will act as our destructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CProceduralRegenerator : public ITextureRegenerator&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
	CProceduralRegenerator( void ) {};&lt;br /&gt;
	virtual void RegenerateTextureBits( ITexture *pTexture, IVTFTexture *pVTFTexture, Rect_t *pSubRect );&lt;br /&gt;
	virtual void Release( void );&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we need to regenerate our texture bits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void CProceduralRegenerator::RegenerateTextureBits( ITexture *pTexture, IVTFTexture *pVTFTexture, Rect_t *pSubRect )&lt;br /&gt;
{&lt;br /&gt;
	CPixelWriter pixelWriter;&lt;br /&gt;
	pixelWriter.SetPixelMemory( pVTFTexture-&amp;gt;Format(), &lt;br /&gt;
		pVTFTexture-&amp;gt;ImageData( 0, 0, 0 ), pVTFTexture-&amp;gt;RowSizeInBytes( 0 ) );&lt;br /&gt;
&lt;br /&gt;
	// Now upload the part we've been asked for&lt;br /&gt;
	int xmax = pSubRect-&amp;gt;x + pSubRect-&amp;gt;width;&lt;br /&gt;
	int ymax = pSubRect-&amp;gt;y + pSubRect-&amp;gt;height;&lt;br /&gt;
	int x, y;&lt;br /&gt;
&lt;br /&gt;
	for( y = pSubRect-&amp;gt;y; y &amp;lt; ymax; ++y )&lt;br /&gt;
	{&lt;br /&gt;
		pixelWriter.Seek( pSubRect-&amp;gt;x, y );&lt;br /&gt;
&lt;br /&gt;
		for( x=pSubRect-&amp;gt;x; x &amp;lt; xmax; ++x )&lt;br /&gt;
		{&lt;br /&gt;
			pixelWriter.WritePixel( y%256, 0, 0, 255 );&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also define your &amp;lt;code&amp;gt;Release()&amp;lt;/code&amp;gt; method, and delete anything you create.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void CProceduralRegenerator::Release()&lt;br /&gt;
{&lt;br /&gt;
	//delete stuff&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The material proxy ==&lt;br /&gt;
Here we will connect our regenerator to our texture. There is already an article on the [[Material_Proxies|Material Proxy]] so I wont go into too much detail. But start out by defining your material proxy class. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CProceduralProxy: public IMaterialProxy&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
	CProceduralProxy();&lt;br /&gt;
	virtual ~CProceduralProxy();&lt;br /&gt;
	virtual bool Init( IMaterial* pMaterial, KeyValues *pKeyValues );&lt;br /&gt;
	virtual void OnBind( void *pC_BaseEntity );&lt;br /&gt;
	virtual void Release( void ) { delete this; }&lt;br /&gt;
&lt;br /&gt;
private:&lt;br /&gt;
	IMaterialVar		*m_pTextureVar;   // The material variable&lt;br /&gt;
	ITexture		*m_pTexture;      // The texture&lt;br /&gt;
	ITextureRegenerator	*m_pTextureRegen; // The regenerator&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here's a basic constructor to just set all our pointers to NULL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CProceduralProxy::CProceduralProxy()&lt;br /&gt;
{&lt;br /&gt;
	m_pTextureVar = NULL;&lt;br /&gt;
	m_pTexture = NULL;&lt;br /&gt;
	m_pTextureRegen = NULL;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our destructor will be called when release is called note the { delete this; } inside the class definition of the method &amp;lt;code&amp;gt;Release()&amp;lt;/code&amp;gt;. Here we will disconnect our regenerator from the texture.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CProceduralProxy::~CProceduralProxy()&lt;br /&gt;
{&lt;br /&gt;
	if (m_pTexture != NULL)&lt;br /&gt;
	{&lt;br /&gt;
		m_pTexture-&amp;gt;SetTextureRegenerator( NULL );&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Init&amp;lt;/code&amp;gt; method is used to initialize everything during the &amp;lt;code&amp;gt;precache&amp;lt;/code&amp;gt; period of loading.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bool CProceduralProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )&lt;br /&gt;
{&lt;br /&gt;
	bool found;&lt;br /&gt;
	&lt;br /&gt;
	m_pTextureVar = pMaterial-&amp;gt;FindVar(&amp;quot;$basetexture&amp;quot;, &amp;amp;found, false);  // Get a reference to our base texture variable&lt;br /&gt;
	if( !found )&lt;br /&gt;
	{&lt;br /&gt;
		m_pTextureVar = NULL;&lt;br /&gt;
		return false;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	m_pTexture = m_pTextureVar-&amp;gt;GetTextureValue();  // Now grab a ref to the actual texture&lt;br /&gt;
	if (m_pTexture != NULL)&lt;br /&gt;
	{&lt;br /&gt;
		m_pTextureRegen = new CProceduralRegenerator( );  // Here we create our regenerator&lt;br /&gt;
		m_pTexture-&amp;gt;SetTextureRegenerator(m_pTextureRegen); // And here we attach it to the texture.&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;OnBind()&amp;lt;/code&amp;gt; method is called for lots of reasons, read the [[Material_Proxies|Material Proxy]] article for more info.  But think of this as our refresh method.  We use this to tell the regenerator it needs to update the bits, which happens every time a new frame is rendered. The Download() method is how we tell the regenerator to redraw. You have the option of passing in a sub-rectangle of space you want to change, but all it does is send that info to your regenerator which you can use or ignore. If you don't give it a rectangle it sends a rectangle matching the full dimensions of our texture.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void CProceduralProxy::OnBind( void *pEntity )&lt;br /&gt;
{&lt;br /&gt;
	if( !m_pTexture )  // Make sure we have a texture&lt;br /&gt;
		return;&lt;br /&gt;
&lt;br /&gt;
	if(!m_pTextureVar-&amp;gt;IsTexture())  // Make sure it is a texture&lt;br /&gt;
		return;&lt;br /&gt;
&lt;br /&gt;
	m_pTexture-&amp;gt;Download(); // Force the regenerator to redraw&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This exposes our proxy to the outside world and allows Source to match up the proxy class with the name listed as the proxy in the [[VMT]] file.&lt;br /&gt;
&lt;br /&gt;
 EXPOSE_INTERFACE( CProceduralProxy, IMaterialProxy, &amp;quot;PixelRenderer&amp;quot; IMATERIAL_PROXY_INTERFACE_VERSION );&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This brings us full circle, and now our texture should bend to the will of our imagination on what to render at runtime.  So now it's up to you to find a use for this feature.  I'm currently working on an AVI renderer to be used in game, for various movie playing applications.  You don't need to edit much of the code above to add this feature to your own games.  For more information, you should checkout [[AVIKit]], it has a very simple interface for doing just this.  For more information about playing movies in Source, see [[AVI Materials]].&lt;br /&gt;
&lt;br /&gt;
Here is an example of Red vs. Blue: Episode 1 playing in HL2.&lt;br /&gt;
&lt;br /&gt;
[[Image:Proctex1.jpg|thumb|left|300px|Before...]][[Image:Proctex2.jpg|thumb|left|300px|...and after.]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Material System]]&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>HeadCrabD</name></author>	</entry>

	</feed>