Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

184 Neutral

About AussieSpoon

  • Rank
  1. Hello,   I am trying to set up alpha to coverage in DirectX 11. I am currently rendering a particle system using instancing and a geometry shader, so that I pass in a point (1 vert) to render all the particles of that particle system. This is what it looks like:     I'm trying to set up alpha to coverage but I can't seem to do so. I am getting a problem where it renders a black quad at the particle systems position   Here is the Alpha to coverage blend state: D3D11_BLEND_DESC alphaToCoverageDesc = {0}; alphaToCoverageDesc.AlphaToCoverageEnable = true; alphaToCoverageDesc.IndependentBlendEnable = false; alphaToCoverageDesc.RenderTarget[0].BlendEnable = false; alphaToCoverageDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; result = device->CreateBlendState(&alphaToCoverageDesc, &AlphaToCoverageBS); And this is what it looks like:   Even when I try to imitate it within the pixel shader with dithering it produces a similar error:     So I was wondering if it has anything to do with instancing or the geometry shader? I can't imagine it is but I have no idea. Any one think of any reason for this.  If this is too vague just say Thanks 
  2. Oh god, yeah I forgot about that.   Thanks heaps, it's compiling now 
  3. It says:      "C:\Users\Trav\Desktop\2 Person Platformer\DirectX - Sprites\TestShader.fx(12,17): Unrecognized RHS value in assignment: 'WRAP' C:\Users\Trav\Desktop\2 Person Platformer\DirectX - Sprites\TestShader.fx(12,5): ID3DXEffectCompiler: Unexpected error ID3DXEffectCompiler: There was an error initializing the compiler   So I changed "WRAP" in the shader to "LINEAR" to test it, it gives me the same error as above (including "WRAP" even though that doesn't exist in the shader when I ran it/anymore) 
  4. Yeah, g_pTestShader is a NULL pointer.  I think the problem is my file directory ("TestShader.fx"), but I have the shader file in my root directory and in the cpp files location (just in case). But it still doesn't seem to load the file correctly 
  5. Hello,   I am trying to get a shader to give an effect over sprites I draw. Currently I don't have the shader altering the sprites, I'm just trying to test that it works/compiles.    Here is my TestShader.fx:   // World * View * Projection matrix float4x4 g_mWorldViewProjection : WORLDVIEWPROJECTION; float4x4 g_mWorld : WORLD; texture g_SpriteTexture; //What Sprite('s Texture) to use sampler SpriteSampler = sampler_state { Texture = <g_SpriteTexture>; MipFilter = WRAP; MinFilter = WRAP; MagFilter = WRAP; }; float4 PixelShaderFunction(float2 texCoord : TEXCOORD0) : COLOR { //return float4(1, 0, 0, 1); Turn every pixel red float4 color = tex2D(SpriteSampler, texCoord); //color.gb = color.r; //make texture GreyScale return color; } technique DefaultTechnique //Renders The current Sprite as is { pass Pass1 { PixelShader = compile ps_2_0 PixelShaderFunction(); } }    Then I create it like so:   //==== Load in our shader: LPD3DXBUFFER pErrors = NULL; wchar_t *str1 = L"TestShader.fx"; DWORD dwShaderFlags = 0; //Create The First Shader if (FAILED(D3DXCreateEffectFromFile( g_pd3dDevice, str1, NULL, NULL, dwShaderFlags, NULL, &g_pTestShader, &pErrors ) )) { if (pErrors != NULL) { char *errorString = (char*)pErrors->GetBufferPointer(); printf(errorString); MessageBox( NULL, L"Could not Create Test Shader", L"Textures1.exe", MB_OK ); //return E_FAIL; } //return E_FAIL; }       Then I try to set it's Matrix, but it crashes my program. I get an error: Unhandled exception at 0x76fc15de in Sprites.exe: 0xC0000005: Access violation reading location 0x00000000.   g_pTestShader->SetMatrix( "g_mWorldViewProjection", &Cam.GetWorldViewProj());   The above line is the only code that tries to use my shader object and it crashes it.   Any ideas why?   Thanks 
  6. Yeah, I know. It still gives me the error though
  7. The LPD3DXLINE->DrawTransform(); function takes D3DVECTOR3 but the ->Draw(); uses a D3DVECTOR2 so I'm confused what to put here? Because I get the "hast to be a constant value" error if I don't
  8. Hello,   I am using the LPD3DXLINE class. I have 2D sprites being rendered and each sprite has a physics object (4 verlets), I am trying to use the LPD3DXLINE class to Draw lines between each physics verlet/vertex.    But when I pass the physics variables (world space) to the Line-> draw(); function it draws the lines in places I don't want (pixel/screen space, I think)   Here is what I mean:     There should be a red line around each sprite, (the bottom left corner is my world's (0,0)  so when it draws (0,0) it does it from the top left (the screens (0,0)).   So I assume this is a matrix problem? So do I need to give the LPD3DXLINE my view*world*porj matrix?   The LPD3DXLINE->DrawTransform(); function takes D3DVECTOR3 but the ->Draw(); uses a D3DVECTOR2 so I'm confused what to put here?   Or is it somehing else I'm doing wrong?    Here is the code for drawing the lines (if it helps):   LPD3DXLINE myLine = NULL; D3DXCreateLine(g_pd3dDevice, &myLine); myLine->SetWidth(1); //myLine->SetGLLines(TRUE); myLine->Begin(); for (int i = 0; i < PhysicsWorld.GetBodyCount(); i++) { int size = PhysicsWorld.Bodies[i]->VertexCount; //int* array=new int[len]; D3DXVECTOR2* Vetecies = new D3DXVECTOR2[size]; for (int j = 0; j < PhysicsWorld.Bodies[i]->VertexCount; j++) { Vetecies[j].x = PhysicsWorld.Bodies[i]->Vertices[j]->Position.x; Vetecies[j].y = PhysicsWorld.Bodies[i]->Vertices[j]->Position.y; } //myLine->DrawTransform(Vetecies, PhysicsWorld.Bodies[i]->VertexCount, , myLine->Draw( Vetecies, PhysicsWorld.Bodies[i]->VertexCount, D3DCOLOR_ARGB( 255, 255, 0, 0 )); delete Vetecies; Vetecies = NULL; } myLine->End(); myLine->Release();     Thanks 
  9. Thanks for the reply.   Is it possible to do this with specific co-ordinates of a texture? (repeat only 1 specific part of it)   I am using this image:     I am trying to repeat only the pink square and cross part, but when I render I get:       The way I am doing it is by generating the uv co-ordinates as normal and then multiplying appropriate vertices u/v by the number of repeats I want (additional sprites)   //Set Vertex 1 (Bottom Left) ? //Other code omitted pVertex[VertexCounter].u1 = pTexture->GetTextureUMin(); pVertex[VertexCounter].v1 = pTexture->GetTextureVMax(); VertexCounter++; //Set vertex 2 (Top Left) pVertex[VertexCounter].u1 = pTexture->GetTextureUMin(); pVertex[VertexCounter].v1 = pTexture->GetTextureVMin() * pSprite->m_TimesRepeatedY; VertexCounter++; //Set vertex 3 (Top Right) pVertex[VertexCounter].u1 = pTexture->GetTextureUMax() * pSprite->m_TimesRepeatedX; pVertex[VertexCounter].v1 = pTexture->GetTextureVMin() * pSprite->m_TimesRepeatedY; VertexCounter++; //Set vertex 4 (Bottom Right) pVertex[VertexCounter].u1 = pTexture->GetTextureUMax() * pSprite->m_TimesRepeatedX; pVertex[VertexCounter].v1 = pTexture->GetTextureVMax(); VertexCounter++;     Is there any obvious problem with this? Or something else?   Thanks
  10. Hello,   I have a program that creates a sprites using quads in a vertex buffer.    I'm wondering if it is possible to instead of creating multiple quads side by side it is possible to make them 1 quad the re-uses the texture drawn and repeat it multiple times?   e.g. Using the image below I'm trying to achieve b) using the Sprite, instead of  doing a), which uses 4 quads instead of 1          How would I achieve this?   If this is hard to explain without my Texture/sprite code, I can post it if it makes it easier.    Thanks
  11.   Oh man, this was my problem. I was returning the texture as an object, but I have a different function for returning it as a pointer. Since the animation take a pointer I needed to return it as a pointer.   Thanks heaps for pointing that out, you are a legend.  It works fine now. 
  12. Class 1 (.h):   struct DrawArea { float left, right, top, bottom; }; class Texture { public: Texture(void); Texture(IDirect3DTexture9 &_Texture); Texture(IDirect3DTexture9 &_Texture, float _startX, float _startY, float _endX, float _endY); ~Texture(void); IDirect3DTexture9* GetDXTexture() {return m_Texture;} DrawArea GetDrawArea() {return m_DrawArea;} //u = x, v = y co-ordinate float GetTextureUMin(); //the x start (left) float GetTextureUMax(); //the x end (right) float GetTextureVMin(); //the y start (top) float GetTextureVMax(); //the y end (bottom) uINT GetWidth(); //will return the width of the texture at level 0 uINT GetWidth(uINT _level); uINT GetHeight(); //will return the width of the texture at level 0 uINT GetHeight(uINT _level); void SetToTexture(Texture &_texture); void SetToTexture(Texture *_texture); void SetDXTexture(IDirect3DTexture9 &_Texture); void SetDXTexture(IDirect3DTexture9 *_Texture); void SetDXTexture(IDirect3DTexture9 &_Texture, float _startX, float _startY, float _endX, float _endY); void SetDXTexture(IDirect3DTexture9 *_Texture, float _startX, float _startY, float _endX, float _endY); void SetDrawArea(float _startX, float _startY, float _endX, float _endY); private: IDirect3DTexture9* m_Texture;//The DirectX texture DrawArea m_DrawArea; };     Class 2 (.h):   class Animation { public: Animation(void); Animation(Texture* _Texture, float StartX, float StartY, short Rows, short Columns, float FrameWidth, float FrameHeight, short Speed); ~Animation(void); void Update(); private: Texture* m_Texture;//????!?!!? float m_StartX; float m_StartY; short m_Rows; short m_Columns; short m_CurrentFrame; short m_CurrentFrameX; short m_CurrentFrameY; float m_FrameWidth; float m_FrameHeight; short m_Time; //short m_Counter (Might be better to make this global (To only have instance of it instead of 1 per animation) };   Class 2 (.cpp):   Animation::Animation(Texture* _Texture, float StartX, float StartY, short Rows, short Columns, float FrameWidth, float FrameHeight, short Speed) { m_Texture = _Texture; m_StartX = StartX; m_StartY = StartY; m_Rows = Rows; m_Columns = Columns; m_FrameWidth = FrameWidth; m_FrameHeight = FrameHeight; m_Time = Speed; m_CurrentFrame = 0, m_CurrentFrameX = 0, m_CurrentFrameY = 0; }   Creating/using the variables:   Animation *TestAnimation; ............ TestAnimation = new Animation(&TestSprite1->GetTexture(), 0, 0, 4, 1, 64, 64, 1); TestSprite1->SetAnimation(TestAnimation);
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!