Problem building a color grading map

I am trying to build a default color grading map into a 1024×32 RenderTarget. Here is my shader code: VertexShaderOutput VertexShaderFunction(VertexShaderInput input) { VertexShaderOutput output; output.Position = float4(input.Position,1); output.TexCoord = input.TexCoord; return output; } float4 PixelShaderFunction(float2 TexCoord : TEXCOORD0) : COLOR0 { float temp = TexCoord.r*1024; float4 result = (float4)0; result.a = 1; result.r = … Read more

Best way to blend colors in tile lighting? (XNA)

I have made a color, decent, recursive, fast tile lighting system in my game. It does everything I need except one thing: different colors are not blended at all: Here is my color blend code: return (new Color( (byte)MathHelper.Clamp(color.R / factor, 0, 255), (byte)MathHelper.Clamp(color.G / factor, 0, 255), (byte)MathHelper.Clamp(color.B / factor, 0, 255))); As you … Read more

The meaning of colours in other cultures

According to http://www.color-wheel-pro.com/color-meaning.html and many other western websites certain colours have meanings. To summarise the meaning of colours in the context of a typical RTS game: red = danger or enemy gold = wealth or high quality yellow = energy green = healing aqua = protection blue = power pink = romance white/grey = neutral … Read more

cost of texture change vs color change

How would I go about determining the difference in cost between changing the render color of an object every frame vice changing the texture (same sheet, just changing the source rectangle) every frame? I ask because right now i’m changing the alpha every frame on about 300-400 objects, and i’m wondering if it isn’t cheaper … Read more

Is this converting from or to premultiplied alpha?

I found this code buried under some rocks: var divAlpha = 0xff00/color.A; var r = (byte) (color.R*divAlpha >> 8); var g = (byte) (color.G*divAlpha >> 8); var b = (byte) (color.B*divAlpha >> 8); The fields on color are bytes, of course. My guess would be it’s avoiding using floating point operations to handle premultiplied alpha, … Read more