• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Warwick Michael Dumas

Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

120 Neutral

About Warwick Michael Dumas

  • Rank
    Newbie

Personal Information

  1. Sure here are the arguments HRESULT surfacegraph::Initialise(int nperRow, // data points per row if square grid data to be supplied int left, int top, int width, int height, float fscale, D3DXVECTOR3 in_Eye, bool Polar = 0, int number_in_outermost = 0, // data points in outermost circle if radially distributed data int number_circles = 0, // number of circles if radially distributed data float radius_outermost = 0.0f // max radius if radially distributed data )      The viewport coordinates are left,top,width,height. (And it's not radially distributed data). The calls to Initialise are in the top code box above. So yes, they are a bit overlapping. I think that should be OK though... the rendering of each object is meant to be independent.  
  2. Hi. N00b here. I wrote a class to create a graph of a surface and this class includes a shadow map. With one object it works fine. With multiple objects, strange things are happening. See picture - for all six objects the same calls are made, only the viewport coordinates are different. Only one of them displays the shadow correctly. The rendering sequence of the objects makes a difference to the behaviour, so it seems to me it is a problem with the way the shadow maps get initialised.   For the attached picture, this was the way the objects were treated:   surfacegraph Graph3, Graph4, Graph2, Graph5, Graph6,Graph; ..... Graph.Initialise(perRow,0,0,600,520,nscale,Eye); Graph2.Initialise(perRow,0,525,600,520,nscale,Eye); Graph3.Initialise(perRow,580,0,480,520,nscale,Eye); Graph4.Initialise(perRow,580,525,480,520,nscale,Eye); Graph5.Initialise(perRow,1050,0,600,520,nscale,Eye); Graph6.Initialise(perRow,1050,525,600,520,nscale,Eye); ..... Graph2.Render(); // the rendering sequence appears to make a big difference Graph4.Render(); // to the shadow maps that result Graph6.Render(); Graph.Render(); Graph3.Render(); Graph5.Render();     This creates the picture where Graph2 displays correctly, Graph displays with no shadow and all the rest display completely in shadow.   However I don't see why the objects are affecting each others' shadow maps.   This is some of the class definition:   class surfacegraph { public: static const int SHADOWMAPRESOLUTION = 4096; int perRow; int texWidth,texHeight; int numVertices, numTriangles; IDirect3DVertexBuffer9* TerrainVertexBuffer; IDirect3DIndexBuffer9* TerrainIndexBuffer; IDirect3DTexture9* texture_grid; D3DVIEWPORT9 vp; D3DVIEWPORT9 shadow_vp; ID3DXEffect* mFX; D3DXMATRIXA16 matView; D3DXMATRIXA16 matProj; DirLight mLight; Mtrl mWhiteMtrl; D3DXVECTOR3 Eye; // eye position // for shadow map: IDirect3DSurface9* pSurface; // never gets used for anything though - not sure why this was here D3DXMATRIX mLightVP; DrawableTex2D* mShadowMap; D3DXHANDLE mhTech; D3DXHANDLE mhWVP; D3DXHANDLE mhTex; D3DXHANDLE mhEyePos; // for specular D3DXHANDLE mhDiffuseMtrl; D3DXHANDLE mhAmbientMtrl; D3DXHANDLE mhLightVector; D3DXHANDLE mhLightDiffuseColour; D3DXHANDLE mhLightAmbientColour; D3DXHANDLE mhLightSpecularColour; D3DXHANDLE mhSpecularMtrl; D3DXHANDLE mhSpecularPower; D3DXHANDLE mhBuildShadowMapTech; D3DXHANDLE mhLightWVP; D3DXHANDLE mhShadowMap; D3DXHANDLE mhSwitch; float xyscale,nscale; surfacegraph(); HRESULT Initialise( parameters ); ... HRESULT SetxzDataAutomatic (float minimum, float maximum, float in_xyscale); HRESULT SetDataFromDoubleScaled(double **, double); HRESULT SetDataAgain(float **); HRESULT SetColourData(float **, float **, float **); VOID surfacegraph::Render(void); ~surfacegraph(); };   The following is the start of the Render method for the class. See code comments.   VOID surfacegraph::Render() { .... // DRAW SHADOW MAP: Direct3D.pd3dDevice->SetViewport(&vp); // without this^^^, 5 graphs, all except the last rendered, appear as small shadows on white mShadowMap->beginScene(); //Direct3D.pd3dDevice->SetViewport(&shadow_vp); // completely whites out all but last-to-render graph. No idea why. // That may suggest that Device->Clear is affecting the back buffer but we also know it is affecting the shadow map! Direct3D.pd3dDevice->Clear( 0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 255, 255, 255 ), 1.0f, 0 ); // this clearly does affect shadow map successfully... // 0x00000000, 1.0f, 0 ); // because this^^^^^ leads to everything being in shadow DXChk(mFX->SetTechnique(mhBuildShadowMapTech)); UINT numPasses = 0; DXChk(mFX->Begin(&numPasses, 0)); DXChk(mFX->SetMatrix(mhLightWVP, &(mLightVP))); DXChk(mFX->CommitChanges()); Direct3D.pd3dDevice->SetStreamSource(0, TerrainVertexBuffer, 0, sizeof(VertexPNT)); Direct3D.pd3dDevice->SetIndices(TerrainIndexBuffer); Direct3D.pd3dDevice->SetVertexDeclaration(VertexPNT::Decl); for (UINT ii = 0; ii < numPasses; ++ii) { mFX->BeginPass(ii); Direct3D.pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, numVertices, 0, numTriangles); mFX->EndPass(); }; DXChk(mFX->End()); mShadowMap->endScene(); // axis drawing in fixed function pipeline: Direct3D.pd3dDevice->SetViewport(&vp); ...   In case it is necessary background information, the "DrawableTex2D" class is    class DrawableTex2D { public: IDirect3DTexture9* mTex; ID3DXRenderToSurface* mRTS; IDirect3DSurface9* mTopSurf; UINT mWidth; UINT mHeight; UINT mMipLevels; D3DFORMAT mTexFormat; bool mUseDepthBuffer; D3DFORMAT mDepthFormat; D3DVIEWPORT9 mViewPort; bool mAutoGenMips; DrawableTex2D(UINT width, UINT height, UINT mipLevels, D3DFORMAT texFormat, bool useDepthBuffer, D3DFORMAT depthFormat, D3DVIEWPORT9& viewport, bool autoGenMips); ~DrawableTex2D(); IDirect3DTexture9* d3dTex(); void beginScene(); void endScene(); void onLostDevice(); void onResetDevice(); DrawableTex2D(const DrawableTex2D& rhs); DrawableTex2D& operator=(const DrawableTex2D& rhs); }; IDirect3DTexture9* DrawableTex2D::d3dTex() { return mTex; } void DrawableTex2D::onResetDevice() { UINT usage = D3DUSAGE_RENDERTARGET; if(mAutoGenMips) usage |= D3DUSAGE_AUTOGENMIPMAP; DXChk(D3DXCreateTexture(Direct3D.pd3dDevice, mWidth, mHeight, mMipLevels, usage, mTexFormat, D3DPOOL_DEFAULT, &mTex)); DXChk(D3DXCreateRenderToSurface(Direct3D.pd3dDevice, mWidth, mHeight, mTexFormat, mUseDepthBuffer, mDepthFormat, &mRTS)); DXChk(mTex->GetSurfaceLevel(0, &mTopSurf)); } void DrawableTex2D::beginScene() { mRTS->BeginScene(mTopSurf, &mViewPort); } void DrawableTex2D::endScene() { mRTS->EndScene(D3DX_FILTER_NONE); }   The following method is called, once only, after the graph object has been declared.   HRESULT surfacegraph::Initialise( parameters ) { ... shadow_vp.X = 0; shadow_vp.Y = 0; shadow_vp.Width = SHADOWMAPRESOLUTION; shadow_vp.Height = SHADOWMAPRESOLUTION; shadow_vp.MinZ = 0.0f; shadow_vp.MaxZ = 1.0f; mShadowMap = new DrawableTex2D(SHADOWMAPRESOLUTION, SHADOWMAPRESOLUTION, 1, D3DFMT_R32F, true, D3DFMT_D24X8, shadow_vp, false); vp.X = left; vp.Y = top; vp.Width = width; vp.Height = height; vp.MinZ = 0.0f; vp.MaxZ = 0.0f; float GlobalAspectRatio = ((float)vp.Width)/(float)vp.Height; // Create the FX from a .fx file. ID3DXBuffer* errors = 0; D3DXCreateEffectFromFile(Direct3D.pd3dDevice, "test1.fx", 0, 0, D3DXSHADER_DEBUG, 0, &mFX, &errors); if( errors ) MessageBox(0, (char*)errors->GetBufferPointer(), 0, 0); // Obtain handles. mhTech = mFX->GetTechniqueByName("WarwickTech"); ........ mShadowMap->onResetDevice(); static D3DXVECTOR3 vLookatPt( 0.0f, 1.2f, 0.0f ); static D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f ); Eye = in_Eye; D3DXMatrixLookAtLH( &matView, &Eye, &vLookatPt, &vUpVec ); D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI / 4.0f, GlobalAspectRatio, 1.0f, 12.0f); mLight.dirW = D3DXVECTOR3(-1.0f, -0.5f, 0.5f);// remember y is height D3DXVec3Normalize(&mLight.dirW, &mLight.dirW); mLight.ambient = D3DXCOLOR(0.4f, 0.4f, 0.4f, 1.0f); mLight.diffuse = D3DXCOLOR(0.6f, 0.6f, 0.6f, 1.0f); mLight.spec = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f); mWhiteMtrl.ambient = WHITE*1.0f; mWhiteMtrl.diffuse = WHITE*1.0f; mWhiteMtrl.spec = WHITE*1.0f; mWhiteMtrl.specPower = 8.0f; // Shadow mapping: D3DXMATRIX lightView; D3DXVECTOR3 lightPosW(20.0f, 10.0f, -10.0f); D3DXVECTOR3 lightTargetW(0.0f, 0.0f, 0.0f); D3DXVECTOR3 lightUpW(0.0f, 1.0f, 0.0f); D3DXMatrixLookAtLH(&lightView, &lightPosW, &lightTargetW, &lightUpW); D3DXMATRIX lightLens; float lightFOV = D3DX_PI*0.25f; D3DXMatrixPerspectiveFovLH(&lightLens, lightFOV, 1.0f, 1.0f, 100.0f); mLightVP = lightView*lightLens; // graph data: perRow = nperRow; numVertices = perRow*perRow; numTriangles = 2*(perRow-1)*(perRow-1); texWidth = perRow; texHeight = perRow; definedindices = 0; if ( DXChk( Direct3D.pd3dDevice->CreateVertexBuffer(numVertices*sizeof(VertexPNT),D3DUSAGE_WRITEONLY,0,D3DPOOL_MANAGED,&TerrainVertexBuffer,0),1) + DXChk( Direct3D.pd3dDevice->CreateIndexBuffer(numTriangles*3*sizeof(DWORD),D3DUSAGE_WRITEONLY, D3DFMT_INDEX32, D3DPOOL_MANAGED,&TerrainIndexBuffer,0),2) + DXChk( D3DXCreateTexture( Direct3D.pd3dDevice, texWidth,texHeight, 0,0,D3DFMT_X8R8G8B8,D3DPOOL_MANAGED, &texture_grid),3) ) return E_FAIL; D3DSURFACE_DESC textureDesc; texture_grid->GetLevelDesc(0, &textureDesc); if ( textureDesc.Format != D3DFMT_X8R8G8B8 ) return E_FAIL; return S_OK; }   Sorry to provide so much code, I'm not all that sure what is going on here. I have tried tinkering with what happens at the start of the Render method but I don't seem to know what I'm doing, the results (as described in the code comments) are hard for me to interpret.   Grateful for any suggestions.   I am happy to dropbox the whole source if anyone wishes to tinker with it.
  3. D24S8 did it. Awesomeness. The near value is 1.0f whereas my camera is at e.g. (3.5,5,-6) and the corner of the graph is at (3,,-3). I may well end up entering a formula for the near clipping frame value, because I might yet mess around with the camera position. But with 24-bit z buffer it does work fine anyway. Cheers, Warwick This work helps to bring about focus fusion as a viable energy source. www.focusfusion.org
  4. OK it definitely is z-fighting because I try SetRenderState( D3DRS_ZFUNC, D3DCMP_LESS ) and different bits go wrong. I made another improvement by moving the far clipping frame from 5000.0f to 12.0f -- thanks for that. It's still not perfect. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] I tried to force a 32 bit depth buffer ... d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D32; ... but CreateDevice then failed. But maybe this is likely to work if I just make it run fullscreen? I'd rather run windowed if I can do, but if needs must. "1. render far outer surface .. 2 render far inner surface ... 3 render near inner surface ... 4 render near outer surface" In general the data is not as simple as here, so I can't predict what areas have a particular depth. "* if you are using a 16 bit depth texture, increase it to 32 or 64 bit depth." It's 32-bit R8G8B8X8. I don't understand why the texture would make a difference though? "* increase the thickness to reduce z-fighting" I can't do it. Seems quite strange that it insists on 16bit although the z coordinates of vertices are float ? I'm sure if I could get it to just stick to 32 bit instead of casting to 16 when it projects, it would be fine. And that seems like it must be the key to it, I don't think 65536 depth values is going to be enough. What happens if I set d3dpp.EnableAutoDepthStencil = FALSE; --I have to manage my own z-buffering? It sounds like too much of a challenge? [img]http://public.gamedev.net//public/style_emoticons/default/blink.png[/img]
  5. Thank you both. I had it set to not culling. If I set pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW); then nothing happens, the mesh is not rendered If I set pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); then it's a significant improvement: https://dl.dropbox.com/u/6773194/testPOLARagain670_CULLCCW.zip I will look into the z-fighting and probably post again...
  6. Hi. I mentioned before my unconventional decision to use DX9 as a rendering platform. I've now all but completed this project but something does not look quite right. I'm drawing a dish which is yellow on the inside with purple outside it; the back of the dish shows a purple stripe, which it should not. I tried it with two different sorts of meshes. One of them is with points arranged in concentric circles and an algorithm that basically sweeps anticlockwise over points on the previous (inner) circle to create triangles for each point on each circle. The other is square mesh with two triangles per square. I always use this square mesh to define the texture dynamically, and it is defined in such a way that radially equal points always get the same colour. I calculate vertex normals in the main program and light the vertices in a vertex shader. I also do shadow mapping in the pixel shader but I'm pretty sure that's nothing to do with the problem. Here are some of my output avi files 'radial' mesh: [url="https://dl.dropbox.com/u/6773194/testPOLARagain670.zip"]https://dl.dropbox.c...LARagain670.zip[/url] 'square' mesh: [url="https://dl.dropbox.com/u/6773194/testSQUARE_800totalperRow.zip"]https://dl.dropbox.c...totalperRow.zip[/url] Those are both so high resolution that it's likely 1 triangle per pixel or more. That may have something to do with the problem although I don't see why it should do. It probably is best to focus attention on the cutaway animation - the lower one - but see also on the upper one, it can be seen that going upwards, the stripes form a sinusoidal pattern. Here is a somewhat lower resolution mesh. There is some mistexturing probably because the wall of the dish is very thin. 'radial' mesh. [url="https://dl.dropbox.com/u/6773194/testPOLARagain50.zip"]https://dl.dropbox.c...OLARagain50.zip[/url] I tried to upload all the code, because I don't know which bit is relevant, but it says 'You aren't permitted to upload this kind of file'. Don't know why text files cause such umbrage but there you go. Anyway maybe looking at this, someone will have some suggestion of what could be going wrong. I've checked that the computed normals all have the same sign for the y-component, and tried inverting them. And I'm certain the texture doesn't have a bizarre purple region. I also can't believe it's meant to look this way with the lighting. I'm at my wits' end, any suggestions appreciated. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
  7. Thank you v much for responses. I now established that the error was in the eye of the beholder - the two things aren't meant to touch, they are at different y-coordinates. The axes are in the right place. My first query and it was unintentionally a windup. Now I just have to work out how to make text appear at device coordinates instead of screen coordinates.
  8. [font=verdana,geneva,sans-serif]Hi, first time I have posted here. I am more-or-less a novice with DirectX. I am working on a graphical output for my scientific simulation. The reason I chose DX over ray-tracing is partly that I already started learning DX, and partly just that I am not actually looking for realistic graphics - e.g. I want to light things arbitrarily with silly ambient lighting inside a deep dark well, but enough about that.[/font] [font=verdana,geneva,sans-serif][i]The problem I am having is the following.[/i][/font] [font=verdana,geneva,sans-serif]I make my surface graph using a shader which is pretty simple and based on the book by Frank Luna.[/font] [font=verdana,geneva,sans-serif]I am feeding a vertex buffer which (I have checked with watches) has x,z coordinates that populate a square (-3,3)x(-3,3).[/font] [font=verdana,geneva,sans-serif]That appeared to work.[/font] [font=verdana,geneva,sans-serif]Then I am also trying to draw axes, in the fixed function pipeline, by using DrawPrimitiveUP. At the moment I am trying to draw one line with D3DPT_LINESTRIP and passing data (-3.02,0,3.02),(-3.02,0,-3.02).[/font] [font=verdana,geneva,sans-serif]The line appears, but well away from the edge of the graph! If I instead set (-2.4,0,2.4),(-2.4,0,-2.4) then it appears still a bit outside the graph square.[/font] [font=verdana,geneva,sans-serif](Meanwhile, if I draw line (3,0,3),(3,10,3) then it looks like it appears in the correct place, though I'm still checking that further.)[/font] [font=verdana,geneva,sans-serif]I have checked, checked, checked that the view*projection matrix being used in SetTransform is the same as is passed to the shader, and the shader does not do anything funny.[/font] [font=verdana,geneva,sans-serif]Any ideas what could be going on I would welcome. Quite happy to provide more information if there's anything you'd like to ask. [/font]