<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>[SOLVED] How do I properly setup multiple TEV stages?</title>
<description> I&amp;#039;m currently working on a test program that demonstrates environment mapping (such as chrome) and cel-shading through the use of Texture matrices and certain TexGen settings. I wanted to be able to render a texture mapped model with cel-shading through the use of the TEV to blend both textures together but I can&amp;#039;t figure out how to do it properly at the moment.

What I want to do is to have my cel-shading texture blend over the model&amp;#039;s base texture through the use of multiple TEV stages but I can&amp;#039;t figure out how to do it properly. TexGens work properly but not the TEV stages as I always get bunch of black and white pixels jumbled all over the geometry. Am I missing some necessary parameters?

Here&amp;#039;s some pseudo-code on how I setup the TEV stages before rendering the model:

GX_LoadTexObj(BarbTex.Texture.TexObj(), GX_TEXMAP0);
GX_LoadTexObj(CelTex.Texture.TexObj(), GX_TEXMAP1);

GX_SetNumTexGens(2);
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
GX_SetTexCoordGen(GX_TEXCOORD1, GX_TG_SRTG, GX_TG_COLOR0, GX_IDENTITY);

GX_SetNumTevStages(2);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR0A0);

object.RenderModel();

I can&amp;#039;t really release the full source code as it uses MTek-GDL and is a tad bit cluttered up but I can release it if the full source is absolutely necessary for solving this problem.

Any useful help will be gladly appreciated! And no, don&amp;#039;t discourage me from finding a way on how to use TEV stages properly as I want to make Wii homebrew that would look pretty as ever in the future.</description><link>http://forum.wiibrew.org/read.php?11,74856,74856#msg-74856</link><lastBuildDate>Mon, 18 May 2026 15:12:00 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,74856,74866#msg-74866</guid>
<title>Re: How do I properly setup multiple TEV stages?</title><link>http://forum.wiibrew.org/read.php?11,74856,74866#msg-74866</link><description><![CDATA[ You&#039;ve got a fair bit of redundant code in there.<br />GX_SetTevOp() is just an easy wrapper to avoid manually calling all of GX_SetTevAlphaIn() + GX_SetTevColorIn() + GX_SetTevAlphaOp() + GX_SetTevColorOp(), so it&#039;s pointless to call them all before it.<br />You&#039;re enabling the raster input channels for tev stage 1 (GX_COLOR0A0) but it&#039;s not being used as an input.]]></description>
<dc:creator>tueidj</dc:creator>
<category>Coding</category><pubDate>Thu, 13 Aug 2015 04:31:36 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,74856,74862#msg-74862</guid>
<title>Re: How do I properly setup multiple TEV stages?</title><link>http://forum.wiibrew.org/read.php?11,74856,74862#msg-74862</link><description><![CDATA[ Eventually... The spanish example you provided demonstrates drop shadows if you really wanna know how to do it.]]></description>
<dc:creator>TheCodingBrony</dc:creator>
<category>Coding</category><pubDate>Wed, 12 Aug 2015 05:41:40 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,74856,74861#msg-74861</guid>
<title>Re: How do I properly setup multiple TEV stages?</title><link>http://forum.wiibrew.org/read.php?11,74856,74861#msg-74861</link><description><![CDATA[ Will u attempt to do shadows?]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Wed, 12 Aug 2015 04:28:38 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,74856,74860#msg-74860</guid>
<title>Re: How do I properly setup multiple TEV stages?</title><link>http://forum.wiibrew.org/read.php?11,74856,74860#msg-74860</link><description><![CDATA[ Okay, I finally figured it out... Here&#039;s how you modulate a texture based on another texture&#039;s color intensities which is what I needed to do cel-shading with texture mapping:<br /><pre class="bbcode">
/* NOTE: Set a working light source so that GX_TG_SRTG will work correctly */

// Texture mapped with Cel-shading (using 2 TEV stages)
GX_LoadTexObj(BarbTex.Texture.TexObj(), GX_TEXMAP0); // Load model texture to GX_TEXMAP0
GX_LoadTexObj(CelTex.Texture.TexObj(), GX_TEXMAP1);  // Load cel shader texture to GX_TEXMAP1

// Prepare TexGens for cel-shading and texture mapping
GX_SetNumTexGens(2);
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); // Model texture coords
GX_SetTexCoordGen(GX_TEXCOORD1, GX_TG_SRTG, GX_TG_COLOR0, GX_IDENTITY); // For cel-shading


// Set TEV stages for cel shading with texture mapping
GX_SetNumTevStages(2);


// Prepare TEV stage 0 (cel texture)
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD1, GX_TEXMAP1, GX_COLORNULL);

// Get TEV color input to texture color
GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_TEXC, GX_CC_C0, GX_CC_ZERO, GX_CC_ZERO);

