⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mv_render.fx

📁 virtual reality project. This algorithm for building large image to Volume rendering. Using directx
💻 FX
📖 第 1 页 / 共 2 页
字号:


//---------------------- FinalPShader (ps_passFinall) ------------------------------------------------------                         
float4 MPRFinalPShader( float4 QuadTex : TEXCOORD0 ) : COLOR0
{
      float4 Color = tex2D( MPRRenderTargetTex, QuadTex );   // MPR 坊歹鸥百 咆胶媚 蔼 免仿
	  float4 VirtualColor = float4(0, 0, 0, 0);
	  float4 VirtualPosition = float4(0, 0, 0, 0);
	  float4 VirtualPosition1 = float4(0, 0, 0, 0);
	  float4 RealSlotPosition = float4(0, 0, 0, 0);
	  float4 MappedPosition = float4(0, 0, 0, 0);
	  float4 Result = float4(0, 0, 0, 0);
	  float4 Color2 = float4(0, 0, 0, 0);
	  if(Color.a > 0)
	  {
		  RealSlotPosition.r = floor(Color.r * 5.0);
		  RealSlotPosition.g = floor(Color.g * 5.0);
		  RealSlotPosition.b = floor(Color.b * 4.0);
		  Color.r = Color.r * 5.0;
		  Color.g = Color.g * 5.0;
		  Color.b = Color.b * 4.0;
		  MappedPosition.a = 1.0;
		  MappedPosition.r = (RealSlotPosition.b*5*5 + RealSlotPosition.g*5 + RealSlotPosition.r)/64.0 + 1.0/128.0;
		  MappedPosition.g = 0.5;
		  MappedPosition.b = 0.5;
		  VirtualColor = tex2D( MPRTexMapper, MappedPosition );   // MPR 坊歹鸥百 咆胶媚 蔼 免仿
		  VirtualPosition.r = round(VirtualColor.r*4.0)-RealSlotPosition.r;
		  VirtualPosition.g = round(VirtualColor.g*4.0)-RealSlotPosition.g;
		  VirtualPosition.b = round(VirtualColor.b*4.0)-RealSlotPosition.b;
		  //Result = abs(VirtualPosition);
	      VirtualPosition = Color + VirtualPosition;
		  VirtualPosition.r = VirtualPosition.r / 4.0;
		  VirtualPosition.g = VirtualPosition.g / 4.0;
		  VirtualPosition.b = VirtualPosition.b / 4.0;
	      VirtualPosition.a = 1.0;
	      Color2 = tex3D( VolumeDenSampler, Color );
	      Result = tex3D( VirtualVolume, VirtualPosition );
	  }
	 return Result;
}
//-------------------------------------------------------------------------------------------------------------
/*float4 MPRFinalPShaderTransed( float4 QuadTex : TEXCOORD0 ) : COLOR0
{
	float4 Color = tex2D( MPRRenderTargetTex, QuadTex );   // MPR 坊歹鸥百 咆胶媚 蔼 免仿
	float4 RealSlot = float4(0, 0, 0, 0);
	float4 MapperIndex = float4(0, 0, 0, 0);
	float4 Trans = float4(0, 0, 0, 0);
	float4 TransedPosition = float4(0, 0, 0, 0);
	float4 Result = float4(0, 0.3, 0.3, 0);
	
	if(Color.a > 0)
	{
		Color.r = Color.r * 512.0;
		Color.g = Color.g * 512.0;
		Color.b = Color.b * 101.0;

		RealSlot.r = floor((Color.r-0.5000000)/63.0000000);
		RealSlot.g = floor((Color.g-0.5000000)/63.0000000);
		RealSlot.b = floor((Color.b-0.5000000)/63.0000000);
		RealSlot.a = 1.0;

		MapperIndex.r = (RealSlot.b*9.0*9.0 + RealSlot.g*9.0 + RealSlot.r)/256.0 + 1.0/512.0;
		MapperIndex.g = 0.5;
		MapperIndex.b = 0.5;

		Trans = tex2D(MPRTexMapper, MapperIndex);

		TransedPosition.r = (Color.r + round(Trans.r*256-RealSlot.r)*63.0000000 + round(Trans.r*256))/256.0000000;
		TransedPosition.g = (Color.g + round(Trans.g*256-RealSlot.g)*63.0000000 + round(Trans.g*256))/512.0000000;
		TransedPosition.b = (Color.b + round(Trans.b*256-RealSlot.b)*63.0000000 + round(Trans.b*256))/512.0000000;
		//Color = Color/256.0;
		Result = tex3D(VirtualVolume, TransedPosition);
		//Result.rgb = Result.rgb * stencilLevelTestColor.rgb;	// test 侩栏肺 level 喊肺 漠扼 促福霸窃. //added by JUN
		Result.a = Trans.a;	// level 沥焊甫 alpha 蔼栏肺 免仿.  //added by JUN
	}
	return Result;
}*/
//-------------------------------------------------------------------------------------------------------------
/*float3 sizeOfSubvolume;
float3 redunRealSlot;
float3 volumeSize;
float3 virtualSubvolumeSize;*/
//-------------------------------------------------------------------------------------------------------------
float4 MPRFinalPShaderTransed( float4 QuadTex : TEXCOORD0 ) : COLOR0
{
	float4 Color = tex2D( MPRRenderTargetTex, QuadTex );   // MPR 坊歹鸥百 咆胶媚 蔼 免仿
	float4 RealSlot = float4(0, 0, 0, 0);
	float4 MapperIndex = float4(0, 0, 0, 0);
	float4 Trans = float4(0, 0, 0, 0);
	float4 TransedPosition = float4(0, 0, 0, 0);
	float4 Result = float4(0, 0.3, 0.3, 0);
	float4 Temp = float4(0, 0, 0, 0);
	float4 Temp1 = float4(0, 0, 0, 0);
	
	Temp.x = sizeOfSubvolume.x - 1.0;
	Temp.y = sizeOfSubvolume.y - 1.0;
	Temp.z = sizeOfSubvolume.z - 1.0;
	//Temp = Temp - 1.0;

	Color.r = Color.r * volumeSize.x;
	Color.g = Color.g * volumeSize.y;
	Color.b = Color.b * volumeSize.z;

	RealSlot.r = floor((Color.r-0.5000000)/Temp.x);
	RealSlot.g = floor((Color.g-0.5000000)/Temp.y);
	RealSlot.b = floor((Color.b-0.5000000)/Temp.z);
	RealSlot.a = 1.0;

	MapperIndex.r = (RealSlot.b*redunRealSlot.x*redunRealSlot.y + RealSlot.g*redunRealSlot.x + RealSlot.r)
					/forOptimize.w;
	MapperIndex.g = 0.5;
	MapperIndex.b = 0.5;

	Trans = tex2D(MPRTexMapper, MapperIndex);

	TransedPosition.r = (Color.r + round(Trans.r*256-RealSlot.r)*Temp.x + round(Trans.r*256))/forOptimize.x;
	TransedPosition.g = (Color.g + round(Trans.g*256-RealSlot.g)*Temp.y + round(Trans.g*256))/forOptimize.y;
	TransedPosition.b = (Color.b + round(Trans.b*256-RealSlot.b)*Temp.z + round(Trans.b*256))/forOptimize.z;
	
	Result = tex3D(VirtualVolume, TransedPosition);
//	Result.rgb = Result.rgb * stencilLevelTestColor.rgb;	// test 侩栏肺 level 喊肺 漠扼 促福霸窃. //added by JUN
//	Result.rgb = stencilLevelTestColor.rgb;	// test 侩栏肺 level 喊肺 漠扼 促福霸窃. //added by JUN
	Result.a = Trans.a;	// level 沥焊甫 alpha 蔼栏肺 免仿.  //added by JUN

	return Result;
}
//-------------------------------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------------------------------
float4 MPRFinalPShaderTransedType1( float4 QuadTex : TEXCOORD0 ) : COLOR0
{
	float4 Color = tex2D( MPRRenderTargetTex, QuadTex );   // MPR 坊歹鸥百 咆胶媚 蔼 免仿
	float4 RealSlot = float4(0, 0, 0, 0);
	float4 MapperIndex = float4(0, 0, 0, 0);
	float4 Trans = float4(0, 0, 0, 0);
	float4 TransedPosition = float4(0, 0, 0, 0);
	float4 Result = float4(0, 0.3, 0.3, 0);
	
	if(Color.a > 0)
	{
		Color.r = Color.r * 256.0;
		Color.g = Color.g * 256.0;
		Color.b = Color.b * 256.0;

		RealSlot.r = floor((Color.r-0.5000000)/63.0000000);
		RealSlot.g = floor((Color.g-0.5000000)/63.0000000);
		RealSlot.b = floor((Color.b-0.5000000)/63.0000000);
		RealSlot.a = 1.0;

		MapperIndex.r = (RealSlot.b*5.0*5.0 + RealSlot.g*5.0 + RealSlot.r)/128.0 + 1.0/256.0;
		MapperIndex.g = 0.5;
		MapperIndex.b = 0.5;

		Trans = tex2D(MPRTexMapper, MapperIndex);

		TransedPosition.r = (Color.r + round(Trans.r*4-RealSlot.r)*63.0000000 + round(Trans.r*4))/256.0000000;
		TransedPosition.g = (Color.g + round(Trans.g*4-RealSlot.g)*63.0000000 + round(Trans.g*4))/256.0000000;
		TransedPosition.b = (Color.b + round(Trans.b*8-RealSlot.b)*63.0000000 + round(Trans.b*8))/512.0000000;
		//Color = Color/256.0;
		Result = tex3D(VirtualVolume, TransedPosition);
		//Result.rgb = Result.rgb * stencilLevelTestColor.rgb;	// test 侩栏肺 level 喊肺 漠扼 促福霸窃. //added by JUN
		Result.a = Trans.a;	// level 沥焊甫 alpha 蔼栏肺 免仿.  //added by JUN
	}
	return Result;
}
//-------------------------------------------------------------------------------------------------------------

