• Create Account

### #ActualKoehler

Posted 05 July 2012 - 11:41 PM

This can be accomplished very simply. Just pass in a float uniform (Let's call it "Offset") that you increase by a little bit each frame.

With Multi-Texturing
When you call Tex2D to sample a texture, you pass it a 2D vector of texture coordinates (U,V). All you have to do is add Offset to the U component of your texture coordinates when sampling the specular texture, add that result to the color sampled from your color texture (Without "offset" added to the coordinates), and multiply the sum of those two values by the value sampled from your alpha texture (Again at the original texture coordinates, To keep everything shield-shaped).

Without Multi-Texturing
You could just use one texture, with RGB and alpha of your shield in it (say that one on the left in your Photoshop window). We know that your texture coordinates are probably a value from 0 to 1. This means that multiplying the U value of your texture coordinate by pi, or 3.14, and taking the sine of the resulting value will yield a nice smooth value ranging from 0 to 1 and back to 0 across the middle of the shield.

To make the effect "move" across the shield, we just have to add the offset to the texture coordinate before multiplying by pi. Now the peak of the sine curve "moves". Multiplying this value by a color vector, then by the original texture's alpha, and adding the result to your output color yields the moving glare effect you're looking for.

Since we're only increasing Offset, we should clamp the value of the sine to [0,1] to make sure we don't add corresponding dark spots (since the sine of pi to 2*pi is negative). Finally, we can multiply the resulting value by some scale amount (<1 to make it fall off sharply, > 1 to make it wider).

//Pass in the offset and color you want the "glare" effect to be...
Uniform float Offset;
Uniform float3 GlareRGB;

//pass in a value for how sharply you want the glare to fall off. 2 = twice as fast as a normal sine curve

Uniform float Glare_Sharpness;

//get our color and alpha from the shield texture
float4 color = Tex2D(colorSampler, texCoords.uv);

//Calculate how bright the glare is at this pixel
float glare_amount =(1/Glare_Sharpness)*clamp(sin(3.14*(texCoords.u + Offset)),0.0,1.0);

float4 OUT_COLOR = float4(color.rgb + glare_amount*GlareRGB), color.a);


### #2Koehler

Posted 05 July 2012 - 11:41 PM

This can be accomplished very simply. Just pass in a float uniform (Let's call it "Offset") that you increase by a little bit each frame.

With Multi-Texturing
When you call Tex2D to sample a texture, you pass it a 2D vector of texture coordinates (U,V). All you have to do is add Offset to the U component of your texture coordinates when sampling the specular texture, add that result to the color sampled from your color texture (Without "offset" added to the coordinates), and multiply the sum of those two values by the value sampled from your alpha texture (Again at the original texture coordinates, To keep everything shield-shaped).

Without Multi-Texturing
You could just use one texture, with RGB and alpha of your shield in it (say that one on the left in your Photoshop window). We know that your texture coordinates are probably a value from 0 to 1. This means that multiplying the U value of your texture coordinate by pi, or 3.14, and taking the sine of the resulting value will yield a nice smooth value ranging from 0 to 1 and back to 0 across the middle of the shield.

To make the effect "move" across the shield, we just have to add the offset to the texture coordinate before multiplying by pi. Now the peak of the sine curve "moves". Multiplying this value by a color vector, then by the original texture's alpha, and adding the result to your output color yields the moving glare effect you're looking for.

Since we're only increasing Offset, we should take the absolute value of the sine to make sure we don't add corresponding dark spots (since the sine of pi to 2*pi is negative). Finally, we can multiply the resulting value by some scale amount (<1 to make it fall off sharply, > 1 to make it wider).

//Pass in the offset and color you want the "glare" effect to be...
Uniform float Offset;
Uniform float3 GlareRGB;

//pass in a value for how sharply you want the glare to fall off. 2 = twice as fast as a normal sine curve

Uniform float Glare_Sharpness;

//get our color and alpha from the shield texture
float4 color = Tex2D(colorSampler, texCoords.uv);

//Calculate how bright the glare is at this pixel
float glare_amount =(1/Glare_Sharpness)*clamp(sin(3.14*(texCoords.u + Offset)),0.0,1.0);

float4 OUT_COLOR = float4(color.rgb + glare_amount*GlareRGB), color.a);


### #1Koehler

Posted 05 July 2012 - 11:37 PM

This can be accomplished very simply. Just pass in a float uniform (Let's call it "Offset") that you increase by a little bit each frame.

With Multi-Texturing
When you call Tex2D to sample a texture, you pass it a 2D vector of texture coordinates (U,V). All you have to do is add Offset to the U component of your texture coordinates when sampling the specular texture, add that result to the color sampled from your color texture (Without "offset" added to the coordinates), and multiply the sum of those two values by the value sampled from your alpha texture (Again at the original texture coordinates, To keep everything shield-shaped).

Without Multi-Texturing
You could just use one texture, with RGB and alpha of your shield in it (say that one on the left in your Photoshop window). We know that your texture coordinates are probably a value from 0 to 1. This means that multiplying the U value of your texture coordinate by pi, or 3.14, and taking the sine of the resulting value will yield a nice smooth value ranging from 0 to 1 and back to 0 across the middle of the shield.

To make the effect "move" across the shield, we just have to add the offset to the texture coordinate before multiplying by pi. Now the peak of the sine curve "moves". Multiplying this value by a color vector, then by the original texture's alpha, and adding the result to your output color yields the moving glare effect you're looking for.

Since we're only increasing Offset, we should take the absolute value of the sine to make sure we don't add corresponding dark spots (since the sine of pi to 2*pi is negative). Finally, we can multiply the resulting value by some scale amount (<1 to make it fall off sharply, > 1 to make it wider).

//Pass in the offset and color you want the "glare" effect to be...
Uniform float Offset;
Uniform float3 GlareRGB;

//pass in a value for how sharply you want the glare to fall off. 2 = twice as fast as a normal sine curve

Uniform float Glare_Sharpness;

//get our color and alpha from the shield texture
float4 color = Tex2D(colorSampler, texCoords.uv);

//Calculate how bright the glare is at this pixel
float glare_amount =(1/Glare_Sharpness)*abs(sin(3.14*(texCoords.u + Offset)));

float4 OUT_COLOR = float4(color.rgb + glare_amount*GlareRGB), color.a);


PARTNERS