Vertex Texture Fetching?
by Matt Vitelli · in Torque Game Engine Advanced · 11/19/2006 (7:59 pm) · 9 replies
While I realize vertex texture fetching is not only expensive, but is also unsupported on most (all?) ATI cards it would still be a neat experiment to try. Gamasutra has a nice article on this.
Adding this information to the TSE water vertex shader was fairly easy. However, I do get the following error:
And that line is:
I have 2 Nvidia 7800s running in SLI, and I believe VTF is supported on all of their shader model 3 cards.
Any ideas?
- Matt Vitelli
Adding this information to the TSE water vertex shader was fairly easy. However, I do get the following error:
error X4532: cannot map expression to vertex shader instruction set
And that line is:
float vDisp = tex2D (bumpMap, t).x;
I have 2 Nvidia 7800s running in SLI, and I believe VTF is supported on all of their shader model 3 cards.
Any ideas?
- Matt Vitelli
#2
11/21/2006 (6:11 pm)
Yes, I've adjusted everything to shader model 3.0
#3
11/30/2006 (4:47 pm)
I've never tried this. Are you sure there isn't a special texture sample instruction for the vertex shaders?
#4
12/03/2006 (1:42 am)
Ok. After playing around with this for a few minutes I was able to get the vertex shader to compile. I have yet to test this though and chances are I'm doing something stupid. The parameters are all wrong, but I think it's one of my better "3:00 AM" projects. :)//*****************************************************************************
// Blank Shader
//*****************************************************************************
#define IN_HLSL
#include "shdrConsts.h"
//---------------------------------------------------------------
// Constants
//---------------------------------------------------------------
struct a2v
{
float4 position : POSITION;
float4 texCoord : TEXCOORD0;
};
struct v2f
{
//float4 HPOS : POSITION;
float2 texCoord : TEXCOORD0;
};
//---------------------------------------------------------------
// Main
//---------------------------------------------------------------
float4 main( a2v In, uniform float4x4 modelview : register(VC_WORLD_PROJ),
uniform sampler2D tex0 : register(S1),
uniform float4 DMParameters : register(VC_MAT_SPECPOWER),
uniform float4 VOfs : register(VC_DETAIL_SCALE)
) : POSITION
{
float4 INP = In.position;
float2 uv = In.texCoord;
INP.xy = INP.xy * ( pow (INP.z, 4) * VOfs.z);
float2 t = (INP.xy + VOfs.xy) * DMParameters.x;
float4 tex1 = tex2D(tex0, uv);
float vDisp = (tex1, t).x;
INP.z = DMParameters.y + (vDisp - 0.5) * DMParameters.z;
// Displace current position with water height
// and project it
return mul (modelview, INP);
}
#5
12/12/2006 (5:49 pm)
Did it work out? Your code is practically copy and paste. The demo of it on the GPU gems 2 cd is fairly impressive regardless of the constant 'resetting' the waves if you move just a little.
#6
Is there anywhere where sampler info can be found in TSE? I've searched but haven't had much luck. If any GG employee could clarify where such info for sampler registers can be found, I would be eternally grateful. I've tried VTF in other situations and it's worked fine, so I'm assuming this is a TSE related problem. I'm guessing the sampler registers were only meant to be handled through the pixel shader.
02/07/2007 (9:08 pm)
I've started work on this again. The error is clearly with the uniform sampler2D and S0 register. Is there anywhere where sampler info can be found in TSE? I've searched but haven't had much luck. If any GG employee could clarify where such info for sampler registers can be found, I would be eternally grateful. I've tried VTF in other situations and it's worked fine, so I'm assuming this is a TSE related problem. I'm guessing the sampler registers were only meant to be handled through the pixel shader.
#7
02/08/2007 (11:06 am)
I haven't tried VTF, but IIRC you need a special vertex format to use it? Something to look into. You might want to check the DIRECTXDEV archives for more info on this.
#8
06/15/2007 (3:59 pm)
I've been looking into this on and off for the past few months and after looking at examples and reading about Nvidia's shader model 3.0 architecture, the problem behind it is clear. tex2D functions can not be used in HLSL in a vertex program, but tex2Dlod can be. Also, vertex textures need to be in fp32 (that is, floating-point 32-bit.) The dds plugin in Photoshop can export to this format. I have adjusted the shader to correctly work, but now I think I realize what the problem is: FP32 isn't a supported GFXFormat, correct me if I'm wrong.
#9
06/17/2007 (2:03 pm)
And ATI do not support VTF as well to make it an even larger problem.
Torque Owner Thomas Phillips
Assuming you have adjusted pixVersion, perhaps the complete modified shader is too large? (I.e., it may consume too many instruction slots.) If this is the case, you would have to optimize the code somehow.
Tom