float4 MPRFinalPShaderSource( float4 QuadTex : TEXCOORD0 ) : COLOR0
{
      float4 Color = tex2D( MPRRenderTargetTex, QuadTex );   // MPR 坊歹鸥百 咆胶媚 蔼 免仿
		if(Color.a <= 0)
		{
			Color.r = 0;
			Color.g = 0;
			Color.b = 0;
		}
	  return Color;
}
//-------------------------------------------------------------------------------------------------------------
float4 MPRFinalPShaderMapper( float4 QuadTex : TEXCOORD0 ) : COLOR0
{
      float4 Color = tex2D( MPRTexMapper, QuadTex );   // MPR 坊歹鸥百 咆胶媚 蔼 免仿
	  return Color;
}

//-------------------------------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------------------------------

technique MVRenderTechnique
{
	
    pass EmptySkipPass // pass0
    {
        ClipPlaneEnable=0;
        AlphaBlendEnable=false;
        ZEnable=true;
        ZWriteEnable=true;
        ZFunc=less;
        CullMode=none;
  
        VertexShader = compile vs_2_0 EmptySkipVShader();
        PixelShader = compile ps_2_0 EmptySkipPShader();
    }

    pass VolumeRenderPass // pass1
    {
        ClipPlaneEnable=CLIPPLANE0 | CLIPPLANE1 | CLIPPLANE2 | CLIPPLANE3 | CLIPPLANE4 | CLIPPLANE5;
        AlphaBlendEnable=true;
        ZEnable=true;
        ZWriteEnable=false;  // FALSE !
        ZFunc=greaterequal;
		CullMode=none;

        VertexShader = compile vs_2_0 VolumeRenderVShader();
        PixelShader = compile ps_2_0 VolumeRenderPShader();
    }

    pass EarlyRayPass // pass2
    {
        ClipPlaneEnable=CLIPPLANE0 | CLIPPLANE1 | CLIPPLANE2 | CLIPPLANE3 | CLIPPLANE4 | CLIPPLANE5;
        AlphaBlendEnable=true;
        ZEnable=true; // D3DRS_ZENABLE 捞 拌加 TRUE 肺 汲沥登绢具 shader 郴何俊辑 depth 函版啊瓷窍骨肺 TRUE肺..
        ZWriteEnable=true;   // TRUE !
        ZFunc=greaterequal;
		CullMode=none;
       
        VertexShader = compile vs_2_0 EarlyRayVShader();
        PixelShader = compile ps_2_0 EarlyRayPShader();
    }

    pass FinalPass // pass3
    {
        ClipPlaneEnable=0;
        AlphaBlendEnable=false;
        ZEnable=false;
        ZWriteEnable=false;
		CullMode=none;
       
        VertexShader = NULL;
        PixelShader = compile ps_2_0 FinalPShader();
    }

	pass ShowDepthPass // pass4
    {
        ClipPlaneEnable=0;
        AlphaBlendEnable=false;
        ZEnable=true;
        ZWriteEnable=true;
        ZFunc=less;
        CullMode=none;
  
        VertexShader = compile vs_2_0 EmptySkipVShader();
        PixelShader = compile ps_2_0 EmptySkipPShaderShowDepth();
    }

	pass MeshRenderPass // pass5
	{
		ClipPlaneEnable=CLIPPLANE0 | CLIPPLANE1;
        AlphaBlendEnable=true;
        ZEnable=false;
        CullMode=ccw;

        VertexShader = NULL;// compile vs_2_0 MeshRenderVShader();
        PixelShader = NULL;//compile ps_2_0 MeshRenderPShader();
	}

	pass MPRRenderPass // pass6
	{
		ClipPlaneEnable=CLIPPLANE0 | CLIPPLANE1;
        AlphaBlendEnable=true;
        ZEnable=false;
        CullMode=none;

        VertexShader = compile vs_2_0 MPRRenderVShader();
        PixelShader = compile ps_2_0 MPRRenderPShader();
	}
	
	// MPR_TEST
	pass CustomMRPRenderPass // pass7
	{
		ClipPlaneEnable=0;
        AlphaBlendEnable=false;
        ZEnable=false;
        CullMode=none;

        VertexShader = compile vs_2_0 CustomMPRVShader();
        PixelShader = compile ps_2_0 CustomMPRPShader();
	}
	
	// MPR_TEST
	pass CustomMRPRenderWirePass // pass8 : show mpr plane in wire frame
	{
		ClipPlaneEnable=0;
        AlphaBlendEnable=false;
        ZEnable=false;
        CullMode=none;

        VertexShader = compile vs_2_0 CustomMPRVShader();
        PixelShader = compile ps_2_0 CustomMPRPShaderWire();
	}
	
	// MPR_TEST
	///////////////////////////////////////////////////////////////////////////////////////////////////////////
	//---- MPR Plane 旗辑 MPR 咆胶媚 谅钎甫 m_pMPRRenderTarget 狼 color 蔼栏肺 免仿.
	pass MPRQuadPass // pass9 : MPR 2d Quad plane shader
    {
        ClipPlaneEnable=0;
        AlphaBlendEnable=false;
        ZEnable=false;
        ZWriteEnable=false;
		CullMode=none;
       
        VertexShader = NULL;
    //    PixelShader = compile ps_2_0 CustomMPRPShader();				// MPR texture 俊 角力 杭俘 density 蔼 蝶客辑 免仿.
        PixelShader = compile ps_2_0 MPRQuadTexColorPShader();		// MPR texture 俊 texture coord. 免仿.
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    
    // MPR_TEST
    // wire 肺 焊咯林扁.. temporary test 内靛..
  	pass MPRQuadPass2 // pass10 : MPR 2d Quad wire shader
    {
        ClipPlaneEnable=0;
        AlphaBlendEnable=false;
        ZEnable=false;
        ZWriteEnable=false;
		CullMode=none;
       
        VertexShader = NULL;
        PixelShader = compile ps_2_0 CustomMPRPShaderWire();
    }
    
    // MPR_TEST
    //------- 掘绢柳 MPR TexCoord. 坊歹鸥百 咆胶媚甫 拳搁 坷弗率俊 免仿.
	pass MPRQuadPass3 // pass11
    {
        ClipPlaneEnable=0;
        AlphaBlendEnable=false;
        ZEnable=false;
        ZWriteEnable=false;
		CullMode=none;
       
        VertexShader = NULL;
        PixelShader = compile ps_2_0 MPRFinalPShaderTransed();
    }
    // MPR_TEST
    //------- 掘绢柳 MPR TexCoord. 坊歹鸥百 咆胶媚甫 拳搁 坷弗率俊 免仿.
	pass MPRQuadPass4 // pass12
    {
        ClipPlaneEnable=0;
        AlphaBlendEnable=false;
        ZEnable=false;
        ZWriteEnable=false;
		CullMode=none;
       
        VertexShader = NULL;
        PixelShader = compile ps_2_0 MPRFinalPShaderSource();
    }
    // MPR_TEST
    //------- 掘绢柳 MPR TexCoord. 坊歹鸥百 咆胶媚甫 拳搁 坷弗率俊 免仿.
	pass MPRQuadPass5 // pass13
    {
        ClipPlaneEnable=0;
        AlphaBlendEnable=false;
        ZEnable=false;
        ZWriteEnable=false;
		CullMode=none;
       
        VertexShader = NULL;
        PixelShader = compile ps_2_0 MPRFinalPShaderMapper();
    }
    // MPR_TEST
    //------- 掘绢柳 MPR TexCoord. 坊歹鸥百 咆胶媚甫 拳搁 坷弗率俊 免仿.
	pass MPRQuadPass6 // pass14
    {
        ClipPlaneEnable=0;
        AlphaBlendEnable=false;
        ZEnable=false;
        ZWriteEnable=false;
		CullMode=none;
       
        VertexShader = NULL;
        PixelShader = compile ps_2_0 MPRFinalPShader();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -