• 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

104 Neutral

About Kurdur

  • Rank
  1. I'm using the NormalMapProcessor from the SpriteEffects sample in my current project. Recently I've been forced to use the "Reach" graphics profile because of end-user limitations. This graphics profile requires that all textures are resized to 'Power of two' or the SamplerState.LinearClamp is used. However, when setting the SamplerState I still get the error that XNA Graphics Profile Reach requires 'power of two'-textures. This error ONLY happens at the exact point where I use the normalmapping from the SpriteEffects sample. How do I fix this??? Code for drawing the textures with normalmapping (the error occurs at spriteBatch_.End()): [CODE] // Draw Gold Chains normalmapEffect.Parameters["LightDirection"].SetValue(lightDirection); // Set the normalmap texture. graphics_.GraphicsDevice.Textures[1] = goldChainTextureNormalMap_; // Begin the sprite batch. spriteBatch_.Begin(0, null, SamplerState.LinearClamp, null, null, normalmapEffect); for (int n = 0; n < goldChains.Length; n++) { if (goldChains[n] != null) { if (goldChains[n].Enabled) goldChains[n].Draw(spriteBatch_, boardPosition, goldChainTexture_); } } spriteBatch_.End(); [/CODE] Code for the NormalMapProcessor: [CODE] #region Using Statements using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content.Pipeline; using Microsoft.Xna.Framework.Content.Pipeline.Graphics; using Microsoft.Xna.Framework.Graphics.PackedVector; #endregion namespace SpriteShaderPipeline { /// <summary> /// Custom content processor converts greyscale displacement bitmaps into /// normalmap format. In the source image, use black for pixels that are /// further away and white for ones that are bumped upward. The output /// texture contains three-component normal vectors. This processor works /// best if the source bitmap is slightly blurred. /// </summary> [ContentProcessor] public class NormalMapProcessor : ContentProcessor<TextureContent, TextureContent> { // Controls how extreme the output normalmap should be. const float bumpSize = 8f; /// <summary> /// Converts a greyscale displacement bitmap into normalmap format. /// </summary> public override TextureContent Process(TextureContent input, ContentProcessorContext context) { // Convert the input bitmap to Vector4 format, for ease of processing. input.ConvertBitmapType(typeof(PixelBitmapContent<Vector4>)); PixelBitmapContent<Vector4> bitmap; bitmap = (PixelBitmapContent<Vector4>)input.Faces[0][0]; // Calculate normalmap vectors. ConvertGreyToAlpha(bitmap); ConvertAlphaToNormals(bitmap); // Convert the result into NormalizedByte4 format. input.ConvertBitmapType(typeof(PixelBitmapContent<NormalizedByte4>)); return input; } /// <summary> /// Copies greyscale color information into the alpha channel. /// </summary> static void ConvertGreyToAlpha(PixelBitmapContent<Vector4> bitmap) { for (int y = 0; y < bitmap.Height; y++) { for (int x = 0; x < bitmap.Width; x++) { Vector4 value = bitmap.GetPixel(x, y); // Copy a greyscale version of the RGB data into the alpha channel. float greyscale = (value.X + value.Y + value.Z) / 3; value.W = greyscale; bitmap.SetPixel(x, y, value); } } } /// <summary> /// Using height data stored in the alpha channel, computes normalmap /// vectors and stores them in the RGB portion of the bitmap. /// </summary> static void ConvertAlphaToNormals(PixelBitmapContent<Vector4> bitmap) { for (int y = 0; y < bitmap.Height; y++) { for (int x = 0; x < bitmap.Width; x++) { // Look up the heights to either side of this pixel. float left = GetHeight(bitmap, x - 1, y); float right = GetHeight(bitmap, x + 1, y); float top = GetHeight(bitmap, x, y - 1); float bottom = GetHeight(bitmap, x, y + 1); // Compute gradient vectors, then cross them to get the normal. Vector3 dx = new Vector3(1, 0, (right - left) * bumpSize); Vector3 dy = new Vector3(0, 1, (bottom - top) * bumpSize); Vector3 normal = Vector3.Cross(dx, dy); normal.Normalize(); // Store the result. float alpha = GetHeight(bitmap, x, y); bitmap.SetPixel(x, y, new Vector4(normal, alpha)); } } } /// <summary> /// Helper for looking up height values from the bitmap alpha channel, /// clamping if the specified position is off the edge of the bitmap. /// </summary> static float GetHeight(PixelBitmapContent<Vector4> bitmap, int x, int y) { if (x < 0) { x = 0; } else if (x >= bitmap.Width) { x = bitmap.Width - 1; } if (y < 0) { y = 0; } else if (y >= bitmap.Height) { y = bitmap.Height - 1; } return bitmap.GetPixel(x, y).W; } } } [/CODE]
  2. Thanks for your ideas! Both solutions seems quite simple. However, I haven't used neither render targets nor created new textures using information from each pixel before. Can any of you help me by writing a small bit of code portraying the idea?
  3. Hi, I have some 2D textures, each of which I would like to cut a part out of using a sourceRect. The program would then rotate that part or flip it horisontally. The end result would be some new 2D textures that I can draw on the screen. Can someone guide me in the right direction? Thanks!