Re: How to blend 2 textures based on vertex alpha values in realtime viewports

Date : Mon, 07 May 2007 14:10:05 +0200
To : XSI(at)Softimage.COM
From : "Fred Jacob" <3freduard(at)gmx.de>
Subject : Re: How to blend 2 textures based on vertex alpha values in realtime viewports
Thx Andy for the thorough reply.

I need this for a game we're working on that does the same blending at runtime, so there's no point in baking maps or rendering anything at all.

"Writing" a shader is what I did by using ShaderFX, which is more like connecting nodes and exporting the resulting shader code
as an *.fx file. However, loading the fx file in XSI "works" (that is: it does not crash) by loading it through the DXFX2 DX9 shading node, but does not render anything.
See attached fx file for reference if you dare.

What would be the benefit of using Cg over DX?
Are there graphical editors that can output Cg code? I was hoping for Mental Mill but that's not released yet as it seems.
The thing is I really don't want to get into shader programming right now as our time schedule is really tight.

Thanks again for your input,

Stefan
-------- Original-Nachricht --------
Datum: Sat, 05 May 2007 16:30:40 +0200
Von: Andy Jones <andy(at)thefront.com>
An: XSI(at)Softimage.COM
Betreff: Re: How to blend 2 textures based on vertex alpha values in realtime viewports

> Hey Stefan,
> 
> I have four approaches I can propose.  The first would involve coding a 
> custom cg shader yourself, or having someone else do it.  This all 
> happens in the interface, so it's not as bad as having to write a shader 
> in C or something (though generally, I'd say writing MR shaders in C can 
> be easier than writing RT shaders in cg, depending on what you're 
> doing).  Having to write some code to do something like what you're 
> describing is ultimately not such a bad thing, as once you know how to 
> code these things, you can pretty much do anything you think of within 
> the limits of the hardware.  This is the solution I recommend.  To 
> access the vertex colors in XSI with a cg shader, you use the COLOR0 
> semantic.  This is also handy in general, because even if you don't have 
> a vertex color map, it reads the diffuse color.  At least, that's how I 
> remember it working...   My experience doing this in XSI has mostly been 
> with the CGProgram node.  But if I were starting all over, I'd probably 
> try to do everything with the .fx plugin.  You can definitely do what 
> you're trying to do with custom cg programs.
> 
> The other possible solution I know for doing texture blending, which I'm 
> not even sure works, is to use a 2-pass shader with the standard OpenGL 
> nodes.  Basically, this just means you have to OpenGL Draw nodes in the 
> shader.  Each draws something to the screen.  So, in this case, each one 
> would draw one of the textures and you'd have to attenuate them somehow, 
> via the blending modes in the draw node.  But I'm not actually sure if 
> you can read the vertex colors from any of the OpenGL nodes, so that 
> might not actually work.
> 
> The third option is to set up a mental ray shader and just rendermap 
> it.  Whether that's useful depends on what you're doing, but a lot of 
> times it's just way easier and faster to do complicated stuff like this 
> with MR.  In a few cases, I've foolishly squandered hours trying to do 
> things in realtime, when sometimes just doing it in MR and dealing with 
> non real-time viewport updates just isn't so bad.
> 
> The fourth option would be to use the FX tree to do the texture blending 
> for you, onto a single clip.  Although, there might be somedifficulty 
> with the vertex colors.  I suppose you could rendermap those...  But it 
> all depends on what your workflow is.
> 
> Hope this helps.
> 
> -Andy
> 
> Fred Jacob wrote:
> 
> >Good morning list!
> >
> >I've been trying to set up a shading network that would show 2 textures
> blended over each other on a per vertex alpha value basis.
> >I want to paint the vertex alpha values using the paint tool, but I don't
> want to render region after every paint stroke I do to see the effect so I
> need this to be displayed in realtime.
> >
> >So far I was not very successful in setting up a realtime shader that
> would
> >do that. I tried with the fixed function DX, Cg and OpenGl shading nodes
> XSI provides out of the box to no avail, and I also tried using an fx file
> I created with the ShaderFX plugin for 3dsMax (which seems to fail to
> render in XSI propery because the shader queries the vertex colors in a
> Max-compatible way, which seems to be different in XSI).
> >
> >Any hint towards an alternative approach, a link to a working OpenGL
> shader (or whatever allows me to work in the viewports, 'cause in DirectX
> display mode no tools seem to display 
> >correctly, including manipulators of the SRT tools and the paint tools,
> which renders DX display a bit useless in the first place) is highly
> appreciated.
> >
> >Also, I was wondering if there are any plans to integrate Mental Mill
> into XSI at some point.
> >
> >Thanks a lot,
> >
> >Stefan
> >
> >
> >
> >
> >
> >
> >
> >
> >  
> >
> 
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> unsubscribe xsi

-- 
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.