Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


8up tuotlo

Member Since 23 Jan 2014
Offline Last Active Apr 10 2015 01:48 PM

Topics I've Started

Help with Skinned Mesh shader

09 April 2015 - 03:09 PM

I am use this HLSL D3DXEFFECT shader to draw my animated model in my application.

Shader model 3.0.

 

 
//-- Lighting ------
struct Direct
{
float3 pos;
float3 col;
};
Direct Dl[2];
float3 Al;
//------------------
 
float3 eye;
 
float Sp;
 
float4x4 BM[60];
 
float4x4 Gm;
float4x4 Wm;
 
struct VS_in
{
float4 Pos  : POSITION;
float3 Norm : NORMAL;
float2 Tex  : TEXCOORD0;
float4 bi   : BLENDINDICES0;
float4 bw<span> </span>: BLENDWEIGHT0;
};
 
struct VS_out
{
float4 Pos  : POSITION;
float3 Norm : TEXCOORD1;
float2 Tex  : TEXCOORD0;
float3 wPos : TEXCOORD2;
float3 v    : TEXCOORD3;
};
 
VS_out vs(VS_in In)
{
VS_out Out;
 
float4x4 blend = BM[In.bi.x]*In.bw.x + BM[In.bi.y]*In.bw.y + BM[In.bi.z]*In.bw.z + BM[In.bi.w]*In.bw.w;
 
float4 SkinPos, SkinNorm;
 
SkinPos.x = (In.Pos.x * blend._11)+(In.Pos.z * blend._21)+(In.Pos.y * blend._31)+(blend._41);
SkinPos.z = (In.Pos.x * blend._12)+(In.Pos.z * blend._22)+(In.Pos.y * blend._32)+(blend._42);
SkinPos.y = (In.Pos.x * blend._13)+(In.Pos.z * blend._23)+(In.Pos.y * blend._33)+(blend._43);
SkinPos.w = 1.0f;
 
SkinNorm.x = (In.Norm.x * blend._11)+(In.Norm.z * blend._21)+(In.Norm.y * blend._31);
SkinNorm.z = (In.Norm.x * blend._12)+(In.Norm.z * blend._22)+(In.Norm.y * blend._32);
SkinNorm.y = (In.Norm.x * blend._13)+(In.Norm.z * blend._23)+(In.Norm.y * blend._33);
SkinNorm.w = 1.0f;
 
Out.Pos = mul(SkinPos, Gm);
Out.Tex = In.Tex;
Out.Norm = normalize(mul(SkinNorm, (float3x3)Wm));
Out.wPos = mul(SkinPos, Wm);
Out.v = eye.xyz - Out.wPos;
 
return Out;
}
 
float3 light(float3 n, float3 v)
{
float  nDotL[2];
 
nDotL[0] = saturate(dot(n, normalize(Dl[0].pos)));
nDotL[1] = saturate(dot(n, normalize(Dl[1].pos)));
 
float3 ret = Dl[0].col * nDotL[0] + Dl[1].col * nDotL[1] + Al;
/*+ (Dl[0].col * ((nDotL[0] == 0.0f) ? 0.0f : pow((saturate(dot(n, normalize(Dl[0].pos + v)))), Sp)));*/
 
return ret;
}
 
float4 ps(VS_out In) : COLOR0
{
return float4(light(normalize(In.Norm), normalize(In.v)), 1);
}
 
technique Standart
{ 
    pass P0
    {          
        VertexShader = compile vs_3_0 vs();
PixelShader  = compile ps_3_0 ps();
    }
}
 

 

it is maximum of 60 bones by:

 

float4x4 BM[60];

 

when i try to set it to:

 

float4x4 BM[120];

 

shader not works.

 

Who knows why?

Can it be set to 120, and how if it is possible?


Use Depth buffer as texture

27 February 2014 - 08:06 AM

Is it possible to set depth buffer as the texture to effect (LPDIRECT3DEFFECT9) in direct3d?

 

thanks.


per channle sampler_state

16 February 2014 - 07:27 PM

i am using this to set filtering of texture...

 

 

sampler2D DTS = sampler_state
{
Texture = <DiffuseMap>;
    MagFilter = Linear;
    MinFilter = Linear;
    MipFilter = Linear;
};
 
how to apply filtering on any channel of texture?
 
thanks

How to use VFACE in HLSL?

23 January 2014 - 08:05 PM

Ho can show me short example of how to use VFACE register in HLSL


PARTNERS