Jump to content
  • Advertisement

FortisVenaliter

Member
  • Content Count

    27
  • Joined

  • Last visited

Community Reputation

122 Neutral

About FortisVenaliter

  • Rank
    Member
  1. FortisVenaliter

    Plane-Plane Intersection

    Does anyone know of any resources that describe how to programmatically do Plane-Plane intersection to produce a Line result?
  2. FortisVenaliter

    How many HLSL/Cgfx Effects do you use?

    The proper style is to have one technique per fx file. That being said, I usually split it up by the effect produced. Usually I have several techniques, but only because each one is for a different quality level (SM1.1 to SM3.0, etc.). They share a lot of code and produce similar looking effects. But I would not put standard lighting and cel-shading techniques in the same effect file.
  3. FortisVenaliter

    Unit Formations

    Try looking into Flocking Behaviours. It's not exactly formations per-se, but you can get some cool stuff with them
  4. FortisVenaliter

    2D Projection Matrix

    Little bit of voodoo math on top of that and it worked! Thanks, Louis
  5. FortisVenaliter

    2D Projection Matrix

    Okay, here's my C++ code: I have abridged some parts in attempts to simplify it (I don't really create a VB every frame). #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_TEX1) struct Vertex { D3DXVECTOR3 pos; D3DXVECTOR2 tex; }; //int id: the texture ID for info from the texture array LPDIRECT3DVERTEXBUFFER9 lpVertexBuffer=NULL; CSGD_Direct3D::GetInstance()->GetDirect3DDevice()->CreateVertexBuffer( 4*sizeof(Vertex), D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &lpVertexBuffer, NULL ); Vertex quadVertices[] = { { D3DXVECTOR3(0.0f, 1.0f, 0.0f), D3DXVECTOR2(0.0f,1.0f)},//, 1.0f,1.0f,1.0f,1.0f }, { D3DXVECTOR3(1.0f, 1.0f, 0.0f), D3DXVECTOR2(1.0f,1.0f)},//, 1.0f,1.0f,1.0f,1.0f }, { D3DXVECTOR3(0.0f, 0.0f, 0.0f), D3DXVECTOR2(0.0f,0.0f)},//, 1.0f,1.0f,1.0f,1.0f }, { D3DXVECTOR3(1.0f, 0.0f, 0.0f), D3DXVECTOR2(1.0f,0.0f)},//, 1.0f,1.0f,1.0f,1.0f } }; quadVertices[1].pos.x = GetTextureWidth(id); quadVertices[3].pos.x = GetTextureWidth(id); quadVertices[0].pos.y = GetTextureHeight(id); quadVertices[1].pos.y = GetTextureHeight(id); void *pVertices = NULL; lpVertexBuffer->Lock( 0, sizeof(quadVertices), (void**)&pVertices, 0 ); memcpy( pVertices, quadVertices, sizeof(quadVertices) ); lpVertexBuffer->Unlock(); D3DXMATRIX scale; D3DXMATRIX rotation; D3DXMATRIX translate; D3DXMATRIX combined; D3DXMatrixIdentity(&combined); // Scale the sprite D3DXMatrixScaling(&scale, scalex, scaley, 1.0f); combined *= scale; // Rotate sprite by an arbitrary point D3DXMatrixTranslation(&translate, -rotx*scalex, -roty*scaley, 0.0f); combined *= translate; D3DXMatrixRotationZ(&rotation, rot); combined *= rotation; D3DXMatrixTranslation(&translate, rotx*scalex, roty*scaley, 0.0f); combined *= translate; // Translate the sprite D3DXMatrixTranslation(&translate, (float)x, (float)y, 0.0f); combined *= translate; D3DXMATRIX proj; D3DXMatrixOrthoLH(&proj,800.0f,600.0f,1.0f,0.0f); combined *= proj; D3DXMATRIX identity; D3DXMatrixIdentity(&identity); CSGD_Direct3D::GetInstance()->GetDirect3DDevice()->SetTransform(D3DTS_PROJECTION,&identity); CSGD_Direct3D::GetInstance()->GetDirect3DDevice()->SetTransform(D3DTS_VIEW,&identity); CSGD_Direct3D::GetInstance()->GetDirect3DDevice()->SetTransform(D3DTS_WORLD,&identity); int error = 0; // Apply the transform. if(FAILED((CSGD_Direct3D::GetInstance()->GetEffect()->SetMatrix( "wvp", &combined )))) error = 1; if(FAILED(CSGD_Direct3D::GetInstance()->GetEffect()->SetTexture( "tex", m_Textures[id].texture ))) error = 2; CSGD_Direct3D::GetInstance()->GetEffect()->CommitChanges(); // Draw the sprite. if(FAILED(CSGD_Direct3D::GetInstance()->GetDirect3DDevice()->SetStreamSource( 0, lpVertexBuffer, 0, sizeof(Vertex) ))) error = 3; if(FAILED(CSGD_Direct3D::GetInstance()->GetDirect3DDevice()->SetFVF( D3DFVF_CUSTOMVERTEX ))) error = 4; if(FAILED(CSGD_Direct3D::GetInstance()->GetDirect3DDevice()->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ))) error = 5; And the shader code: float4x4 wvp; texture tex : Diffuse; sampler TextureSampler = sampler_state { Texture = (tex); MinFilter = linear; MagFilter = linear; MipFilter = linear; AddressU = mirror; AddressV = mirror; }; struct VertexIn { float3 pos : POSITION; float2 texCoord : TEXCOORD0; }; struct VertexOut { float4 pos : POSITION; float2 texCoord : TEXCOORD0; float4 color : COLOR0; }; struct PixelIn { float2 texCoord : TEXCOORD0; float4 color : COLOR0; }; VertexOut VertexShaderFunction(VertexIn inval) { VertexOut outval = (VertexOut)0; outval.pos = mul(float4((inval.pos).xyz,1),wvp); outval.texCoord = inval.texCoord; outval.color = float4(1.0f,1.0f,1.0f,1.0f); return outval; } float4 PixelShaderFunction(PixelIn inval) : COLOR0 { return tex2D(TextureSampler, inval.texCoord); } technique Lighter { pass pass0 { VertexShader = compile vs_2_0 VertexShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); } }
  6. FortisVenaliter

    2D Projection Matrix

    What would be a standard projection transform matrix for 2D? Right now I am using the DirectX D3DXMatrixOrthoLH and the results are... not favorable. I am trying to convert my code from D3DXSPRITE to shader code. The code looks fine when run with the Sprite, but with the new code it seems to be offset and flipped. At first I thought it was a 0.5 offset, but when I manually tried to fix it, that isn't right. What would be the best view/proj matrix configuration to use?
  7. FortisVenaliter

    D3DERR_INVALIDCALL on SetMatrix

    ... turns out it was an unrelated issue with source control. The variable didn't exist in the shader...
  8. Every three milliseconds? You are aware that at 60 frames per second, there are 16 milliseconds per frame. Can you try to explain what it is you are trying to do?
  9. In this call: error = (CSGD_Direct3D::GetInstance()->GetEffect()->SetMatrix( "world", &combined )); error ends up being D3DERR_INVALIDCALL. The shader has a float4x4 called "world" and combined is a valid D3DXMATRIX. When does this error get returned? How can I fix it? Thanks, Louis
  10. FortisVenaliter

    fxc needs a directx device?

    Fixed it. It seems i needed to set up my paths right in DOS.
  11. When trying to run my shader .fx file through fxc.exe, it returns with this error: Failed to create D3D device Please check your SDK installation. disassembly failed; no disassembly produced Ive got the June 2008 SDK Thanks, Louis
  12. FortisVenaliter

    fxc looking for main()?

    Okay, great, that seemed to fix that problem! Now I have a different one... Failed to create D3D device Please check your SDK installation. disassembly failed; no disassembly produced ??? Louis
  13. FortisVenaliter

    fxc looking for main()?

    When compiling my shader, I get the following error when compiling with fxc.exe: error X3501: 'main': entrypoint not found When even google failed me n this topic, I decided to post here. Anyone know how to fix this? What causes it? int numLights; float lengths[32]; float2 positions[32]; bool perPixelLighting = false; float2 camPos; texture tex : Diffuse < string ResourceName = "rgbcheck.bmp"; >; sampler TextureSampler = sampler_state { Texture = (tex); MinFilter = linear; MagFilter = linear; MipFilter = linear; AddressU = mirror; AddressV = mirror; }; struct VertexIn { float2 pos : POSITION; float2 texCoord : TEXCOORD0; float4 color : COLOR0; }; struct VertexOut { float4 pos : POSITION; float2 texCoord : TEXCOORD0; float2 wPos : TEXCOORD1; float4 color : COLOR0; }; struct PixelIn { float2 texCoord : TEXCOORD0; float2 wPos : TEXCOORD1; float4 color : COLOR0; }; VertexOut VertexShaderFunction(VertexIn inval) { VertexOut outval = (VertexOut)0; outval.wPos = inval.pos; outval.pos = float4((inval.pos-camPos).xy,0,0); outval.texCoord = inval.texCoord; outval.color = inval.color; } float4 PixelShaderFunction(PixelIn inval) : COLOR0 { float4 color = tex2D(TextureSampler, inval.texCoord); float litval = 1; return float4(color.rgb*litval,color.a); } technique Lighter { pass pass0 { VertexShader = compile vs_2_0 VertexShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); } }
  14. FortisVenaliter

    Shaders with C++

    Heh, yea... it appears I was looking at the online docs for DX SDK March '05. Whoops. I have compiled effects using fxc before, so I will look into the functions. Thanks!
  15. FortisVenaliter

    Shaders with C++

    Hmmm... it seems that example is only in C#/VB (who honestly uses VB with DirectX anyway?)
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!