• Content count

  • Joined

  • Last visited

Community Reputation

114 Neutral

About JezzaP

  • Rank
  1. Week Of Awesome IV - The Competition Thread

    First blog post:
  2. does anyone have a local copy of this sample? I really would like to see it but the link is dead.
  3. check if released

    Thanks, I never of the existence of such classes. That's a real help.
  4. Is there a way in DirectX to check if a resource has already been released? If you try to release something twice, it will give Access Violations. Say I have a texture, which two pointers point to. I can release from one and nullify the pointer, but without checking if that is nullified I shan't know whether to attempt to release the other. If I wanted the pointers to be independent then I have a problem.
  5. texture coordinates mess up

    Can anyone see the problem in this code? Or want to see more? EDIT: How strange. I upgraded to the latest dx version (March, I was using November 08) and it works. I also changed all the shaders to model 2 instead of 3. One of those made it work. Ah well. [Edited by - JezzaP on May 29, 2009 8:22:02 AM]
  6. texture coordinates mess up

    Ok here is my vertex shader: vertexOutput std_VS(appdata IN) { vertexOutput OUT = (vertexOutput)0; OUT.WorldNormal = normalize(mul(IN.Normal,WorldITXf).xyz); if(useNorm){ OUT.WorldTangent = normalize(mul(IN.Tangent,WorldITXf).xyz); OUT.WorldBinormal = normalize(mul(IN.Binormal,WorldITXf).xyz); } float4 Po = float4(,1); float3 Pw = mul(Po,WorldXf).xyz; if(1==lightType){ OUT.LightVec = lightDir - Pw; }else OUT.LightVec = lightDir; if(flipy){ if(flipx) OUT.UV = float2((1.0-IN.UV.x),(1.0-IN.UV.y)); else OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); } else{ if(flipx) OUT.UV = float2((1.0-IN.UV.x),IN.UV.y); else OUT.UV = float2(IN.UV.x,IN.UV.y); } OUT.WorldView = normalize(ViewIXf[3].xyz - Pw); OUT.HPosition = mul(Po,WvpXf); return OUT; } Where the matrices are: float4x4 WorldITXf : WorldInverseTranspose; float4x4 WvpXf : WorldViewProjection; float4x4 WorldXf : World; float4x4 Projection : Projection; float4x4 ViewIXf : ViewInverse; float4x4 WorldIXf : WorldInverse; structs: /* data from application vertex buffer */ struct appdata { float3 Position : POSITION; float4 UV : TEXCOORD0; float4 Normal : NORMAL; float4 Tangent : TANGENT; float4 Binormal : BINORMAL; }; /* data passed from vertex shader to pixel shader */ struct vertexOutput { float4 HPosition : POSITION; float2 UV : TEXCOORD0; float3 WorldNormal : TEXCOORD2; float3 WorldTangent : TEXCOORD3; float3 WorldBinormal : TEXCOORD4; float3 WorldView : TEXCOORD1; float3 LightVec : TEXCOORD5; float3 Attenuation : TEXCOORD6; }; The samplers all look like this: sampler ColorSampler = sampler_state { texture = <ColorTexture> ; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = WRAP; AddressV = WRAP; AddressW = WRAP; }; The matrices are set like this: sys->Device->GetTransform(D3DTS_VIEW, &matView); sys->Device->GetTransform(D3DTS_PROJECTION, &matProjection); D3DXMatrixInverse(&matInverseView, NULL, &matView); matWorld = new D3DXMATRIX[numObjects]; matWorldViewProjection = new D3DXMATRIX[numObjects]; matWorldView = new D3DXMATRIX[numObjects]; matWorldInverseTransponse = new D3DXMATRIX[numObjects]; matWorldInverse = new D3DXMATRIX[numObjects]; phong.Shader->SetMatrix("ViewIXf", &matInverseView); for(int i2=0; i2<numObjects; i2++){ matWorld[i2]=objects[i2].pose; D3DXMatrixMultiply(&matWorldView[i2], &matWorld[i2], &matView); D3DXMatrixMultiply(&matWorldViewProjection[i2], &matWorldView[i2], &matProjection); D3DXMatrixInverse(&matWorldInverse[i2], NULL, &matWorld[i2]); D3DXMatrixTranspose(&matWorldInverseTransponse[i2], &matWorldInverse[i2]); } objects are then rendered like this: for(int i2=0; i2<numObjects; i2++){ //set variables for shader phong.Shader->SetMatrix("WorldXf", &matWorld[i2]); phong.Shader->SetMatrix("WorldITXf", &matWorldInverseTransponse[i2]); phong.Shader->SetMatrix("WvpXf", &matWorldViewProjection[i2]); for(DWORD i = 0; i < objects[i2].numMaterials; i++) { if(objects[i2].diffuse[i]!=NULL) phong.Shader->SetTexture("ColorTexture", objects[i2].diffuse[i]); if(objects[i2].specular[i]!=NULL) phong.Shader->SetTexture("SpecTexture", objects[i2].specular[i]); if(objects[i2].normal[i]!=NULL) phong.Shader->SetTexture("NormTexture", objects[i2].normal[i]); phong.Shader->CommitChanges(); objects[i2].DXObject->DrawSubset(i); } } The projection matrix is set with this: void PD_RENDERER::SetFOV(float FOV){ D3DXMATRIX matProjection; D3DXMatrixPerspectiveFovLH(&matProjection, pdDegree2Rad(FOV), (FLOAT)ScreenWidth / (FLOAT)ScreenHeight, 0.1f, 500.0f ); matProjection(2,2) = 1.0f; matProjection(3,2) = -1.0f; sys->Device->SetTransform(D3DTS_PROJECTION, &matProjection); } where float FOV defaults to 45 (which is what I use) [Edited by - JezzaP on May 29, 2009 1:06:18 AM]
  7. Hello. First post. I am writing a game engine in DX 9. I have had, for a long time, a strange problem where texture coordinates mess up when the camera gets close and views from an angle. The engine currently uses an effect file to render, but I am fairly sure the problem also existed before this, when I was using the fixed function pipeline. The problem exists not only when using textures, the lighting (such as which areas are lit the most by a point light) also messes up in the same way, even when textures are not used at all. The image on the left shows how it is meant to be, the right is what happens when one moves the camera close to the object. The object shown is a box generate by DirectX, but the problem also occurs when using meshes loaded in. I read somewhere this might have something to do with perspective correction. Thank you in advance for any suggestions. EDIT: does bbcode not work here? Anyway, direct link to image: