Solar Wind 3D Sample

This sample for Silverilght 5 uses the new 3D features to draw the Earth with day and night transitions, atmosphere layers, and population density overlays. It demonstrates advanced concepts like mipmaps, texture blending, multiple drawing passes, sampler states...

C# (10.4 MB)
 
 
 
 
 
4.4 Star
(8)
9,128 times
Add to favorites
9/12/2011
E-mail Twitter del.icio.us Digg Facebook
//
// This file is a pixel shader for drawing Earth population density.
//

#include "EarthCommon.hlsl"

// Textures
sampler2D PopulationSampler : register(s0);

// Pixel shader
float4 main(VertexShaderOutput input) : COLOR 
{	
	float4 population = tex2D(PopulationSampler, input.UV);

	// calculate density
	population.rgb *= 255;
	float density = (255 - population.r) + (227 - population.g) + (141 - population.b);	
	density /= 454; // convert to value between 0.0 and 1.0

	//if(population.a < 0.6) population.a = 0.0; // eliminate continent border
	density *= population.a; // apply mask
	float inverseDensity = 1.0 - density;

	// adjust alpha by density
	float alpha = population.a * density * 4.0f;
	//float alpha = population.a * max(0,(2.5 + log(density)));
	
	return (float4(255, 25, 67, 0) / 255) * density + (float4(255, 209, 5, 0) / 255) * inverseDensity + float4(0,0,0,saturate(alpha));
}