Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

382 Neutral

About PumpkinPieman

  • Rank
  1. PumpkinPieman

    Simple RTS unit AI.

    I've been putting off working on this because I can't seem to find a clean solution for it. I've made a simple AI that moves around on command, attacks enemies with whatever weapons it has, but I'm stumped as to how to write a pursue state without duplicating code from both the walk and attack states. Doing single states that handle their own thing is fine, but when trying to combine them in different ways makes me wonder how I'm going to go about implementing them. For example, say you order units to move to a specific location but along the way the units encounter an enemy. You'd want them to take a few shots at them before continuing on, without pursuing them. The problem is with the states changing so often it's hard to keep the orders between the different states. The only other thing I can think of is that the global state handles orders, and tells the secondary state to work on those orders. But even that is kind of messy. Has anyone worked on something similar?
  2. PumpkinPieman

    Issue passing a texture to shader.

    Awesome. You've been a great help to me. Rate++; One more question that is off topic. Is there a way to directly call Load functions on resources that get called through the pipeline? There are a few things that I don't like about using the Content manager and I'd like to develop a class that doesn't just extend the functionality of the class but gives some new methods for content management.
  3. PumpkinPieman

    Issue passing a texture to shader.

    Wow, awesome. Thanks for the info. It's good to know. Now here is my question. Some of the textures I use, I don't want a texture chain... On the XBOX I want to reduce as much memory as possible and some of these mipmaps really aren't needed. Is there any way to not have these?
  4. PumpkinPieman

    Issue passing a texture to shader.

    F*@k. I figured out this issue. Now I need a way around it... The issue is exactly this. DirectX doesn't support reading textures larger then the rendertarget. Seeing as my rendertargets are 128x128, and my texture is 256x256 that would make sense. However. I can import a brush in to by other pixel shader through constants and it draws fine. The real reason why this works? Well, I loaded this through the Content manager. I don't know how this really changes anything... but it seems this only works if the resource is < rendertarget size || created by the Content manager. I tried setting the rendertarget to the backbuffer, but this didn't help. Which made me think that I am setting the texture parameters incorrect. My brush is larger then the surface so it can't be a size restriction so it must be a texture creation issue. Any ideas? EDIT: TextureUseage.AutoGemerateMipMap works. Why wouldn't TexureUseage.None work in this situation?
  5. PumpkinPieman

    Issue passing a texture to shader.

    To answer your question XNA did place this texture in the Managed pool.
  6. PumpkinPieman

    Issue passing a texture to shader.

    In PIX when you take a frame capture does this capture the frame from the begining of when the backbuffer is drawn to when it is flipped?
  7. PumpkinPieman

    Issue passing a texture to shader.

    I can check that in D3D, but how would I do something like that in XNA? PIX isn't really the most readable output...
  8. PumpkinPieman

    Issue passing a texture to shader.

    Listen, I know this is not much. But this shouldn't happen. I've tried two different methods. I've tried creating this texture and I've tried using an existing rendertarget and drawing something on it through a pixel shader. Both methods seem to yield no results... Now, here is the thing that really drives me mad. If I load a texture I've created outside of runtime it works fine. Without Terrain Generation: (Red: 1, Blue: 0, Green: 0, Height: ~0) Terrain With Generation: (Red: 0, Blue: 0, Green: 0, Height: 0) <- this should have a red layer of noise. // note this uses the noise texture which I have checked that was created perfectly......... Terrain with Generation: (Red: tex.r, Blue: tex.b, Green: tex.g, Height: tex.a) // note this uses a texture of the same size that I pass using the same parameter as the noise, no other code has been changed What the heck is going wrong with this application? It can't be the shader, it draws the parameter fine. It can't be the shader object because it passes the texture fine. And it can't be the texture because I've read back the data. It's set perfectly, and even uses base 2. Please, anything will help... EDIT: Quote:Original post by MJP Does everything still work correctly if you have your pixel shader sample from TextureSampler? What happens if you send your noise texture as the parameter for SpriteBatch.Draw and sample from TextureSampler, does it still show up? This will verify that you're filling up your noise texture with correct values. You could also verify by running your app in PIX, finding your texture, and viewing it. If you've made sure your noise texture is coming out directly, you'll want to do some further debugging. Run your app with the debug runtimes active, and make sure you're not getting any errors. Then after that I would have a look at the native D3D9 calls that are happening behind the scene. Find the call to IDirect3DDevice9::SetTexture that's setting your noise texture to the device. Then look through the calls leading up to the actual DrawPrimitive call, and make sure your Effect is being applied properly and that the SpriteBatch is messing up anything for you. Thanks for your response. Yes, it does work fine. However, what I'm planning on attempting is not just simple terrain generation. I also want to have the ability to generate noise on the terrain by a factor of x. Which would give me the ability to create rippes in the terrain. As for the second part. I've been trying to use PIX to debug it, but it has been no help. The first thing I would have suspected is as you say. However, I'm able to pass a texture loaded by the content manager in. Which boggles my mind...
  9. I tried posting this on the XNA community forums but I got no such luck, just questions as to what I'm attempting. Now, my problem here is that I'm creating a texture, filling it full of noise. Then passing it to the shader as a parameter, however the shader won't sample the texture and return anything but black. I know the texture has been set correctly, I've read back the data and it's the same I put in it. But that doesn't explain why when I pass it the shader acts as if it wasn't set and just returns nothing... private void UpdateSurfaceNoiseGPU(GameTime gameTime) { if (generateList.Count > 0 == false) return; // device GraphicsDevice device = game.GraphicsDevice; Vector2 viewportSize = new Vector2(blockWidth, blockHeight); // noise info Vector4 noiseInfo = generateList[0]; int noiseWidth = (int)noiseInfo.X; int noiseHeight = (int)noiseInfo.Y; Texture2D noiseTexture = new Texture2D(device, noiseWidth, noiseHeight, 0, TextureUsage.None, SurfaceFormat.Color); Color[] noiseData = new Color[noiseWidth * noiseHeight]; for(int x = 0; x < noiseWidth; x++) { for(int y = 0; y < noiseHeight; y++) { noiseData[x + y * noiseWidth] = new Color( (byte)(Util.ImageProcessing.PerlinNoise.Noise2D(x, y) * 255), 0, 0, 0 ); } } noiseTexture.SetData<Color>(noiseData); // setup shader constants shaderGenerate.Parameters["ViewportSize"].SetValue(viewportSize); shaderGenerate.Parameters["Noise"].SetValue(noiseTexture); // draw on to surface for (UInt32 x = 0; x < mapBlockWidthNum; x++) { for (UInt32 y = 0; y < mapBlockHeightNum; y++) { TerrainBlock block = mapBlocks[x, y]; // set the render target, draw and swap device.SetRenderTarget(0, mapSwapBlock); batch.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.None); shaderGenerate.Begin(); shaderGenerate.CurrentTechnique.Passes[0].Begin(); batch.Draw(block.SurfaceTexture, Vector2.Zero, Color.White); shaderGenerate.CurrentTechnique.Passes[0].End(); shaderGenerate.End(); batch.End(); device.SetRenderTarget(0, null); FlipBlockBackBuffer(block); } } generateList.Clear(); noiseTexture.Dispose(); device.SetRenderTarget(0, null); } The problem exists here: shaderGenerate.Parameters["Noise"].SetValue(noiseTexture); The shader I'm using is a modified version of the SpriteBatch shader, which works in my other process for terrain painting but not this. // SpriteBatch default variables texture Noise; sampler NoiseSampler = sampler_state { Texture = <Noise>; MipFilter = Linear; MinFilter = Linear; MagFilter = Linear; AddressU = Clamp; AddressV = Clamp; }; // spritebatch vertex code... void SpritePixelShader(inout float4 color : COLOR0, float2 texCoord : TEXCOORD0) { float4 surface = tex2D(TextureSampler, texCoord); float4 noise = tex2D(NoiseSampler, texCoord); color = noise; } Now, I must be doing something completely wrong. Because my other method works and is similar, I can even pass in textures to the shader. I'm not sure where to approach this because this texture needs to be a shader parameter and not passed in with the Draw call..
  10. PumpkinPieman

    How do I make my own game?

    Seeing as you know nothing about programming you might want to start on something that has memory management. Try C# and use Visual Studio with the XNA addon. You should be able to download the express version of C#, and grab the XNA installer at [creators.xna.com]. There is also a selection of tutorials there that can get you on your feet. I'm not saying this is a sure way of getting what you want done, but it sets up quick and lets you do simple things very easily.
  11. PumpkinPieman

    Image Compression Libs in C#?

    Quote:Original post by Codeka Quote:Original post by PumpkinPieman That's one of the issues. I'd work with the BMP format, but I'm trying to compress mighty big textures. 8000x8000 at max. Can you even generate an 8000x8000 image on an XBOX? By my calculations, that would require 244MB of memory and the XBOX only has 512MB of memory which is shared between the CPU and GPU. It's going to be a bit of a tight squeeze when you've got the .NET CF running, the XBOX OS itself and your game. In any case, does it need to be an image file that you save? Could you save a .bmp and then use SharpZipLib to create a .zip file? I mean, there's not much point viewing an 8000x8000 image on your TV so you could save the "raw" 8000x8000 in a zip and a "preview" at a lower resolution for actually viewing by the XBOX (if that's the point anyway). Also, SharpZipLib could be a starting point for implementing managed .png compression, since the algorithm .png uses is supported by SharpZipLib. Yeah, it cannot support textures of that size. However the terrain I'm generating doesn't use the whole texture. It's broken up in to 128x128 segments, and a static vertex buffer for shader height \ splatter manipulations. This is why if I get straight data from from the library, I don't have to worry about the texture2d throwing an exception for exceeding the limit. Yeah, I've seen Sharp zLib. I've just tested the SevenZip lib for C#, and it was quite slow. I'm going to give this a shot and see what comes out of it.
  12. PumpkinPieman

    Image Compression Libs in C#?

    That's one of the issues. I'd work with the BMP format, but I'm trying to compress mighty big textures. 8000x8000 at max.
  13. PumpkinPieman

    Image Compression Libs in C#?

    That's usually the first thing that is mentioned. I can use this on the PC version, but "apparently" those two methods don't exist on the xbox versions. So I was kind of looking for something outside of the standard API and XNA. Other people suggested I write my own compression library, as if I have nothing better to do or something. Hah.
  14. Hey, I'm looking for an image compression library that is done in C#. I posted this over at the XNA board, but I had no luck there. What I'm trying to find is some kind of library that will allow me to bypass the content pipeline and compress images. For the application I'm using I need to write textures, which is something that doesn't seem like its supported on the XBOX unless I do it this way. I figured the people over at GD might know of a few libraries that can aid me. (no real preference at this point. I wish there was a libpng for C#)
  15. The project of mine has been evolving ever so slightly, but I've run in to a couple of blocks and I need ideas for good design decisions. Everything works right now, but it makes what I've done more complex at times. Save data vs Game data \ Saving and loading ---------------------- Currently I'm using my XML save structures as structures to store information about campaigns and levels (not necessarily raw data). Right now I pass the save data to individual components such as the terrain, so that it can manage loading it's content. But I'm confused as to who should do the saving and who should do the loading. Should those internal classes not only handle loading their own content but saving it as well? My issue is that the data structures aren't specifically designed for one class or another. Or is it better if each class "fills in" the fields that it needs? Paths ----------------------- Right now I don't have any method to handle paths. What is the better design? Hardcoded path strings that all states and objects can access, or an xml structure outside of the game that allows me to modify the path? Messages \ Textboxes and resource strings ----------------------------------------- Right now each state has it's own resource strings hardcoded. So an individual menu would keep the strings it needs to create things like dialog boxes and text entry fields. (using wrappers around the guide classes) Is it better to keep a big block of resource strings and functions to load predefined templates for message boxes? Here's an example of what I'm working on. I uploaded the video to facebook, but you're going to need an account to see it. http://www.facebook.com/video/video.php?v=39318187377 Thanks
  • 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!