<li><aclass="backlink"title="Click to do a full-text search for this title"href="./ArtReference_Q4Shaders_Extra_Passes?action=fullsearch&value=linkto%3A%22ArtReference+Q4Shaders+Extra+Passes%22&context=180">ArtReference Q4Shaders Extra Passes</a></li>
<spanclass="anchor"id="line-1"></span><pclass="line874">This section is by no means complete, as the shader system has more options in it than I could cover in one document. In this section we’ll go over some basics with extra passes in the shader system. <spanclass="anchor"id="line-2"></span><spanclass="anchor"id="line-3"></span><pclass="line867"><hr/><pclass="line874"><spanclass="anchor"id="line-4"></span><spanclass="anchor"id="line-5"></span><pclass="line867">
<spanclass="anchor"id="line-6"></span><spanclass="anchor"id="line-7"></span><pclass="line867"><strong>What is an extra pass?</strong> Every time you open and close a shader entry in the same shader entry you’re writing a pass. Extra passes are any entries other than the diffuse, bump, height, specular, and imagemap entries. <spanclass="anchor"id="line-8"></span><spanclass="anchor"id="line-9"></span><pclass="line867"><strong>Time</strong>: A unit of measure in game. When the game starts, the games begins counting, and stops when the level is disconnected, or is shut down. No one really knows what the unit is, but its assumed its 1 to 1, although I think it uses fuzzy logic. <spanclass="anchor"id="line-10"></span><spanclass="anchor"id="line-11"></span><pclass="line867"><strong>Modulation</strong>: Changes the UV values of vertices on a surface. Usually the first number is the U or horizontal direction, and the second value is V or the vertical direction. <spanclass="anchor"id="line-12"></span><spanclass="anchor"id="line-13"></span><pclass="line867"><strong>Tables</strong>: Tables are numeric strings that act as modulation over time. See the tables’ section for more info. <spanclass="anchor"id="line-14"></span><spanclass="anchor"id="line-15"></span><pclass="line867"><strong>Scroll</strong>: Changes the UV values of vertices on a surface. Moves the textures across a surface. There are 2 entries, the first number is for the positive and negative horizontal while the second number represents the positive and negative vertical. (Example: scroll 1, 0.) The range can be controlled over time. <spanclass="anchor"id="line-16"></span><spanclass="anchor"id="line-17"></span><pclass="line867"><strong>Scale</strong>: Scales occur to the lower left hand portion of the textures. 2 values, the lower the number the larger the image, so a ‘scale 3, 3 would be smaller than a scale .5, .5. Scale can be modulated over time. <spanclass="anchor"id="line-18"></span><spanclass="anchor"id="line-19"></span><pclass="line867"><strong>Centerscale</strong>: Same rules apply as Scale, but it scales from the center. (Example: centerscale 1, 1.) Centerscale can be modulated over time. <spanclass="anchor"id="line-20"></span><spanclass="anchor"id="line-21"></span><pclass="line867"><strong>Shear</strong>: skews the texture from its center. The 2 entries represent the amount of shear you want. A little goes a long way, I think 1 = a 45 degree increment. (Example: shear .5, .5) Shear can be modulated over time. <spanclass="anchor"id="line-22"></span><spanclass="anchor"id="line-23"></span><pclass="line867"><strong>Rotate</strong>: spins the texture (0 to 1), 0 = 0 degree and 1 = 360 degrees. Can be modulated over time. <spanclass="anchor"id="line-24"></span><spanclass="anchor"id="line-25"></span><pclass="line867"><strong>Color</strong>: Numerically modulate the existing texture. Can be modulated over time through an expression. <spanclass="anchor"id="line-26"></span><spanclass="anchor"id="line-27"></span><pclass="line867"><strong>Colored</strong>: Pays attention to the parm 0 parm 1 and parm 2. Shortcut to use the parms. Breaks if you define color values. <spanclass="anchor"id="line-28"></span><spanclass="anchor"id="line-29"></span><pclass="line867"><strong>RGB</strong>: Monochromatic. Applies modulation to the RGB value (meaning an entity) <spanclass="anchor"id="line-30"></span><strong>RGBA</strong>: Monochromatic with alpha. Same as above except includes alpha. <spanclass="anchor"id="line-31"></span><spanclass="anchor"id="line-32"></span><pclass="line867"><strong><spanclass="u">Blend modes</span></strong>: <spanclass="anchor"id="line-33"></span>Blend modes have 2 entries: One is, what do I do with the thing I’m drawing right now (Source Blend Mode), and the second is what is happening to the values that are already there. (Destination Blend Mode). The first is the source blend and the second is the destination blend on the blend line. (example blend gl_one, gl_one) <spancla
<spanclass="anchor"id="line-38"></span><spanclass="anchor"id="line-39"></span><pclass="line867"><strong>GL_ONE</strong>: Add the color of whatever is in the buffer. <spanclass="anchor"id="line-40"></span><spanclass="anchor"id="line-41"></span><pclass="line867"><strong>GL_ZERO</strong>: Don’t draw whatever is in the source. <spanclass="anchor"id="line-42"></span><spanclass="anchor"id="line-43"></span><pclass="line867"><strong>GL_DST_COLOR</strong>: Draw the source only over areas that have positive RGB values. <spanclass="anchor"id="line-44"></span><spanclass="anchor"id="line-45"></span><pclass="line867"><strong>GL_ONE_MINUS_DST_COLOR</strong>: Darken the colors based on the colors behind it. (If you invert the colors, it’s a way to make targas work without an alpha pass) re-write. <spanclass="anchor"id="line-46"></span><spanclass="anchor"id="line-47"></span><pclass="line867"><strong>GL_SRC_ALPHA</strong>: Only draw areas based on the positive alpha <spanclass="anchor"id="line-48"></span><spanclass="anchor"id="line-49"></span><pclass="line867"><strong>GL_ONE_MINUS_SRC_ALPHA</strong>: Only draw the inverse of the alpha source channel <spanclass="anchor"id="line-50"></span><spanclass="anchor"id="line-51"></span><pclass="line867"><strong>GL_DST_ALPHA</strong>: Use the alpha from the surface you are drawing on. <spanclass="anchor"id="line-52"></span><spanclass="anchor"id="line-53"></span><pclass="line867"><strong>GL_ONE_MINUS_DST_ALPHA</strong>: Use the inverse alpha from the surface you’re drawing the source on. <spanclass="anchor"id="line-54"></span><spanclass="anchor"id="line-55"></span><pclass="line867"><hr/><pclass="line874"><spanclass="anchor"id="line-56"></span><spanclass="anchor"id="line-57"></span><pclass="line867">
<spanclass="anchor"id="line-58"></span><spanclass="anchor"id="line-59"></span><pclass="line867"><strong>GL_ONE</strong>: Take whatever colors are already there, and add it into the scene. <spanclass="anchor"id="line-60"></span><spanclass="anchor"id="line-61"></span><pclass="line867"><strong>GL_ZERO</strong>: Do not draw the images behind the color. <spanclass="anchor"id="line-62"></span><spanclass="anchor"id="line-63"></span><pclass="line867"><strong>GL_SRC_ALPHA</strong>: Draw the background in, according the source alpha. <spanclass="anchor"id="line-64"></span><spanclass="anchor"id="line-65"></span><pclass="line867"><strong>GL_ONE_MINUS_SRC_ALPHA</strong>: Draw the background in according to the inverse of the source alpha. <spanclass="anchor"id="line-66"></span><spanclass="anchor"id="line-67"></span><pclass="line867"><strong>GL_DST_ALPHA</strong>: Draw the background based on the destination alpha. <spanclass="anchor"id="line-68"></span><spanclass="anchor"id="line-69"></span><pclass="line867"><strong>GL_ONE_MINUS_DST_ALPHA</strong>: Draw the background based on the inverse of the background alpha <spanclass="anchor"id="line-70"></span><spanclass="anchor"id="line-71"></span><pclass="line867"><strong>GL_SRC_COLOR</strong>: Draw the background based on the source color. (makes transparent, good for glass) <spanclass="anchor"id="line-72"></span><spanclass="anchor"id="line-73"></span><pclass="line867"><strong>GL_ONE_MINUS_SRC_COLOR</strong>: Fill in whatever is not being used by the source color. <spanclass="anchor"id="line-74"></span><spanclass="anchor"id="line-75"></span><pclass="line867"><hr/><pclass="line874"><spanclass="anchor"id="line-76"></span><spanclass="anchor"id="line-77"></span><pclass="line867">
<spanclass="anchor"id="line-78"></span><pclass="line874">There are shortcuts. If you know you’re going to be writing a lot of these, or if you want to avoid the GL stuff, use these: <spanclass="anchor"id="line-79"></span><spanclass="anchor"id="line-80"></span><pclass="line867"><strong>Blend add</strong>: GL_ONE, GL_ONE: typical glow pass. Draw the background and add the foreground onto it. Set up the file so that your colors are the glow pass and the black are dropped out. <spanclass="anchor"id="line-81"></span><spanclass="anchor"id="line-82"></span><pclass="line867"><strong>Blend blend</strong>: GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA = Draw as much of your source as your alpha will allow and make up the rest with your background colors. Set up your .tga with an alpha. <spanclass="anchor"id="line-83"></span><spanclass="anchor"id="line-84"></span><pclass="line867"><strong>Blend filter</strong>: GL_DST_COLOR, GL_ZERO : Drops out the White of the file, darkening to the degree of black in the image. Basic multiply parameter. <spanclass="anchor"id="line-85"></span><spanclass="anchor"id="line-86"></span><pclass="line867"><strong>Blend None</strong>: Only when writing to the depth buffer… For <aclass="nonexistent"href="./MaskAlpha">MaskAlpha</a>. <spanclass="anchor"id="line-87"></span><spanclass="anchor"id="line-88"></span><pclass="line867"><strong>Shader Parameters</strong>: These options affect the whole shader entry, do not use these in individual shader passes. Its best to place these at the top of the shader after you open the initial pass. Nonsolid: Makes the texture or model surface non-solid. All shots and characters pass through it. <spanclass="anchor"id="line-89"></span><spanclass="anchor"id="line-90"></span><pclass="line867"><strong>Noimpact</strong>: Makes the texture or model surface non-solid. All shots pass through the texture. <spanclass="anchor"id="line-91"></span><spanclass="anchor"id="line-92"></span><pclass="line867"><strong>Noshadows</strong>: The texture or model will not cast a shadow. <spanclass="anchor"id="line-93"></span><spanclass="anchor"id="line-94"></span><pclass="line867"><strong>Noselfshadows</strong>: The model will not cast a shadow on itself. <spanclass="anchor"id="line-95"></span><spanclass="anchor"id="line-96"></span><pclass="line867"><strong>Playerclip</strong>: Texture blocks the player but nothing else. <spanclass="anchor"id="line-97"></span><spanclass="anchor"id="line-98"></span><pclass="line867"><strong>Monsterclip</strong>: Texture blocks monsters but nothing else. <spanclass="anchor"id="line-99"></span><spanclass="anchor"id="line-100"></span><pclass="line867"><strong>Unsmoothedtangents</strong>: This has to functions. The first thing it does is, average the normals during a _local.tga render. The second is, it must stay in the shader to mark it as using averaged normals. Used for animated or moving models. <spanclass="anchor"id="line-101"></span><spanclass="anchor"id="line-102"></span><pclass="line867"><hr/><pclass="line874"><spanclass="anchor"id="line-103"></span><spanclass="anchor"id="line-104"></span><pclass="line867">
<spanclass="anchor"id="line-105"></span><spanclass="anchor"id="line-106"></span><pclass="line867"><strong>Clamp</strong>: Disables the tiling of a texture on a polygon. Used in stages <spanclass="anchor"id="line-107"></span><spanclass="anchor"id="line-108"></span><pclass="line867"><strong>Zeroclamp</strong>: Same as Clamp, except a black border on of one pixel will be preserves on all mip levels. Used in stages. <spanclass="anchor"id="line-109"></span><spanclass="anchor"id="line-110"></span><pclass="line867"><strong><aclass="nonexistent"href="./AlphaZeroClamp">AlphaZeroClamp</a></strong>: Same as Clamp, except a translucent white border on of one pixel will be preserves on all mip levels. <spanclass="anchor"id="line-111"></span><spanclass="anchor"id="line-112"></span><pclass="line867"><strong>Smoothnormals</strong>: Effects the bumpmap line only. Can smooth the local and height, or local or height. Should be used sparingly, since it can drastically alter the normal. Example: <spanclass="anchor"id="line-113"></span><spanclass="anchor"id="line-114"></span><pre>Bumpmap addnormals ((smoothnormals models/blah_local.tga), heightmap (models/blah_h.tga, 3)) This would smooth the local but not the height.
<spanclass="anchor"id="line-115"></span></pre><spanclass="anchor"id="line-116"></span><spanclass="anchor"id="line-117"></span><pclass="line867"><strong>Deforms</strong>: <spanclass="anchor"id="line-118"></span><strong>Deform Flare</strong>: Must be a quad. (2 tris) Creates new set of polygons around the original edges of the quad. Pushes them away from the corners, perpendicular to the camera, by the amount placed in the shader line. By default, the original polygon is assigned a white shader and the new border edges are mapped with a quadratic falloff. (Example: Deform flare 50) <spanclass="anchor"id="line-119"></span><spanclass="anchor"id="line-120"></span><pclass="line867"><strong>Deform Sprite</strong>: Rotates the polygon to the camera. Must be a quad. (2 tris) <spanclass="anchor"id="line-121"></span><spanclass="anchor"id="line-122"></span><pclass="line867"><strong>Deform Expand</strong>: Takes the polygons and scales them by the amount listed. They can be use a table and be modulated over time. (Example : Deform Expand 30) <spanclass="anchor"id="line-123"></span>(On a table: deform expand sintable [time] ) <spanclass="anchor"id="line-124"></span><spanclass="anchor"id="line-125"></span><pclass="line867"><strong>Alpha</strong>: <spanclass="anchor"id="line-126"></span><strong>Alphatest</strong>: Hard edged alpha. Goes through each pixel and determines whether the alpha value is greater or equal to the number, and draws it. (Example <aclass="nonexistent"href="./AlphaTest">AlphaTest</a> .5) Bilinear filtering happens after the Alphatest. Example: <spanclass="anchor"id="line-127"></span><spanclass="anchor"id="line-128"></span><pclass="line867"><strong><aclass="nonexistent"href="./IgnoreAlphatest">IgnoreAlphatest</a></strong>: Ignores Alpha test for that stage. <spanclass="anchor"id="line-129"></span><spanclass="anchor"id="line-130"></span><pclass="line867"><strong><aclass="nonexistent"href="./MaskAlpha">MaskAlpha</a></strong>: Current pass is not allowed to change the alpha values. <spanclass="anchor"id="line-131"></span><spanclass="anchor"id="line-132"></span><pclass="line867"><strong><aclass="nonexistent"href="./InverseAlpha">InverseAlpha</a></strong>: Inverts the previous alpha pass in this stage. <spanclass="anchor"id="line-133"></span><spanclass="anchor"id="line-134"></span><pclass="line867"><hr/><pclass="line874"><spanclass="anchor"id="line-135"></span><spanclass="anchor"id="line-136"></span><pclass="line867">
<h3id="head-5bf20a871ea6a10aa1972ae016f98986c873e3af">Some Common shader passes</h3>
<spanclass="anchor"id="line-137"></span><spanclass="anchor"id="line-138"></span><pclass="line867"><strong>Glow pass: (additive passes)</strong><spanclass="anchor"id="line-139"></span>The glow pass is the most common extra pass. Through this entry we can fake a lighting effect without adding a dynamic light in game. <spanclass="anchor"id="line-140"></span><spanclass="anchor"id="line-141"></span><pre> {
<spanclass="anchor"id="line-145"></span></pre><spanclass="anchor"id="line-146"></span><pclass="line867"><strong>Hard edged Alpha</strong><spanclass="anchor"id="line-147"></span>In this pass, the diffuse map will need an alpha channel with just black and white. <spanclass="anchor"id="line-148"></span><spanclass="anchor"id="line-149"></span><pre> {
<spanclass="anchor"id="line-154"></span></pre><spanclass="anchor"id="line-155"></span><pclass="line867"><strong>Soft edged Alpha</strong><spanclass="anchor"id="line-156"></span>In this, you’ll need to make an alpha channel with shades of gray. White is opaque and black is transparent. All the ranges in between are viable. <spanclass="anchor"id="line-157"></span><spanclass="anchor"id="line-158"></span><pre> {
<spanclass="anchor"id="line-162"></span></pre><spanclass="anchor"id="line-163"></span><spanclass="anchor"id="line-164"></span><pclass="line874">Well…that’s all. There are a lot of different combinations of shaders you can use to get different effects. A lot of shaders have been written, so if there is something you’d want to try in a shader, nine times out of ten there are examples in the *.mtr files. <spanclass="anchor"id="line-165"></span><spanclass="anchor"id="bottom"></span></div><pid="pageinfo"class="info"lang="en"dir="ltr">ArtReference Q4Shaders Extra Passes (last edited 2005-11-04 21:51:06 by <spantitle="MattVainio @ 67.129.250.254[67.129.250.254]"><aclass="nonexistent"href="./MattVainio"title="MattVainio @ 67.129.250.254[67.129.250.254]">MattVainio</a></span>)</p>
<li><ahref="http://moinmoin.wikiwikiweb.de/">MoinMoin Powered</a></li><li><ahref="http://www.python.org/">Python Powered</a></li><li><ahref="http://validator.w3.org/check?uri=referer">Valid HTML 4.01</a></li>