Game Development Community

PostFX texture

by Guy Allard · in Torque 3D Professional · 03/22/2010 (1:12 am) · 2 replies

Question 1:
I have an object that renders stuff to a texture each frame. The texture is allocated at runtime and is used as a render target by the object.

What I would like to do next is use that texture in a post effect. But, I have no idea how I make this texture available to the postFX system. I've been reading through all the shaders and postFX scripts and still have no clue.


Question 2:
What is the coordinate space of the vertex positions from the postFXV shader? Are they in world-space, camera space, or something else?
If they're not in world space, is there an easy way to convert them back to world space?



Any advice?


#1
03/22/2010 (2:31 am)
Hi Guy,
when T3D uses postfx, then T3D does not render the scene directly to the screen,it renders it to a texture.
This texture contains everything you'd usually see on the screen.
Then T3D renders a screen aligned quad, which covers the whole screen and uses this texture:

vertex positions:
top-left (-1,1)
top-right (1,1)
bottom-left (-1,-1)
bottom-right (1,-1)

texcoords:
top-left (0,0)
top-right (1,0)
bottom-left (0,1)
bottom-right (1,1)

You see those positions are at screen space.They are the same in eye space.
To transform from screen-to-world,there is a matScreenToWorld matrix,that you can use in your shader.

There is also a nice resource - a selection buffer.It is a good example of how to render to a buffer and how to sample from a buffer.
I think Konrad Kiss is the author.
#2
03/23/2010 (11:30 am)
Quote:I have no idea how I make this texture available to the postFX system
See the MatTextureTarget interface in engine\source\materials\matTextureTarget.h. You need to derive a class from this interface which allows PostEffect to find your texture by a target name (those are the names which start with #).

In 1.1 beta 2 we have snuck in a helper class called NamedTexture which does all this for you... just assign it a texture and give it a name.