sas_x86

Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

102 Neutral

About sas_x86

  • Rank
    Newbie
  1. HLSL Pixel Shader returns (0,0,0,0)

    [quote name='NickUdell' timestamp='1336736804' post='4939270'] Can you check in pix that your matrices are definitely being set? May I also ask why Output.Position and Output.Position2D are identical? Seems a bit of a waste of space and resources... [/quote] Hello. My matrices are set. I can see it in Mesh window of Pix (Pre-vertex shader, Post-Vertex shader and Viewport is correct). Output.Position and Output.Position2D are identical because i thought that after vertex shader i can't use a Position field in the Pixel Shader.
  2. Hello. There is a shader which implements shadow map technique [code]struct VS_INPUT { float4 Pos : POSITION0; float4 Normal: NORMAL; float4 Color : COLOR; float2 TexCoords : TEXCOORD0; float4 TexWeights : TEXCOORD1; }; float4x4 xLightWorld; float4x4 xLightView; float4x4 xLightProjection; struct SMapVertexToPixel { float4 Position : POSITION0; float4 Position2D : POSITION1; }; SMapVertexToPixel ShadowMapVertexShader(VS_INPUT In) { SMapVertexToPixel Output = (SMapVertexToPixel)0; Output.Position = mul(In.Pos, xLightWorld); Output.Position = mul(Output.Position, xLightView); Output.Position = mul(Output.Position, xLightProjection); Output.Position2D = Output.Position; return Output; } float4 ShadowMapPixelShader(SMapVertexToPixel PSIn) : COLOR { return float4(PSIn.Position2D.z/PSIn.Position2D.w, 0, 0, 1); }[/code] I run this code in PIX in Debugger window and for some pixel i have [code] ShadowMapPixelShader | ( 0.161, 0.000, 0.000, 1.000 ) | float4 [/code] but in Render window all pixels are black. If i change code [code] float4 ShadowMapPixelShader(SMapVertexToPixel PSIn) : COLOR { return float4(0.5f, 0, 0, 1); } [/code] all pixels will be little bit red. Why?
  3. Cannot find texture in my effect file

    [quote name='NightCreature83' timestamp='1329161779' post='4912698'] Have you tried just using the GetSamplerIndex with the constant name? [/quote] thanks a lot. I add this unpleasant code [code] handle = pdxVertexConstants->GetConstantByName(NULL, var_name); if (strcmp(var_name, "xBillboardTexture") == 0) { HRESULT res = localDevice->SetTexture(0, baseTexture); return res; }[/code]
  4. Hello All. I have some problem with my shader. I have function which sets variables in my pixel shader. It works fine for all my shaders, but not for this [code]float4x4 xView; float4x4 xProjection; float4x4 xWorld; float3 xCamPos; float3 xAllowedRotDir; Texture xBillboardTexture : TEXTURE0; sampler textureSamplerTree = sampler_state { texture = <xBillboardTexture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = CLAMP; AddressV = CLAMP; }; struct BBVertexToPixel { float4 Position : POSITION; float2 TexCoord : TEXCOORD0; }; struct BBPixelToFrame { float4 Color : COLOR0; }; BBPixelToFrame BillboardPS(BBVertexToPixel PSIn) { BBPixelToFrame Output = (BBPixelToFrame)0; Output.Color = tex2D(textureSamplerTree, PSIn.TexCoord); return Output; } /*Vertex shader not important*/ BBVertexToPixel CylBillboardVS(float3 inPos: POSITION0, float2 inTexCoord: TEXCOORD0) { BBVertexToPixel Output = (BBVertexToPixel)0; float4 inPosTmp = float4(inPos, 1); float4 center = mul(inPosTmp, xWorld); float3 eyeVector = center.xyz - xCamPos; float3 upVector = xAllowedRotDir; upVector = normalize(upVector); float3 sideVector = cross(eyeVector,upVector); sideVector = normalize(sideVector); float3 finalPosition = center.xyz; finalPosition += (inTexCoord.x-0.5f)*sideVector * 5.0f; finalPosition += (1.5f-inTexCoord.y*1.5f)*upVector * 5.0f; float4 finalPosition4 = float4(finalPosition, 1); float4x4 preViewProjection = mul (xView, xProjection); Output.Position = mul(finalPosition4, preViewProjection); Output.TexCoord = inTexCoord; return Output; }[/code] Now my setter function [code]HRESULT Shader::SetTexture(IDirect3DTexture9 * baseTexture, char * var_name) { D3DXHANDLE handle; handle = pdxVertexConstants->GetConstantByName(NULL, var_name); if (localDevice && pdxPixelConstants && (handle = pdxPixelConstants->GetConstantByName(NULL, var_name))) { DWORD shaderSamplerIndex = pdxPixelConstants->GetSamplerIndex(handle); localDevice->SetTexture(shaderSamplerIndex, baseTexture); return S_OK; } return E_FAIL; }[/code] and always GetConstantByName(NULL, "xBillboardTexture") returns me NULL. I can't understand where is problem.
  5. SetFVF or compiler do this

    Hello. I write this #define FVF_COLOR (D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_NORMAL) SetFVF(FVF_COLOR) but see in PIX this IDirect3DDevice::SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1) Why?
  6. Cannot render scene with scale

    Thanks for the help. Where can I read about why it is multiplied in order world, view, projection?
  7. Cannot render scene with scale

    Thank a lot for answers. I start with small translation and it is works fine.
  8. Hello anybody. My first shader renders a mesh so well in this state void DrawModel (MyMesh Model, LPDIRECT3DTEXTURE9 * meshTextures) { Effect->SetTechnique("Simplest"); D3DXMATRIX mTranslation; D3DXMatrixTranslation(&mTranslation, 0, 0, 0); Effect->SetMatrix("xWorldViewProjection", &(matView * matProj * mTranslation)); UINT Passes; Effect->Begin(&Passes, 0); for (UINT Pass = 0; Pass < Passes; Pass++) { Effect->BeginPass(Pass); for (DWORD i=0; i<Model.numMaterials; i++) { Effect->SetTexture("xTexture", meshTextures[i]); Effect->CommitChanges(); DXOutDevice->SetMaterial(&(Model.meshMaterials[i])); Model.Mesh->DrawSubset(i); } Effect->EndPass(); } Effect->End(); } I see a small model but if i want translate model to (1,1,1) void DrawModel (MyMesh Model, LPDIRECT3DTEXTURE9 * meshTextures) { Effect->SetTechnique("Simplest"); D3DXMATRIX mTranslation; D3DXMatrixTranslation(&mTranslation, 1, 1, 1); Effect->SetMatrix("xWorldViewProjection", &(matView * matProj * mTranslation)); UINT Passes; Effect->Begin(&Passes, 0); for (UINT Pass = 0; Pass < Passes; Pass++) { Effect->BeginPass(Pass); for (DWORD i=0; i<Model.numMaterials; i++) { Effect->SetTexture("xTexture", meshTextures[i]); Effect->CommitChanges(); DXOutDevice->SetMaterial(&(Model.meshMaterials[i])); Model.Mesh->DrawSubset(i); } Effect->EndPass(); } Effect->End(); } I see only black screen What is the problem?