Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm currently totally at a loss as to how this effect is done: http://www.youtube.com/watch?v=zp8MHUNp7Cg

The glowing on the ship and the changing color. I want to do this effect in XNA 4.0 any hints and tips?

share|improve this question

1 Answer 1

up vote 10 down vote accepted

It looks like simple vertex colouring where the colour index is function of the distance to the centre of the ship, plus time.

This can be implemented using a texture storing a palette. It could also be done proceduraly if the desired colour gradients are simple enough.

If using a palette, the vertex shader would be something like this:

uniform float4 in_ShipCenter; /* Centre of the ship */
uniform float in_Time;        /* Elapsed time */
/* ... */

void main(float4 in_Position : POSITION,
          uniform sampler1D in_Palette,
          /* ... */
          out float4 out_Color : COLOR)
{
    /* ... */
    float distance = length((in_Position - in_ShipCenter).xyz);
    float time = in_Time;

    /* Simple distance/time combination */
    vec2 colorIndex = vec2(distance + time, 0.5);

    /* Other possible effects:
     * vec2 colorIndex = vec2(A * distance + B * time, 0.5);
     * vec2 colorIndex = vec2(distance, time);
     * vec2 colorIndex = vec2(distance + A * time, time + B * distance); */

    /* Query the colour in the two-dimensional texture palette. */
    out_Color = tex2D(in_Palette, colorIndex);
}

Edit: account for the fact that XNA doesn't support 1D palettes. If you still want to access the pixels of a 2D palette as if it was a 1D palette, see this question.

share|improve this answer
    
It might also be a Manhattan Distance. –  user712092 Nov 10 '11 at 0:09
1  
The colour waves look very circular to me. A Manhattan distance would create square waves. –  Sam Hocevar Nov 10 '11 at 1:54
    
Problem: you can't use a Texture1D in XNA; but otherwise a very good answer. –  Jonathan Dickinson Dec 1 '11 at 12:47
    
You're right, I wrote my answer thinking GL+GLSL in my head and just assumed it would be the same in XNA... Then in the meantime I learned that tex1D didn't exist on XNA. I'll fix that, thanks! –  Sam Hocevar Dec 1 '11 at 15:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.