Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

145 Neutral

About fervent

  • Rank
  1. fervent

    [MDX] Creating a ramp texture

    Great, thank you! Works like a charm!! -David
  2. Hi, I'm trying to convert the following code from C++ to C#. The code generates a ramp texture for use in cel shading from an array of char values. // Here is the cel shade texture we will apply to the object unsigned char diffuseRange[16] = {127, 127, 127, 160, 160, 160, 160, 160, 255, 255, 255, 255, 255, 255, 255, 255}; // Texture LPDIRECT3DTEXTURE9 diffuseTex = NULL; // Surface rectangle D3DLOCKED_RECT dataRect; // Create the ramp textures. if(D3D_Device->CreateTexture(16, 1, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &diffuseTex, 0) != D3D_OK) return false; memset(&dataRect, 0, sizeof(D3DLOCKED_RECT)); diffuseTex->LockRect(0, &dataRect, NULL, 0); unsigned char *dataPtr = (unsigned char*)dataRect.pBits; for(int i = 0; i < 16; i++) { dataPtr[i * 4 + 0] = diffuseRange; dataPtr[i * 4 + 1] = diffuseRange; dataPtr[i * 4 + 2] = diffuseRange; dataPtr[i * 4 + 3] = diffuseRange; } diffuseTex->UnlockRect(0); I've converted the code to c# in the following way. It compiles, but it's not doing the same thing as the code above. Looks like I need to use texture.LockRectangle in c#, but I'm not exactly sure how to manipulate the GraphicsStream like they're doing iwth the dataPtr. Any help would be appreciated. int[] d = new int[16] { 127, 127, 127, 160, 160, 160, 160, 160, 255, 255, 255, 255, 255, 255, 255, 255 }; Bitmap b = new Bitmap(16, 1); // height, width for (int i=0; i<16; i++) b.SetPixel(i, 0, Color.FromArgb(d, d, d, d); Texture diffuseTex = new Texture(device, 16, 1, 1, Usage.None, Format.A8R8G8B8, Pool.Managed);
  3. Hi, I'm trying to export a textured model from 3dsmax with panda exporter (.x file). The produced model loads fine, but the UV coordinates seem to be completely off (i.e., the texture is not applied in the right position on the model). Is there something I'm missing? (some setting or something with Panda)? Thanks, David
  4. I'm trying to determine perf bottlenecks in my app. Are there any free perf profilers that work well with managed directx?
  5. Hi, I'm writing a D3D game in MDX. I added post-processing shader effects last night, and now my device.Dispose() is taking up to 4 seconds... I'm using a bunch of surfaces for post processing, but should it really take that long just to dispose all that? Anyone had a similar perf problem and want to share their solution? :) Thanks, David
  6. Hi, I'm trying to add motion blur to my game (DX9) and I'm looking for a good tutorial or some sample code. I found the one from 2003 in the DX SDK. It's not that great to be honest, so I'm looking for others. +10 Bonus if the tutorial or sample code is MDX. Thanks, David
  7. There seem to be 20-30 plugins, and I'm trying to find "the best". Any recommendations? Thanks, David
  8. I might be crazy, but what's the name of the tool? Also, I wrote my own utility since yesterday using functions like mesh.Optimize, Mesh.Simplify, and Mesh.Clean, and finally mesh.Save (where I can specify the file format). The utility works exactly to spec for .x files outputted by Caligari Gamespace. But with .x files from Blender, I am not seeing any sort of optimization. For example, the furthest I can get mesh.Simplify to work on a blender .x file is a 1-2% decrease in vertices, whereas with a .x file from Gamespace, I can scale the number of vertices in the mesh down to 1% or less... What's going on with the blender outputted .x files? Why isn't DirectX loading the mesh (using Mesh.FromFile) in such a way that it's file format independent? There must be something wrong with blender's output format such that DirectX, after loading the mesh into memory, thinks theres no way it can be optimized. Any help would be appreciated.
  9. Thanks guys. Does anyone know of a free utility for .x mesh files for optimizing, cleaning, and resaving in binary format? The DX Mesh class makes these things fairly straight forward, but I'd rather use someone else's free utility than be forced to write my own :)
  10. Hi, I have a friend making .x models in belnder. Problem is, it's exporting them as 3-4mb .x files, and they aren't that complex. Is there a program I can run to clean these up and make them much smaller? Thanks, David
  11. I'm reading varying stories for what the difference is. Thanks.
  12. Sweet! Would you mind posting a few relevant parts of the MDX source code? Specifically, the syntax for rendering to a texture. Are you using multiple surfaces or the StretchRect method? -Dave
  13. Those are neat, but the most important part of the effect is the artist pipeline, where the artist can specify the glow amount through the alpha channel of the texture. The examples above don't implement the glow in quite the same way.
  14. Hi Guys, I posted and found a description of the Tron 2.0-style glow effect: In fact, the Nvidia SDK has a glow sample, implementing this technique in DirectX: Problem is, they are using compiled shaders and have a horrible implementation for code that's targeted for developers trying to learn (and especially developers trying to convert c++ to managed directx). Anyone know of any other implementations of this technique that are maybe easier to understand/break-down/reuse? Bonus points for MDX version (but I know I'm pushing my luck). Thanks, David
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!