• 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.


  • Content count

  • Joined

  • Last visited

Community Reputation

376 Neutral

About LevyDee

  • Rank

Personal Information

  • Location
    Washington State
  1. Real programmers use FORTRAN, and If you can't do it in FORTRAN, do it in assembly.  If you can't do it in assembly, it isn't worth doing
  2. As stated in the topic, I have a use case where this would be nice, but is it actually possible? If you declare an interface in libraryOne and define an identical interface signature in libraryTwo, can  the two libraries use each other through an application without the two libraries having knowledge of each other?
  3. Theoretically: if you were to open an image file via an I/O object and write its bytes out in plain text and then create an IDirect3DTexture9 object(using a compatible format), then lock the surface to receive a D3DLOCKED_RECT object, could you then simply write the original source image bytes directly to the pBits pointer and result in a functioning IDirect3DTexture9 object(representing the original image)?   The question: AKA is the pBits member of D3DLOCKED_RECT a direct and exact representation of raw image pixel data(from .jpg, .png, ect...), or is their a liaison process that occurs, altering the data, when the d3d device creates the texture from a file?   Thank you
  4. Thank you so much for both of your input, that was indeed the problem.
  5. My issue is explained in the attached images. I am attempting to texture splat by adjusting alpha values on seperate layers. The problem is when the alpha map runs through the shader multiple times, it affects previous alpha adjustments adversly. The shader is very simple and is as follows: void psPPAlphaPaint(float2 iUV : TEXCOORD0, out float4 color : COLOR0) {     color = tex2D(AlphaMap, iUV);         float2 distance = float2(0.0f, 0.0f);     distance.x = uCoordinate - iUV.x;     distance.y = vCoordinate - iUV.y;         float dist = sqrt(pow(uCoordinate - iUV.x, 2) + pow(vCoordinate - iUV.y, 2));     if(dist < 0.05)     {         color.a = 1.0;     } } Older alpha adjustments begin to blur and adust their position in the texture.   Any thoughts or clarifying questions?   Thank you   Edit: I am running the shader using a full screen quad to make adjustments to the alpha map as a render target
  6. Well after running the program through pix and looking at the mip chain, both of you are correct. Thank you for the help.
  7. Hello,   So I am having a little trouble alpha blending two ground textures in order to "paint" alpha values in my homegrown engine level editor. I am using hlsl and direct3d9. The problem is that the alpha values seem to be taking BUT are only visible when the camera is very close to the texture in game. I have included two pictures that show the issue.   This is my pertinent hlsl code //LWSurface layers int layers; texture layerOne; texture layerTwo; sampler LayerOneTexture = sampler_state {     Texture = <layerOne>;     MipFilter = LINEAR;     MinFilter = LINEAR;     MagFilter = LINEAR; }; sampler LayerTwoTexture = sampler_state {     Texture = <layerTwo>;     MipFilter = LINEAR;     MinFilter = LINEAR;     MagFilter = LINEAR; }; void psLWSurface(float4 iNorm : TEXCOORD0,                  float2 iUV : TEXCOORD1,                  float2 iDepth : TEXCOORD2,                  out float4 mapColor : COLOR0,                  out float4 mapNorm : COLOR1,                  out float4 mapDepth : COLOR2,                  out float4 mapIdentity: COLOR3) {         float4 layerOne = tex2D(LayerOneTexture, iUV);     if(layers == 1)     {         mapColor = layerOne;     }     else if(layers == 2)     {                 //Sample second layer         float4 layerTwo = tex2D(LayerTwoTexture, iUV);         //Alpha blend the two layers         float4 blendResult;         blendResult.a = layerTwo.a + (1.0f - layerTwo.a) * layerOne.a;         blendResult.rgb = (1.0f / blendResult.a) * (layerTwo.a * layerTwo.rgb + (1.0f - layerTwo.a) * layerOne.a * layerOne.rgb);             mapColor = blendResult;     }     //Normal map     //Transform to range [0, 1] due to X8R8G8B8 texture format. Only holds unsigned data.     mapNorm.xyz = 0.5f * (normalize(iNorm) + 1.0f);     mapNorm.w = 1.0f;     //Depth map     mapDepth.xyz = (iDepth.x / iDepth.y);     mapDepth.w = 1.0f;     mapIdentity.xyzw = dsObjectIdentity; } technique LWSurface {     pass p0     {         VertexShader = compile vs_3_0 vsFill();         PixelShader = compile ps_3_0 psLWSurface();     } } And in the engine I have hardcoded a test value for the alpha of the second texture just until I can get this probem solved D3DLOCKED_RECT textureData;             _layers[layer].layer->LockRect(0, &textureData, 0, 0);             unsigned* bytePointer = (unsigned*)textureData.pBits;             for (int y = 0; y < desc.Height; y++)             {                 for (int x = 0; x < desc.Width; x++)                 {                     //Alpha channel                     ((byte*)&bytePointer[x])[3] = 50;                 }                 // 32bpp == 4 bytes and pitch may not be == width * 4                 bytePointer += textureData.Pitch >> 2;             }             _layers[layer].layer->UnlockRect(0); The textures are Dynamic and 32byte A8R8G8B8.   Thank you for taking the time.      
  8. The attached image helps to describe my problem.   Given a direction vector(V1), location to avoid along with the radius, and a destination point, how could I calculate the blue travel path?   I know that given the angle in radians of a circle you can find the vector location at that angle on the circle, but I am not sure how I would implement this equation to solve this.   Thank you
  9. I am looking to make the scene flat for editing maps in my engine. I am assuming it would have something to do with my projection matrix. I am looking for the effect that most editors use including Blender, Unreal sdk, hammer editor ect... Any tips?   Thanks
  10. First I want to apologize, I have been pretty active with questions the past few days so I hope nobody is getting annoyed with me!   The concept is as follows   Two identical textures loaded from the same resource. Texture 1 used in the pixel shader, Texture 2 the device render target. Pixel shader manipulates texture 1 to render results to texture 2 via full screen quad. After draw calls, copy texture 2's surface back into texture 1's surface.   That is what I am attempting to accomplish, but alas am failing. I have been working on this all day and it is getting pretty frustrating. Can anyone give any advice or knit pick my code?   Thank you   Create textures and full screen quad            //Create texture for display             if(D3DXCreateTextureFromFileEx(                                 device,                                 texturePath.c_str(),                                 D3DX_DEFAULT,                                 D3DX_DEFAULT,                                 D3DX_DEFAULT,                                 D3DUSAGE_RENDERTARGET,                                 D3DFMT_A8R8G8B8,                                 D3DPOOL_DEFAULT,                                 D3DX_DEFAULT,                                 D3DX_DEFAULT,                                 0,                                 0,                                 0,                                 &texture1) != D3D_OK)             {                 ErrorMessenger::ReportMessage("Failed to create texture!", __FILE__, __LINE__);             }             //Create texture for applying shader effect             if(D3DXCreateTextureFromFileEx(                                 device,                                 texturePath.c_str(),                                 D3DX_DEFAULT,                                 D3DX_DEFAULT,                                 D3DX_DEFAULT,                                 D3DUSAGE_RENDERTARGET,                                 D3DFMT_A8R8G8B8,                                 D3DPOOL_DEFAULT,                                 D3DX_DEFAULT,                                 D3DX_DEFAULT,                                 0,                                 0,                                 0,                                 &texture2) != D3D_OK)             {                 ErrorMessenger::ReportMessage("Failed to create texture!", __FILE__, __LINE__);             }             //Create full screen quad             if(device->CreateVertexBuffer(6 * sizeof(LWVERTEX),                                       0,                                       0,                                       D3DPOOL_DEFAULT,                                       &fullScreenQuad,                                       0) != D3D_OK)                 ErrorMessenger::ReportMessage("Failed to create vertex buffer!", __FILE__, __LINE__);             LWVERTEX* fsQuad = new LWVERTEX[6];             fsQuad[0].position = D3DXVECTOR3(-1.0f, 1.0f, 0.0f);             fsQuad[1].position = D3DXVECTOR3(-1.0f, -1.0f, 0.0f);             fsQuad[2].position = D3DXVECTOR3(1.0f, -1.0f, 0.0f);             fsQuad[3].position = D3DXVECTOR3(-1.0f, 1.0f, 0.0f);             fsQuad[4].position = D3DXVECTOR3(1.0f, 1.0f, 0.0f);             fsQuad[5].position = D3DXVECTOR3(1.0f, -1.0f, 0.0f);                          void* bufferData;             fullScreenQuad->Lock(0, 0, &bufferData, 0);             memcpy(bufferData, fsQuad, sizeof(LWVERTEX) * 6);             fullScreenQuad->Unlock(); Here is the draw function             //Set effect variables             if(effect->SetTexture("scene", texture1) != D3D_OK)                 ErrorMessenger::ReportMessage("Failed to set texture", __FILE__, __LINE__);             //Back up old render target             IDirect3DSurface9* oldRT;             if(device->GetRenderTarget(0, &oldRT) != D3D_OK)                 ErrorMessenger::ReportMessage("Failed to GetRenderTarget", __FILE__, __LINE__);             //Set texture2 as new render target             IDirect3DSurface9* newRT;             texture2->GetSurfaceLevel(0, &newRT);             if(device->SetRenderTarget(0, newRT) != D3D_OK)                 ErrorMessenger::ReportMessage("Failed to SetRenderTarget", __FILE__, __LINE__);              //Draw             device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);             device->BeginScene();                 UINT numPass;                 effect->Begin(&numPass, 0);                     effect->BeginPass(0);                     if(device->SetStreamSource(0, fullScreenQuad, 0, sizeof(LWVERTEX)) != D3D_OK)                         ErrorMessenger::ReportMessage("Failed to set stream source!", __FILE__, __LINE__);                     if(device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2) != D3D_OK)                                                     ErrorMessenger::ReportMessage("Failed to draw primitave!", __FILE__, __LINE__);                     effect->EndPass();                 effect->End();             device->EndScene();             device->SetRenderTarget(0, oldRT);             //Copy results from texture2 back into texture 1             IDirect3DSurface9* destSurf;             texture1->GetSurfaceLevel(0, &destSurf);             if(D3DXLoadSurfaceFromSurface(destSurf, nullptr, nullptr, newRT, nullptr, nullptr, 0, 0) != D3D_OK)             {                 ErrorMessenger::ReportMessage("Failed to LoadSurfaceFromSurface", __FILE__, __LINE__);             }
  11. Ah, roger that. Thats what I get for copying my lock from a different function I wrote(meant to read, not write...) Thank you for the help. That seemed to do the trick.
  12. Thank you for the response. This seems to change the correct value, but the change is not reflecting in my rendering. Is their anything that would prevent my change from taking effect?   The purpose of this is I am building an editor for my engine. I want to have multiple layers for terrain painting. So you have the base layer, and then you can have layers on top of that. Each extra layer can be "painted" by lowering the alpha channel of which ever layer you like. So what I m trying to do is manually edit the alpha channel only at certain indices of the surface data(due to mouse dragging). I have manually set up a test case where I just lower the alpha to 50 percent ala 255 / 2 but it has zero effect. If I set the alpha channel to 0.5f in my shader before the alpha blending occurs, it works as expected. Will locking the surface of the texture and setting the alpha channel there not effect my alpha channel I receive in my shader? that seems to be the case right now.   Using your example this is what my test function looks like. It is simply supposed to adjust every texels alpha channel to 0.5f in my shader.   Shader(tested and verified to work) //Alpha blend float4 blendResult; blendResult.a = layerTwo.a + (1.0f - layerTwo.a) * layerOne.a; blendResult.rgb = (1.0f / blendResult.a) * (layerTwo.a * layerTwo.rgb + (1.0f - layerTwo.a) * layerOne.a * layerOne.rgb);          color = blendResult;   Alpha function IDirect3DSurface9* surf;             _layers[1].texture->GetSurfaceLevel(0, &surf);             //Get surface description             D3DSURFACE_DESC desc;             surf->GetDesc(&desc);             //Lock surface data             D3DLOCKED_RECT surfaceData;             surf->LockRect(&surfaceData, 0, D3DLOCK_READONLY);                 //Make pointer to directly edit surface data             BYTE* bytePointer = (BYTE*)surfaceData.pBits;             for (int y = 0; y < desc.Height; y++)             {                 for (int x = 0; x < desc.Width; x++)                 {                     //Alpha channel                     ((byte *) &bytePointer[x])[3] = 255 / 2;                 }                 // 32bpp == 4 bytes and pitch may not be == width * 4                 bytePointer += surfaceData.Pitch >> 2;             }             //Unlock             surf->UnlockRect();
  13. I am looking for a way to manually adjust the alpha channel of an A8R8G8B8 formatted texture. I create the texture as managed in order to lock the surface and get the pBits describing the surface data. So how would you loop through the entire surface and only change the alpha channel of each pixel?   I know you can do something like this   BYTE* bytePointer = (BYTE*)surfaceData.pBits;   for(int i = 0; i < surfaceData.pitch * textureHeight; i++) {     bytePointer[i] = //some value } This will loop through every bit, but how do I figure which channel of the pixel I am on so I can update only the alpha channel of an A8R8G8B8 texture?   Thank you.
  14. Thank you lwm. That is exactly what I needed.