• 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.
Sign in to follow this  
Followers 0
greenpig83

DirectX9 and Pallete swaping ?

3 posts in this topic

I'm making kind of a classic 2d rts game like starcraft, aoe1. cossack...

For team color (1->8). AOE1 use pallete color I think,  they only use 256 pallete bmp color!

 

I know many ppl asked about this. 

After 2 days searching I found only 1 way, is using Pixel Shader and look up table.  Pallete no more usable in today cards and direcx9.

But does Pixel Shader support quite old Computer that do not have hardware graphic card. I want my game to support as much ppl as it can. Because this is just a 2D game. One more problem is that with Pixel shader, you have to set Beginpass, before each sprite batch. If i draw team 1 player unit, then team 2 player unit, then team 1... -> many beginpass will have to draw, and it will kill the performance ! 

 

I tried to generate texture for each team color. But it seem too bad. with only 1 team, the game used 300-400mb texture, ( 1 sprite for attack may use a texture of 3000x200 image size, 1 unit used about 5 sprite, and the game have many units sad.png ). for 8 player, it will kill any high end comp. That's absurd.

 

Using maskColor in gSprite->draw   ( Then use a color sprite of gray color to draw over the real sprite ). Can help me a lot, but it's quite limited. Make the color look weird.  This is the method I'm using in the game now.

 

I'm running out of ideas. Can you give me a better Idea. I think this is a very simple thing, and games decades ago can solve it very well. I wish I can touch the genie engine or dmcr :(

 

I'm thinking of 2 direction :

  Use pixel shader : but make sure it call less BeginPass ass possible, Because my units are draw in order of relative depth. Cant draw blue units, then red units, then...

  Generated Units color, so must optimize the texture resource management...

Edited by greenpig83
0

Share this post


Link to post
Share on other sites

You may limit yourself to something like Shader Model 2 or 3 (which are supported by the D3D9) level, and practically all usable hardware should support them. Even Shader Model 2 should give you enough of freedom. 

 

I don't think that there is a reason to use palette anymore. For the different unit coloring, you could make your sprite sets with white color and then have a gray scale mask texture to indicate the parts which needs coloring. You may pass the unit color in the instancing parameters for example. In the pixel shader then for each texel calculate the modulated color (ie. texture color modulated with the unit color) and then use the gray scale mask to lerp between the original color and the modulated color.

 

For sprite ordering, I think that you may use z-buffering for it or just putting the sprites in the buffer in correct order. For z-buffering you could have a instancing parameter and use it as a depth in the vertex shader output.

 

This way, you may draw all the sprites using the same sprite sheet with one draw call.

 

Cheers!

0

Share this post


Link to post
Share on other sites

But does Pixel Shader support quite old Computer that do not have hardware graphic card. I want my game to support as much ppl as it can.

 

Shader Model 2.0 is all that's required for this kind of lookup, and that's available on everything, including the likes of the Intel GMA900 - here's a review from 2004: http://www.anandtech.com/show/1413 - I think you don't need to be concerned about older hardware here.

0

Share this post


Link to post
Share on other sites

Thanks for comments. I think I will spend more time for the pixel shader techniques. 

I've already found this thread http://www.gamedev.net/topic/485555-lookup-table-using-pixel-shader/

 

The HLSL lang is strange, and I quite dont understand someplace. 

Do I have to use a Vertex Shader before the Pixel Shader. Because I'm doing a 2D game, I dont use any worldview matrix thing in the game... Just want to change the pixel color... And in my code, when I dont set the texture in the Sampler, the pixel shader still take effect. 

 

 

struct VS_OUTPUT
{
    float4 hposition : POSITION;
float2 texture0  : TEXCOORD0;
    //float4 color : COLOR0;
};

 

PS_OUTPUT myps( VS_OUTPUT IN )
{
    PS_OUTPUT OUT;
OUT.color = tex2D( Sampler, IN.texture0 );
//OUT.color = float4( 0.0, 0.0, 1.0, 1.0);
    return OUT;
}
 
In the code above. I dont know what the texture in the Sampler do. Event if i dont set it, or set to other texture. OUT.color still return the Input texture color.

 

However after some experiment. I found out that when I want to change state in the pixel Shader (use setInt, setTexture..., to tell the shader to choose other look up table, for other units). I must set it outside of the gsprite->begin / end. So there noway to change it one sprite by one. I'm drawing alot of sprites between 1 begin/end pair for performance.

 

As for the z-buffer Idea, now I'm sorting it myself and draw units in order, set z=0. If i use the directx to sort, i will have to set each unit a z value. it maybe 0.1, 0.2 ...

Because I'm doing a 2d Game, do you think it will make the sprites distort ?, it get zoomed or look weird ?

Edited by greenpig83
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0