• 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

How do you match a colour in HLSL

3 posts in this topic

Hi all.

What I'm doing is creating a selected object display. This is when a user selects a game object and a window has its detail and a image,
That may show its health status.

I'm working on the image part.
Each object has a .DDS icon image with alpha channel and its a image of the object rendered as a wire frame
the inner parts are coloured black, This is the colour I would Like to over ride.
I tryed three ways the last one works the best but it adds a line at the top and bottom.

I'm thinking its from the top and bottom of the image.




here is my HLSL pixel shader snippit of code
//any other ways I should try.

float4 texColor = gTex.Sample( TexS, input.tex0 );
float4 diffuse = Mdiffuse * texColor;
// Kill transparent pixels.
clip(diffuse.a - 0.15f);
// Interpolated normals can become unnormal--so normalize.
input.normalW = normalize(input.normalW);
input.toEyeW  = normalize(input.toEyeW);
// Light vector is opposite the direction of the light.
float3 lightVecW = gLight.dir;
//shadow stuff
float shadowFactor = 0.0;
float3 removethiscolour = float3(0.0, .0, 0.0);//this will be user set later

//if the colour is black then we want to change that colour
//to our new colour

//try 1
//float val = diffuse.r + diffuse.g + diffuse.b;
	//if(val <= 0.55)
		//diffuse = float4(0.0, 1.0, 0.0, 1.0);
 //try 2
//find the colour to over write
	//if(diffuse.r == removethiscolour.r && diffuse.g == removethiscolour.g && diffuse.b == removethiscolour.b )
	//	diffuse = float4(0.25, 0.25, 0.105, 1.0);

//this one I like more
//this here has a nice look to it
float v1 = diffuse.r - removethiscolour.r;
float v2 = diffuse.g - removethiscolour.g;
float v3 = diffuse.b - removethiscolour.b;
float delta = 0.5;
if(v1 <= delta && v2 <= delta & v3 <= delta)
          diffuse = float4(1.0, 0.0, 0.0, 1.0);

 float4 spec    = Mspec;
 // Compute the lit color for this pixel.
 SurfaceInfo v = {input.posW, input.normalW, diffuse, spec};
 float3 litColor = ParallelLight(v, gLight, gEyePosW, shadowFactor);

 return float4(litColor * gSelectedColour, gAlpha);


Share this post

Link to post
Share on other sites

Just a quick question : how your sampler TexS is defined? Have you tried using point sampling?




Share this post

Link to post
Share on other sites

Good point.

Totally sliped my mind to change the sampler hehe.


But I still getting the line but is smaller in length, going to look at it in pix see whats going on there.




and using MIN_MAG_MIP_POINT now.



SamplerState TexS



AddressU = Wrap;

AddressV = Wrap;



Heres a Image with three ways of displaying the objects health

A is just replacing the the colour with the health colour.

B is the image with the health colour added to it.

C is change one colour with the Health colour.


I like B. then again C is looking ok. What do you all think..


Edited by ankhd

Share this post

Link to post
Share on other sites

Ok I know what does it.


It's the Texture Address Mode


I have it set to wrap and it produces the lines all ways at the edge.


I change the Address mode to Clamp and the lines are gone fixed I think.


And after all that I think I don't like what the look of the health image looks like.  may do a icon of the obejct and the health colour over the top with no wire frame.

Edited by ankhd

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