Да рах ты прав!
Запустилось у меня, но отрисовует только один шар:
Если:
float4 RayCastSimplePS(VertexShaderOutput input) : COLOR0
{
//calculate projective texture coordinates
//used to project the front and back position textures onto the cube
float2 texC = input.pos.xy /= input.pos.w;
texC.x = 0.5f*texC.x + 0.5f;
texC.y = -0.5f*texC.y + 0.5f;
float3 front = tex2D(FrontS, texC).xyz;
float3 back = tex2D(BackS, texC).xyz;
float3 dir = normalize(back - front);
float4 pos = float4(input.texC, 0);
float4 dst = float4(0, 0, 0, 0);
float4 src = 0;
float value = 0;
float3 Step = dir * StepSize;
for(int i = 0; i < 2; i++)
{
pos.w = 0;
value = tex3D(VolumeS, pos).r;
src = (float4)value;
//src.a *= .1f; //reduce the alpha to have a more transparent result
//this needs to be adjusted based on the step size
//i.e. the more steps we take, the faster the alpha will grow
//Front to back blending
// dst.rgb = dst.rgb + (1 - dst.a) * src.a * src.rgb
// dst.a = dst.a + (1 - dst.a) * src.a
//src.rgb *= src.a;
dst = (1.0f - dst.a)*src + dst;
//break from the loop when alpha gets high enough
if(dst.a >= .9f)
break;
//advance the current position
pos.xyz += Step;
//break if the position is greater than <1, 1, 1>
if(pos.x > 1.0f || pos.y > 1.0f || pos.z > 1.0f)
break;
}
return dst;
}
то вилетает:
Ошибка 2 E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx(112,8): error X5608: Compiled shader code uses too many arithmetic instruction slots (70). Max. allowed by the target (ps_2_0) is 64.
E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx(187,23): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
ID3DXEffectCompiler: Compilation failed
E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx VolumeRayCasting
Что с етим делать?
Как быть?