d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Hlsl Shader Question > Fog Of War
Add Reply New Topic New Poll
Member
Posts: 21,861
Joined: Dec 13 2010
Gold: 0.91
Jun 28 2015 01:58pm
Hello Guys,

I've posted this here because there is no Real subforum regarded to Graphic-programming.
Probably I got luck and someone is around with some knowledge about HLSL Shaders.

First of all:

At the moment I have to work on a 3d Game with XNA + c#
I have implement a Fog of War.
I got all the Logic regarded to the Fog of war, it also works well, I'm only missing the visual effect of it, and I'm too newbish in writing shaders to achieve it

what I actually wanna do:
1. put a second Fog Of War-Map over my current map and make it transparent, so you can see the Game-map. --> this is no problem.
2. Write a HLSL Shader which will set the Transparency to 100% in a circular Area around Objects under Player-control. that shall be the "reveal" effect.

post your ideas/suggestions about this topic, also about achieving a fog of war effect in general

kind regards,
Bree
Member
Posts: 21,861
Joined: Dec 13 2010
Gold: 0.91
Jun 28 2015 02:37pm
I have found out how to Burn a badass hole in my Fog of war texture:

Code
float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
{
float dx = coords.x - 0.0f;
float dy = coords.y - 0.0f;
if (dx * dx + dy * dy <= 0.02f){
float4 color = float4(1.0f, 0.0f, 0.0f, 0.0f);
return color;
}
else{
float4 color = float4(0.0f, 0.0f, 0.0f, 0.5f);
return color;
}
}


Now I need to find out how I can pass the Shader at which positions he shall do this.
and how I calculate 3D Worldpositions to texturecoordinates
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll