Показать сообщение отдельно
Старый 13.03.2011, 21:07   #12
ІГРОГРАЙКО
ПроЭктировщик
 
Аватар для ІГРОГРАЙКО
 
Регистрация: 20.06.2009
Адрес: Україна
Сообщений: 152
Написано 10 полезных сообщений
(для 24 пользователей)
Плохо Ответ: Volume Rendering на XNA (Texture3D)

Да... Спасибо! Но!

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(front, 0);
    
    float4 dst = float4(0, 0, 0, 0);
    float4 src = 0;
    
    float value = 0;
	
	float3 Step = dir * StepSize;
    
    for(int i = 0; i < 10; 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 >= .95f)
			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;
}


technique RayCastSimple
{
    pass Pass1
    {		
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_2_0 RayCastSimplePS();
    }
}
}
Все одно вылетает из за:

Ошибка	2	E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx(136,9): error X5426: Shader uses texture addressing operations in a dependency chain that is too complex for the target shader model (ps_2_0) to handle.  
ID3DXEffectCompiler: Compilation failed

	E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx	VolumeRayCasting
И если изменяю ps_2_0 на ps_3_0 Опять:

Нажмите на изображение для увеличения
Название: Image1.jpg
Просмотров: 1168
Размер:	44.9 Кб
ID:	12965

Что с етим делать???
__________________
Blitz3D, XNA, WebGL, OpenGL, Unity3D
PC: ASUS A55VM Core i3 (2.4Ghz), 6 Gb RAM, Nvidia GF 630M GT 2Gb
(Offline)
 
Ответить с цитированием