Game Development Community

Silhuette shader from RenderMonkey help

by BBS Games · in Torque Game Engine Advanced · 05/12/2006 (8:19 am) · 4 replies

Hi All,

I'm trying to implement a simple 2 stages shader from RenderMonkey examples but I don't understand
how to provide a render target to the first pass (the same texture will be used by the second pass to perform edge detection);
looking at CustomMaterial source I've seen that there is a $miscbuf that I colud provide to second stage as input texture...how to setup a render target with $miscbuf as output?

My first idea was to subclass CumstomMaterial and add a flag to setup a render target like the texture[n] parameter...is this the right choice or there is another method to setup a render target from material definition?

#1
05/21/2006 (5:16 am)
Short answer: no. Render targets cannot be specified at material level, at least not yet. You'll need to do some changes to CustomMaterial so you can specify a render target.

It's not that hard, and you can look at how to switch render targets by looking at the glowBuffer code, the waterBlock code, and the legacy terrain code (it does terrain blending in a render target, I believe).

A good idea (are you listening GG?) would be creating a RenderTarget class, exposed to console just like the materials and customMaterials are. So you could create as much of those as you need, and set them to shader passes using a new "target" field.
#2
05/22/2006 (12:25 am)
I've done something like this:

- a class that can hold the render target (and that you can define in your scripts like the GlowBuffer)
- I have modified CustomMaterial to select the render texture
- also if a render target is specified, the material "tells" to tsMesh::Render(...) to switch the render target before the call to GFX->drawPrimitive( i );

This code isn't very flexible, I'd like to define different render target objects and select the one I want (as a render target or a texture source) via CustomMaterial definition; now I don't have the time to do this but when this will be done I'll post here
#3
05/22/2006 (1:10 am)
Sounds useful for some of those people out there who dont know how to add things theirselves, like full scene post procesing shaders.
#4
05/18/2009 (5:54 pm)
not sure if bb is still following this or not, but I am guessing you got the Silhouette shader into torque. Could you post it as a resource or something, cause I am really interested in using it as well and am not really sure how the multiple render passes for a shader works in in Torque.