iddevnet/quake4/ArtReference_Q4Shaders_Definitions
Daniel Gibson ef46a7566e Quake4 part of Yamagis dump
will need heavy cleaning up before it becomes usable at all
2021-04-10 03:29:43 +02:00

260 lines
22 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="robots" content="index,nofollow">
<title>ArtReference Q4Shaders Definitions - Quake 4 SDK Documentation</title>
<script type="text/javascript" src="/wiki/common/js/common.js"></script>
<script type="text/javascript">
<!--// common functions
// We keep here the state of the search box
searchIsDisabled = false;
function searchChange(e) {
// Update search buttons status according to search box content.
// Ignore empty or whitespace search term.
var value = e.value.replace(/\s+/, '');
if (value == '' || searchIsDisabled) {
searchSetDisabled(true);
} else {
searchSetDisabled(false);
}
}
function searchSetDisabled(flag) {
// Enable or disable search
document.getElementById('fullsearch').disabled = flag;
document.getElementById('titlesearch').disabled = flag;
}
function searchFocus(e) {
// Update search input content on focus
if (e.value == 'Search') {
e.value = '';
e.className = '';
searchIsDisabled = false;
}
}
function searchBlur(e) {
// Update search input content on blur
if (e.value == '') {
e.value = 'Search';
e.className = 'disabled';
searchIsDisabled = true;
}
}
function actionsMenuInit(title) {
// Initialize action menu
for (i = 0; i < document.forms.length; i++) {
var form = document.forms[i];
if (form.className == 'actionsmenu') {
// Check if this form needs update
var div = form.getElementsByTagName('div')[0];
var label = div.getElementsByTagName('label')[0];
if (label) {
// This is the first time: remove label and do buton.
div.removeChild(label);
var dobutton = div.getElementsByTagName('input')[0];
div.removeChild(dobutton);
// and add menu title
var select = div.getElementsByTagName('select')[0];
var item = document.createElement('option');
item.appendChild(document.createTextNode(title));
item.value = 'show';
select.insertBefore(item, select.options[0]);
select.selectedIndex = 0;
}
}
}
}
//-->
</script>
<link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="/wiki/modern/css/common.css">
<link rel="stylesheet" type="text/css" charset="utf-8" media="screen" href="/wiki/modern/css/screen.css">
<link rel="stylesheet" type="text/css" charset="utf-8" media="print" href="/wiki/modern/css/print.css">
<link rel="stylesheet" type="text/css" charset="utf-8" media="projection" href="/wiki/modern/css/projection.css">
<!-- css only for MSIE browsers -->
<!--[if IE]>
<link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="/wiki/modern/css/msie.css">
<![endif]-->
<link rel="Start" href="/quake4/Quake4SDK">
<link rel="Alternate" title="Wiki Markup" href="/quake4/ArtReference_Q4Shaders_Definitions?action=raw">
<link rel="Alternate" media="print" title="Print View" href="/quake4/ArtReference_Q4Shaders_Definitions?action=print">
<link rel="Search" href="/quake4/FindPage">
<link rel="Index" href="/quake4/TitleIndex">
<link rel="Glossary" href="/quake4/WordIndex">
<link rel="Help" href="/quake4/HelpOnFormatting">
</head>
<body lang="en" dir="ltr">
<div id="header">
<div id="logo"><a href="/quake4/Quake4SDK"><img src="/wiki/common/moinmoin.png" alt="MoinMoin Logo"></a></div>
<form id="searchform" method="get" action="">
<div>
<input type="hidden" name="action" value="fullsearch">
<input type="hidden" name="context" value="180">
<label for="searchinput">Search:</label>
<input id="searchinput" type="text" name="value" value="" size="20"
onfocus="searchFocus(this)" onblur="searchBlur(this)"
onkeyup="searchChange(this)" onchange="searchChange(this)" alt="Search">
<input id="titlesearch" name="titlesearch" type="submit"
value="Titles" alt="Search Titles">
<input id="fullsearch" name="fullsearch" type="submit"
value="Text" alt="Search Full Text">
</div>
</form>
<script type="text/javascript">
<!--// Initialize search form
var f = document.getElementById('searchform');
f.getElementsByTagName('label')[0].style.display = 'none';
var e = document.getElementById('searchinput');
searchChange(e);
searchBlur(e);
//-->
</script>
<ul id="username"><li><a href="/quake4/ArtReference_Q4Shaders_Definitions?action=login" id="login">Login</a></li></ul>
<div id="locationline">
<ul id="pagelocation">
<li><a class="backlink" title="Click to do a full-text search for this title" href="/quake4/ArtReference_Q4Shaders_Definitions?action=fullsearch&amp;value=linkto%3A%22ArtReference+Q4Shaders+Definitions%22&amp;context=180">ArtReference Q4Shaders Definitions</a></li>
</ul>
</div>
<ul id="navibar">
<li class="wikilink"><a href="/quake4/GettingStarted">GettingStarted</a></li><li class="wikilink"><a href="/quake4/ScriptFile">ScriptFile</a></li><li class="wikilink"><a href="/quake4/MakeAMod">MakeAMod</a></li><li class="wikilink"><a href="/quake4/LevelEditor">LevelEditor</a></li><li class="wikilink"><a href="/quake4/FXEditor">FXEditor</a></li><li class="wikilink"><a href="/quake4/GUIEditor">GUIEditor</a></li><li class="wikilink"><a href="/quake4/Sounds">Sounds</a></li><li class="wikilink"><a href="/quake4/Animations">Animations</a></li><li class="wikilink"><a href="/quake4/ArtReference">ArtReference</a></li><li class="wikilink"><a href="/quake4/DownloadableContent">DownloadableContent</a></li><li class="wikilink"><a href="/quake4/RecentChanges">RecentChanges</a></li><li class="wikilink"><a href="/quake4/FindPage">FindPage</a></li><li class="wikilink"><a href="/quake4/HelpContents">HelpContents</a></li><li class="current"><a href="/quake4/ArtReference_Q4Shaders_Definitions">ArtReferenc...Definitions</a></li>
</ul>
<div id="pageline"><hr style="display:none;"></div>
<ul class="editbar"><li><span class="disabled">Immutable Page</span></li><li><a href="/quake4/ArtReference_Q4Shaders_Definitions?action=info">Info</a></li><li><a href="/quake4/ArtReference_Q4Shaders_Definitions?action=AttachFile">Attachments</a></li><li>
<form class="actionsmenu" method="get" action="">
<div>
<label>More Actions:</label>
<select name="action"
onchange="if ((this.selectedIndex != 0) &&
(this.options[this.selectedIndex].disabled == false)) {
this.form.submit();
}
this.selectedIndex = 0;">
<option value="raw">Raw Text</option>
<option value="print">Print View</option>
<option value="RenderAsDocbook">Render as Docbook</option>
<option value="refresh">Delete Cache</option>
<option value="show" disabled class="disabled">------------</option>
<option value="SpellCheck">Check Spelling</option>
<option value="LikePages">Like Pages</option>
<option value="LocalSiteMap">Local Site Map</option>
<option value="show" disabled class="disabled">------------</option>
<option value="RenamePage" disabled class="disabled">Rename Page</option>
<option value="DeletePage" disabled class="disabled">Delete Page</option>
<option value="show" disabled class="disabled">------------</option>
<option value="MyPages">My Pages</option>
<option value="SubscribeUser">Subscribe User</option>
<option value="show" disabled class="disabled">------------</option>
<option value="Despam">Remove Spam</option>
<option value="PackagePages">Package Pages</option>
</select>
<input type="submit" value="Do">
</div>
<script type="text/javascript">
<!--// Init menu
actionsMenuInit('More Actions:');
//-->
</script>
</form>
</li></ul>
</div>
<div id="page" lang="en" dir="ltr">
<div dir="ltr" id="content" lang="en"><span class="anchor" id="top"></span>
<span class="anchor" id="line-1"></span><p class="line874">Here are some basic definitions for shaders, using the example. <span class="anchor" id="line-2"></span><span class="anchor" id="line-3"></span><p class="line874">The first thing we need to do is define the basics: <span class="anchor" id="line-4"></span><span class="anchor" id="line-5"></span><ol type="1"><li><p class="line862">A <strong>Material</strong> is a file format (.mtr) that the game reads. <span class="anchor" id="line-6"></span><span class="anchor" id="line-7"></span></li><li class="gap"><p class="line862">A <strong>Shader</strong> is an entry in the material file. Shaders combine all of the source files (_d, _h, _s, _local plus extra passes) so the games lighting can be used properly. <span class="anchor" id="line-8"></span><span class="anchor" id="line-9"></span></li><li class="gap"><p class="line891"><strong>Spaces</strong> between shader commands and path names are used to begin and end strings and commands. <span class="anchor" id="line-10"></span><span class="anchor" id="line-11"></span></li><li class="gap"><p class="line891"><strong>Path names</strong> are used to point to a file. The directory paths on Q and the paths in the shaders are the same. <span class="anchor" id="line-12"></span><span class="anchor" id="line-13"></span></li><li class="gap"><p class="line862">// = <strong>Comment out</strong>. If you want the game to ignore a line in a shader, put this in front of the line and the game will ignore it. Using this is essential for troubleshooting. You can comment out blocks of entries by placing a /* before the area you want to have commented out and a */ after the area that you want commented out. The areas between these are commented out. <span class="anchor" id="line-14"></span><span class="anchor" id="line-15"></span></li><li class="gap"><p class="line891"><strong>Defaults</strong>: the game loads from q4base, so you wont need to write q4base in the shader path names. <span class="anchor" id="line-16"></span><span class="anchor" id="line-17"></span></li></ol><p class="line867"><strong>Example:</strong> <span class="anchor" id="line-18"></span><span class="anchor" id="line-19"></span><pre>1) models/monsters/iron_maiden/base
<span class="anchor" id="line-20"></span>2) {
<span class="anchor" id="line-21"></span>3) noselfshadow
<span class="anchor" id="line-22"></span>4) unsmoothedtangents
<span class="anchor" id="line-23"></span>
<span class="anchor" id="line-24"></span>5) renderbump -size 512 512 -trace 0.07 -aa 2 models/monsters/heavyhovertank/hh_lo_b_local.tga work/models/monsters/heavy_hover_tank/hh_hi_14.lwo
<span class="anchor" id="line-25"></span>
<span class="anchor" id="line-26"></span>6) materialImage models/monsters/iron_maiden/base_hit.tga
<span class="anchor" id="line-27"></span>
<span class="anchor" id="line-28"></span>7) diffusemap models/monsters/iron_maiden/base_d.tga
<span class="anchor" id="line-29"></span>8) bumpmap addnormals ( models/monsters/iron_maiden/base_local.tga, heightmap ( models/monsters/iron_maiden/base_h.tga, 2 ))
<span class="anchor" id="line-30"></span>9) specularmap models/monsters/iron_maiden/base_s.tga
<span class="anchor" id="line-31"></span>
<span class="anchor" id="line-32"></span>10) {
<span class="anchor" id="line-33"></span>11) blend add
<span class="anchor" id="line-34"></span>12) map models/monsters/iron_maiden/base_g.tga
<span class="anchor" id="line-35"></span>13) }
<span class="anchor" id="line-36"></span>
<span class="anchor" id="line-37"></span>14) }
<span class="anchor" id="line-38"></span></pre><span class="anchor" id="line-39"></span><p class="line874">What well do is define all of the shader line by line. <span class="anchor" id="line-40"></span><span class="anchor" id="line-41"></span><ol type="1"><li><p class="line891"><strong>The shader title</strong> (models/monsters/iron_maiden/base) This is probably one of the most used lines in the game. This is the name of the shader that the game looks for when its used by an entity or brush in the game. <span class="anchor" id="line-42"></span><span class="anchor" id="line-43"></span><ol type="i"><li><p class="line862">For <strong>Textures</strong> this is the name that appears in the editor. It also serves as a path name, so if youre looking for a texture in medlabs and the name of the shader is textures/medlabs/wall1, the texture would be in the same directory. The last entry in the line is the texture name and the previous entries (textures/medlabs) are organizational directories in the editor <span class="anchor" id="line-44"></span><span class="anchor" id="line-45"></span></li><li class="gap"><p class="line862">For <strong>Models</strong>, the shader title needs to be added as a <em>surface on the model itself</em>. When the model is loaded into the game, it sees the shader name and loads the texture as projected by the UV map. You can have multiple shader titles on the same model. All youd need to do is select the geometry in your 3d package and assign the shader name to it. <span class="anchor" id="line-46"></span><span class="anchor" id="line-47"></span></li></ol></li><li class="gap"><p class="line862">The <strong>Open bracket</strong> ({ ) begins the first pass of the shader. <em>ALL SHADERS NEED TO HAVE AN OPEN AND A CLOSE BRACKET</em>. If not, the game will either crash or break a long list of other shaders following it. Think of the shader title as a chapter title and the open and close brackets are the beginning and the ending of a chapter. <span class="anchor" id="line-48"></span><span class="anchor" id="line-49"></span></li><li class="gap"><p class="line891"><strong>Shader Parameters</strong> are <em>attributes that are applied to the whole shader</em>. <span class="anchor" id="line-50"></span><span class="anchor" id="line-51"></span></li><li class="gap">Another Global Shader Parameter option <span class="anchor" id="line-52"></span><span class="anchor" id="line-53"></span></li><li class="gap"><p class="line862">The <strong>Render (bump) line</strong> is used ONLY in models. This line is NOT used in game for viewing a set of targas. Activating a model for rendering a normal map uses this line, otherwise its dormant string. <span class="anchor" id="line-54"></span><span class="anchor" id="line-55"></span></li><li class="gap"><p class="line862">The <strong><a class="nonexistent" href="/quake4/MaterialImage">MaterialImage</a></strong> is an option that allows for a texture or a model to have multiple hit impacts, by using a color coated Targa. If you use this option you must point it to a targa by writing a path name to the file. So if you were to shoot the Iron Maiden in the above example, the impact would change depending on where you hit it. (The <a class="nonexistent" href="/quake4/MaterialImage">MaterialImage</a> targa has colors for flesh, solidmetal, hollowmetal, and gelatinous fluids) <strong><a class="nonexistent" href="/quake4/MaterialType">MaterialType</a></strong> is a command that assumes that the whole testure or skin has one attribure (all flesh, all rubber) it does not load a TGA, it uses a script so we save on texture memory! <span class="anchor" id="line-56"></span><span class="anchor" id="line-57"></span></li><li class="gap"><p class="line891"><strong>Diffusemap</strong> is a shortcut option that creates a rendering stage for the diffuse targa (base colors of the texture or skin) This line needs a path name to the file (.tga) being used. In this case (models/monsters/iron_maiden/base_d.tga) All diffuse targas should have an _d suffix. <span class="anchor" id="line-58"></span><span class="anchor" id="line-59"></span></li><li class="gap"><p class="line891"><strong>Bumpmap</strong> is a shortcut option that creates a rendering stage for the Height targa and Local targa. In this case you need an additional command <strong>addnormals</strong> to this string, this allows for the height targa and the local targa to be loaded in unison. This line needs a path name to the files (.tga) being used. <span class="anchor" id="line-60"></span><span class="anchor" id="line-61"></span><ol type="i"><li><p class="line862">The <strong>Bumpmap</strong> uses the _local targa. This file allows the texture or model to take light correctly. The _local files are generated in game by either renderbumping a texture or a high poly model to a low poly model. <span class="anchor" id="line-62"></span><span class="anchor" id="line-63"></span></li><li class="gap"><p class="line891"><strong>Heightmap</strong> is used to call out the targa used as a surface for the shader. This is usually a black and white image where white is a positive change (up) and black is a negative change (down). The number after the path name is the degree in which you want the range to occur. <span class="anchor" id="line-64"></span><span class="anchor" id="line-65"></span></li><li class="gap">Because this is using addnormals you need to separate the files by using parentheses, youll need to open and close them like using a shader pass. Make sure you separate the heightmap line with a comma, then the number otherwise it wont know to attach it to the previous path. <span class="anchor" id="line-66"></span><span class="anchor" id="line-67"></span></li><li class="gap">If you need to write a bumpmap without the height remove the height line and the parentheses. <span class="anchor" id="line-68"></span><span class="anchor" id="line-69"></span></li><li class="gap">The local map targa should always have an _local suffix, while the height map targa shouls have an _h suffix. <span class="anchor" id="line-70"></span><span class="anchor" id="line-71"></span></li></ol></li><li class="gap"><p class="line862">The <strong>Specularmap</strong> is a shortcut option that creates a rendering stage for the specular targa. This file adds reflectivity to the texture or model. This is a pretty sensitive file so they tend to be pretty dark. This line needs a path name to the file (.tga) being used. In this case (models/monsters/iron_maiden/base_s.tga) All specular targas should have an _s suffix. <span class="anchor" id="line-72"></span><span class="anchor" id="line-73"></span></li><li class="gap"><p class="line891"><strong>Extra passes</strong> also need opened and closed brackets. Why add an extra pass? Well if you want a glow pass, modulation or anything other than the base of the model, then youll need an extra pass. Remember, every extra pass is a hit to the processing speed. Some shaders dont use the above render options, these are specialty textures used for various reasons. (fx, guis, glass, water, fire etc) <span class="anchor" id="line-74"></span><span class="anchor" id="line-75"></span></li><li class="gap"><p class="line891"><strong>Blend Add</strong> is a <strong>blending option</strong>. In this case blend add is short hand for blend GL_ONE, GL_ONE. This is an additive pass, and is the option for glow passes. This needs a path name to a targa file. <span class="anchor" id="line-76"></span><span class="anchor" id="line-77"></span></li><li class="gap"><p class="line891"><strong>Path name</strong> to the glow support targa. <span class="anchor" id="line-78"></span><span class="anchor" id="line-79"></span></li><li class="gap"><p class="line862">The <strong>Close Bracket</strong> ( } ) is used to close a shader pass. This close bracket closes the first extra pass, the glowing pass. <span class="anchor" id="line-80"></span><span class="anchor" id="line-81"></span></li><li class="gap"><p class="line862">Another <strong>Close Bracket</strong> ( }) This closes the shader out, and the game is happy. This close bracket is attached to the top Open Bracket. <span class="anchor" id="line-82"></span></li></ol><span class="anchor" id="bottom"></span></div><p id="pageinfo" class="info" lang="en" dir="ltr">ArtReference Q4Shaders Definitions (last edited 2005-11-04 21:36:57 by <span title="MattVainio @ 67.129.250.254[67.129.250.254]"><a class="nonexistent" href="/quake4/MattVainio" title="MattVainio @ 67.129.250.254[67.129.250.254]">MattVainio</a></span>)</p>
<div id="pagebottom"></div>
</div>
<div id="footer">
<ul class="editbar"><li><span class="disabled">Immutable Page</span></li><li><a href="/quake4/ArtReference_Q4Shaders_Definitions?action=info">Info</a></li><li><a href="/quake4/ArtReference_Q4Shaders_Definitions?action=AttachFile">Attachments</a></li><li>
<form class="actionsmenu" method="get" action="">
<div>
<label>More Actions:</label>
<select name="action"
onchange="if ((this.selectedIndex != 0) &&
(this.options[this.selectedIndex].disabled == false)) {
this.form.submit();
}
this.selectedIndex = 0;">
<option value="raw">Raw Text</option>
<option value="print">Print View</option>
<option value="RenderAsDocbook">Render as Docbook</option>
<option value="refresh">Delete Cache</option>
<option value="show" disabled class="disabled">------------</option>
<option value="SpellCheck">Check Spelling</option>
<option value="LikePages">Like Pages</option>
<option value="LocalSiteMap">Local Site Map</option>
<option value="show" disabled class="disabled">------------</option>
<option value="RenamePage" disabled class="disabled">Rename Page</option>
<option value="DeletePage" disabled class="disabled">Delete Page</option>
<option value="show" disabled class="disabled">------------</option>
<option value="MyPages">My Pages</option>
<option value="SubscribeUser">Subscribe User</option>
<option value="show" disabled class="disabled">------------</option>
<option value="Despam">Remove Spam</option>
<option value="PackagePages">Package Pages</option>
</select>
<input type="submit" value="Do">
</div>
<script type="text/javascript">
<!--// Init menu
actionsMenuInit('More Actions:');
//-->
</script>
</form>
</li></ul>
<ul id="credits">
<li><a href="http://moinmoin.wikiwikiweb.de/">MoinMoin Powered</a></li><li><a href="http://www.python.org/">Python Powered</a></li><li><a href="http://validator.w3.org/check?uri=referer">Valid HTML 4.01</a></li>
</ul>
</div>
</body>
</html>