// We don&#039;t need the alpha channel of the cel texture as we&#039;ll be modulating its intensity to the model&#039;s texture
GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO);

// Set TEV operators to ADD and use default bias and scale values
GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_2, GX_TRUE, GX_TEVPREV);
GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_2, GX_TRUE, GX_TEVPREV);

// We&#039;ll be ignoring vertex colors since we&#039;re going for cel shading based on a texture map so we&#039;ll just use GX_REPLACE
GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE);


// Prepare TEV stage 1 (model texture)
GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);

// Take color and alpha values from texture
GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_TEXC, GX_CC_C0, GX_CC_ZERO, GX_CC_ZERO);
GX_SetTevAlphaIn(GX_TEVSTAGE1, GX_CA_TEXA, GX_CA_A0, GX_CA_ZERO, GX_CA_ZERO);

// Same operator values as TEV stage 0
GX_SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);

// Modulate the final pixel color relative to the cel shader texture
GX_SetTevOp(GX_TEVSTAGE1, GX_MODULATE);


// Render model (must have normals)
object.RenderModel();</pre><br />And here&#039;s the result (model on the top left is chrome/reflection mapped, top right is cel-shaded and the one on the bottom is cel-shaded with texture mapping through 2 TEV stages):<br /><img src="http://i1344.photobucket.com/albums/p659/LameGuy64/shader_fx_zpsgplonlfr.png" class="bbcode" border="0" /><br /><br /><br />Full example of this test program will be included in the next release of MTek-GDL...]]></description>
<dc:creator>TheCodingBrony</dc:creator>
<category>Coding</category><pubDate>Wed, 12 Aug 2015 03:24:45 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,74856,74859#msg-74859</guid>
<title>Re: How do I properly setup multiple TEV stages?</title><link>http://forum.wiibrew.org/read.php?11,74856,74859#msg-74859</link><description><![CDATA[ That is just what I needed! I&#039;ll post a message once I figure out how to setup multiple TEVs which should be easier to figure out now that I have that precious bit of example code.]]></description>
<dc:creator>TheCodingBrony</dc:creator>
<category>Coding</category><pubDate>Tue, 11 Aug 2015 05:09:53 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,74856,74858#msg-74858</guid>
<title>Re: How do I properly setup multiple TEV stages?</title><link>http://forum.wiibrew.org/read.php?11,74856,74858#msg-74858</link><description><![CDATA[ found this sometime ago. its in Spanish be easy to translate;<br /><br />[<a href="http://www.elotrolado.net/hilo_wii-graficos-3d-para-wii-pdf-ejemplos_1049703" rel="nofollow">www.elotrolado.net</a>]]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Tue, 11 Aug 2015 04:21:32 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,74856,74856#msg-74856</guid>
<title>[SOLVED] How do I properly setup multiple TEV stages?</title><link>http://forum.wiibrew.org/read.php?11,74856,74856#msg-74856</link><description><![CDATA[ I&#039;m currently working on a test program that demonstrates environment mapping (such as chrome) and cel-shading through the use of Texture matrices and certain TexGen settings. I wanted to be able to render a texture mapped model with cel-shading through the use of the TEV to blend both textures together but I can&#039;t figure out how to do it properly at the moment.<br /><br />What I want to do is to have my cel-shading texture blend over the model&#039;s base texture through the use of multiple TEV stages but I can&#039;t figure out how to do it properly. TexGens work properly but not the TEV stages as I always get bunch of black and white pixels jumbled all over the geometry. Am I missing some necessary parameters?<br /><br />Here&#039;s some pseudo-code on how I setup the TEV stages before rendering the model:<br /><pre class="bbcode">
GX_LoadTexObj(BarbTex.Texture.TexObj(), GX_TEXMAP0);
GX_LoadTexObj(CelTex.Texture.TexObj(), GX_TEXMAP1);

GX_SetNumTexGens(2);
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
GX_SetTexCoordGen(GX_TEXCOORD1, GX_TG_SRTG, GX_TG_COLOR0, GX_IDENTITY);

GX_SetNumTevStages(2);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR0A0);

object.RenderModel();</pre><br />I can&#039;t really release the full source code as it uses MTek-GDL and is a tad bit cluttered up but I can release it if the full source is absolutely necessary for solving this problem.<br /><br />Any useful help will be gladly appreciated! And no, don&#039;t discourage me from finding a way on how to use TEV stages properly as I want to make Wii homebrew that would look pretty as ever in the future.]]></description>
<dc:creator>TheCodingBrony</dc:creator>
<category>Coding</category><pubDate>Mon, 10 Aug 2015 16:18:36 +0200</pubDate></item>
</channel>
</rss>