Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 26 May 2011
Offline Last Active Aug 19 2012 05:35 PM

Topics I've Started

How do the maps work in Civilization?

27 June 2011 - 08:08 AM

In Civilization V there are no "sides" to the map (except for the top and bottom of course), so if you keep moving your camera, lets say to the left, you keep on circling around the map. How is this achieved? I was going to wrap my terrain around a cylinder, but I don't think that would produce the same effect, as the map in Civilization looks flat.

If statement not working in pixel shader

26 May 2011 - 05:15 PM

I'm trying to make fog of war by taking the terrain texture and the fog of war texture and multi-texturing them. It works pretty well except it seems to enter the if statement even if it isn't true

Here is the colors im using in the fog of war texture:

D3DCOLOR_XRGB(0,0,0); // for the completely dark unexplored areas
D3DCOLOR_XRGB(110,110,110); //this is the color of the seen but not visible areas, the actual color doesnt too much
D3DCOLOR_ARGB(254,255,255,255); //this what I use for the visible areas

Here is the pixel shader

sampler Terrain;
sampler Fog;

struct PS_INPUT
	float2 terrain : TEXCOORD0;
	float2 fog : TEXCOORD1;

struct PS_OUTPUT
	vector color : COLOR0;

	//zero out members of output
	PS_OUTPUT output = (PS_OUTPUT)0;

	//sample textures
	vector t = tex2D(Terrain, input.terrain);
	vector f = tex2D(Fog, input.fog);
	vector o;
	if(f.r != 110) // if the color isnt the gray color
		o = t * f;   // I combine these so I could reduce the number of if statements
		o.a = f.a; 
	else // if it is then gray scale it 

		float avg = (t.r + t.g + t.b) / 3;
		o.r = avg; o.g = avg; o.b = avg;
	output.color = o;
	return output;


So at the if(f.r != 110) it just enters it regardless. It works fine for the black and empty colors, though. Why would it do that?

Also if anybody knows a better way to do fog of war that would be helpful.