#include "convert_rgb8.hls"

// Velocity map
sampler	VELOCITY_MAP	: register (s0);

// Quantity map
sampler	QUANTITY_MAP	: register (s1);

// Simulation step value
float SIMULATION_STEP			: register (c0);

// Reciprocal of Grid Size
float INV_GRID_SIZE		: register (c1);

void main
	(
		float2 coords	: TEXCOORD0, // grid coordinates
		out float4 vNew	: COLOR0 // advected qty
	)
{
	float2 pos = coords - extractNeg(tex2D(VELOCITY_MAP, coords)).xy * SIMULATION_STEP;

	// follow the velocity field "back in time"
	vNew = tex2D(QUANTITY_MAP, pos);
}
