VertexIn_PNTTTB (possible bugs)
by Joshua Horns · in Torque 3D Professional · 08/30/2009 (12:51 pm) · 6 replies
So I'm working on this gravity shader thing that someone posted and I'm having a couple of problems.
Fist, view the shader results so far here:
www.joshuahorns.com/panTilt-1.wmv
Now for the problems:
1. VertexIn_PNTTTB.T (the tangent component) seems to be (0,0,0). I had some problems converting things to object space so I rendered the tangent as a color and it was all black. In order to get this shader to work I hacked a value into it.
2.
Edit* - Problem 2 was me. I suck with Houdini (XSI ftw).
Fist, view the shader results so far here:
www.joshuahorns.com/panTilt-1.wmv
Now for the problems:
1. VertexIn_PNTTTB.T (the tangent component) seems to be (0,0,0). I had some problems converting things to object space so I rendered the tangent as a color and it was all black. In order to get this shader to work I hacked a value into it.
2.
Edit* - Problem 2 was me. I suck with Houdini (XSI ftw).
#2
Thanks for the update.
08/30/2009 (5:43 pm)
Oh, ok thanks. I was going off of the DiffBump shaders. I didn't bother to check to see what was using this shader. I just went off of the first one I saw that used tangent space.Thanks for the update.
ConnectData main( VertexIn_PNTTTB IN,
uniform float4x4 modelview : register(C0),
uniform float4x4 texMat : register(C4),
uniform float3 inLightVec : register(C24),
uniform float3 eyePos : register(C20),
uniform float4x4 objTrans : register(C12)
)
{
ConnectData OUT;
OUT.hpos = mul(modelview, IN.pos);
float4 texCoordExtend = float4( IN.uv0, 0.0, 1.0 );
OUT.outTexCoord = mul(texMat, texCoordExtend);
OUT.bumpCoord = OUT.outTexCoord;
float3x3 objToTangentSpace;
objToTangentSpace[0] = IN.T;
objToTangentSpace[1] = IN.B;
objToTangentSpace[2] = IN.normal;
OUT.outLightVec.xyz = -inLightVec;
OUT.outLightVec.xyz = mul(objToTangentSpace, OUT.outLightVec);
OUT.outLightVec = OUT.outLightVec / 2.0 + 0.5;
return OUT;
}
#3
08/30/2009 (5:52 pm)
Is the struct used in this shader applicable? I am trying to find a way to determine what is shading a DTS.//*****************************************************************************
// Torque -- HLSL procedural shader
//*****************************************************************************
// Dependencies:
#include "shaders/common/lighting.hlsl"
//------------------------------------------------------------------------------
// Autogenerated 'Light Buffer Conditioner [RGB]' Uncondition Method
//------------------------------------------------------------------------------
inline void autogenUncondition_bde4cbab(in float4 bufferSample, out float3 lightColor, out float NL_att, out float specular)
{
lightColor = bufferSample.rgb;
NL_att = dot(bufferSample.rgb, float3(0.3576, 0.7152, 0.1192));
specular = max(bufferSample.a / NL_att, 0.00001f);
}
// Features:
// Vert Position
// Base Texture
// Alpha Test
// Bumpmap [Deferred]
// Deferred RT Lighting
// Visibility
// Translucent
struct VertData
{
float3 position : POSITION;
float tangentW : TEXCOORD3;
float3 normal : NORMAL;
float3 T : TANGENT;
float2 texCoord : TEXCOORD0;
};
struct ConnectData
{
float4 hpos : POSITION;
float2 out_texCoord : TEXCOORD0;
float3x3 worldToTangent : TEXCOORD1;
float3 wsPosition : TEXCOORD4;
};
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
ConnectData main( VertData IN,
uniform float4x4 modelview : register(C0),
uniform float4x4 worldToObj : register(C4),
uniform float4x4 objTrans : register(C8)
)
{
ConnectData OUT;
// Vert Position
OUT.hpos = mul(modelview, float4(IN.position.xyz,1));
// Base Texture
OUT.out_texCoord = IN.texCoord;
// Alpha Test
// Bumpmap [Deferred]
float3x3 objToTangentSpace;
objToTangentSpace[0] = IN.T;
objToTangentSpace[1] = cross( IN.T, normalize(IN.normal) ) * IN.tangentW;
objToTangentSpace[2] = normalize(IN.normal);
float3x3 worldToTangent = mul( objToTangentSpace, worldToObj );
OUT.worldToTangent = worldToTangent;
// Deferred RT Lighting
OUT.wsPosition = mul( objTrans, float4( IN.position.xyz, 1 ) ).xyz;
// Visibility
// Translucent
return OUT;
}
#4
I would guess thats probably some sortof mesh.
You can also use Materail::dumpInstances to find the procedural shader files associated with a particular material. Shaders are linked to materials, not directly to a dts.
08/30/2009 (8:03 pm)
That right there actually is doing what tom was talking about, generating the binormal in the vertex shader rather than passing it in with the VertData.I would guess thats probably some sortof mesh.
You can also use Materail::dumpInstances to find the procedural shader files associated with a particular material. Shaders are linked to materials, not directly to a dts.
#5
Thanks, I'll try using this struct.
08/30/2009 (8:26 pm)
So I can just add this struct to my file and use it to access the streams? The question about the DTS was based on my understanding of what Tom had said about DTS models not passing Binormals and not to use the struct with the TBN info. Thanks, I'll try using this struct.
# struct VertData
# {
# float3 position : POSITION;
# float tangentW : TEXCOORD3;
# float3 normal : NORMAL;
# float3 T : TANGENT;
# float2 texCoord : TEXCOORD0;
# };
#
#6
Its tricky because there is no way currently from a CustomMaterial to know what the exact vertex format will be for a particular material.
09/01/2009 (8:49 pm)
I believe that should work. Its tricky because there is no way currently from a CustomMaterial to know what the exact vertex format will be for a particular material.
Associate Tom Spilman
Sickhead Games
If you look at a few existing procedural shaders for DTS models you should see the right vertex format.