Problem with compile shader from file

Started by
37 comments, last by Asesh 12 years ago

i tried maybe all...rad SDK and i don't know how to chek it sad.png , can you plz tell me where i can see it?

P.S. If you sure where is the problem - can you simply say how to fix it?


You need to double check that you're uploading a proper world/view/projection matrix in your c++ code to your [color="#000000"]worldViewProj that is in your shader.
Advertisement
Yes i found a mistake! Thanks very much for help! happy.png
but how i can give my shader other variables? like this:
float4x4 matWorld;
float4 vec_light;


for worldViewProj i have special function: g_pConstantTableVS->SetMatrix
but have can i set other vectors or matrixes? Or they just need to have same name?
you are free to declare more variables and update those variables from external source
well for example:
float4x4 matWorldViewProj;
float4x4 matWorld;
float4 vecLightDir;

struct VS_OUTPUT
{
float4 Pos : POSITION;
float3 Light : TEXCOORD0;
float3 Norm : TEXCOORD1;
};

VS_OUTPUT VS(float4 Pos : POSITION, float3 Normal : NORMAL)
{
VS_OUTPUT Out = (VS_OUTPUT)0;
Out.Pos = mul(Pos, matWorldViewProj); // transform Position
Out.Light = vecLightDir; // output light vector
Out.Norm = normalize(mul(Normal, matWorld)); // transform Normal and normalize it
return Out;
}

this shader code need texture coordinates, but when i use PIX - i see that all textures positions are 0. I update all variables in render:


for(int b =1;b<MeshCount+1;b++)
{
for( DWORD i = 0; i < g_dwNumMaterials; i++ )
{
g_bUseShaders = true;

if( g_bUseShaders == true )
{
//
// Use vertex and pixel shaders...
//
g_pd3dDevice->SetMaterial( &entity.g_pMeshMaterials );
g_pd3dDevice->SetTexture( 0,entity.g_pMeshTextures[1] );
g_pd3dDevice->SetTexture( 1,entity.g_pMeshTextures[2] );


D3DXVECTOR3 vecLightDir(10,10,10);
D3DXMATRIX matWorldViewProj = matWorld * matView *matProj;
g_pConstantTableVS->SetMatrix( g_pd3dDevice, " matWorldViewProj", &matWorldViewProj );

g_pd3dDevice->SetVertexDeclaration( g_pVertexDeclaration );
g_pd3dDevice->SetVertexShader( g_pVertexShader );


g_pd3dDevice->SetPixelShader( g_pPixelShader );



g_pMesh->DrawSubset( i );
}
i update all, why shader cannot see coordinates?
First off, you aren't uploading your world matrix or your light direction, you're only uploading your matWorldViewProj.

Secondly, does the geometry have UV coordinates?

I think you need to take a step back and review what you have so far, and understand what everything is doing.
I find all information that i need to, now shaders are working good. But there is the last thing that i cannot understand, i don't want start new topic, so : how to add to my mesh more then 1 textures?Mesh have 1 diffuse map, but in shader i need second texture for bump mapping, where can i add it to my mesh? For example in 3dsMax? Or where? Can i load it in code?
Use NVIDIA texture tools: http://developer.nvidia.com/nvidia-texture-tools-adobe-photoshop to generate a normal map of your mesh's texture and modify your shader to add support for normal mapping
I still cannot find working sample of HLSL bump. I found only diffuse lighting...sb know where to find working HLSL effects?
learn to google :P, google direct3d 9 normal mapping

This topic is closed to new replies.

Advertisement