1uniform float4x4 ViewProj; 2uniform float4 color = {1.0, 1.0, 1.0, 1.0}; 3 4uniform float4 randomvals1; 5uniform float4 randomvals2; 6uniform float4 randomvals3; 7 8struct SolidVertInOut { 9 float4 pos : POSITION; 10}; 11 12SolidVertInOut VSSolid(SolidVertInOut vert_in) 13{ 14 SolidVertInOut vert_out; 15 vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj); 16 return vert_out; 17} 18 19float4 PSSolid(SolidVertInOut vert_in) : TARGET 20{ 21 return color; 22} 23 24float rand(float4 pos, float4 rand_vals) 25{ 26 return 0.5 + 0.5 * frac(sin(dot(pos.xy, float2(rand_vals.x, rand_vals.y))) * rand_vals.z); 27} 28 29float4 PSRandom(SolidVertInOut vert_in) : TARGET 30{ 31 return float4(rand(vert_in.pos, randomvals1), 32 rand(vert_in.pos, randomvals2), 33 rand(vert_in.pos, randomvals3), 34 1.0); 35} 36 37struct SolidColoredVertInOut { 38 float4 pos : POSITION; 39 float4 color : COLOR; 40}; 41 42SolidColoredVertInOut VSSolidColored(SolidColoredVertInOut vert_in) 43{ 44 SolidColoredVertInOut vert_out; 45 vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj); 46 vert_out.color = vert_in.color; 47 return vert_out; 48} 49 50float4 PSSolidColored(SolidColoredVertInOut vert_in) : TARGET 51{ 52 return vert_in.color * color; 53} 54 55technique Solid 56{ 57 pass 58 { 59 vertex_shader = VSSolid(vert_in); 60 pixel_shader = PSSolid(vert_in); 61 } 62} 63 64technique SolidColored 65{ 66 pass 67 { 68 vertex_shader = VSSolidColored(vert_in); 69 pixel_shader = PSSolidColored(vert_in); 70 } 71} 72 73technique Random 74{ 75 pass 76 { 77 vertex_shader = VSSolid(vert_in); 78 pixel_shader = PSRandom(vert_in); 79 } 80} 81