• 11
• 9
• 10
• 9
• 10

# HLSL help request

This topic is 4612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm just having a bit of a strang result with some hlsl code. My basic atempt with this code is to perform simple goemetry blending. Everything seems to go fine untill i include one line of code. I am trying to add two vectors but when I do this the hlsl code is actually casuses a crash in Effect edit and FX Composer. When I try to run the code using an Effect interface. I get a runtime error, that occurs when I try to load the effect from file. I am trying a component add i.e. v0.xyz =v1.xyz+v2.xyz; This doesn't work neithter does v0 = v1+v2; I have also tried to add each component seperately, this is where it gets even a bit more strang to me. I am fine when I include the lines to v0.x = v1.x+v2.x; v0.y = v1.y+v2.y; but when I include the z addition I get the fault in the Effects file. Does anyone see what could be causing this? Thanks for all your hlep.
//--------------------------------------------------------------------------------------
// Global variables
//--------------------------------------------------------------------------------------

float4x4		g_mWorldCurrent;							//world matrix
float4x4		g_mWorldRoot;								//Root blending matrix
float4x4		g_mWorldChild;								//Child blending matrix
float4x4		g_mViewProj;								// the view*proj matrix
//float3			g_vEyePoint;							//the vector point of the eye
//float3			g_vLightPosition;						//the light position
texture			g_tTex1;									//texture reference

//--------------------------------------------------------------------------------------
//Samplers and Structures
//--------------------------------------------------------------------------------------
sampler2D TexSampler = sampler_state				//sampler for texture
{
//set sampler states
texture = <g_tTex1>;
mipfilter = LINEAR;
minfilter = LINEAR;
magfilter = LINEAR;
};

struct VS_INPUT
{
float4 Pos:					POSITION0;
float3 Normal :				NORMAL0;
float2 Tex0 :				TEXCOORD0;
float  BlendWeights :		TEXCOORD1;
};

struct VS_OUTPUT
{
float4 Pos:			POSITION0;
float2 Tex0:			TEXCOORD0;
};

struct PS_INPUT
{
float2 Tex0:			TEXCOORD0;
};
//--------------------------------------------------------------------------------------
//Vertex and Pixel Mains
//--------------------------------------------------------------------------------------
VS_OUTPUT VSMain (VS_INPUT In )
{
VS_OUTPUT Out;
float4	vTemp1;
float4	vTemp2;
float4   vTemp3;

//Transform the position by both matrices for the blending
vTemp1 = mul(In.Pos, g_mWorldCurrent);
vTemp2 = mul(In.Pos, g_mWorldRoot);

//Multiply the vertices byt the blending weight
vTemp1 = mul(vTemp1,(1.0-In.BlendWeights.x));
vTemp2 = mul(vTemp1,In.BlendWeights.x);
//combine the weighted amounts of each transformed vertex

Out.Pos.x = vTemp1.x+vTemp2.x;
Out.Pos.y = vTemp1.y+vTemp2.y;
//Out.Pos.y = vTemp1.y;
Out.Pos.z = vTemp1.z+vTemp2.z;
//Out.Pos.z = vTemp1.z;
Out.Pos.w = 1;
Out.Pos = mul(Out.Pos,g_mViewProj);
Out.Tex0 = In.Tex0;
return Out;
}

float4 PSMain (PS_INPUT In): COLOR0
{
float4 OutColor;
OutColor = tex2D(TexSampler,In.Tex0);
return OutColor;
}

//--------------------------------------------------------------------------------------
// Techniques
//--------------------------------------------------------------------------------------
technique RenderScene
{

pass P0
{
CullMode = NONE;
FogEnable = false;
Lighting = false;
}
}
technique RenderSceneNoBlend
{

pass P0
{
ColorArg1[0] = TEXTURE;
ColorOp[0]   = SELECTARG1;
Lighting = true;
LightEnable[0] = true;
CullMode = CCW;
}

}