本文整理汇总了C#中Texture2D.SetCSUAV方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.SetCSUAV方法的具体用法?C# Texture2D.SetCSUAV怎么用?C# Texture2D.SetCSUAV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture2D
的用法示例。
在下文中一共展示了Texture2D.SetCSUAV方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyBilateralFiltering
private void ApplyBilateralFiltering( Texture2D _Source, Texture2D _Target, float _BilateralRadius, float _BilateralTolerance, bool _Wrap )
{
if ( !m_CS_BilateralFilter.Use() )
throw new Exception( "Can't generate translucency map as bilateral filter compute shader failed to compile!" );
_Source.SetCS( 0 );
_Target.SetCSUAV( 0 );
m_CB_Filter.m._Radius = _BilateralRadius;
m_CB_Filter.m._Tolerance = _BilateralTolerance;
m_CB_Filter.m._Tile = (uint) (_Wrap ? 1 : 0);
uint h = Math.Max( 1, MAX_LINES*1024 / W );
uint callsCount = (uint) Math.Ceiling( (float) H / h );
for ( uint i=0; i < callsCount; i++ ) {
m_CB_Filter.m._Y0 = i * h;
m_CB_Filter.UpdateData();
m_CS_BilateralFilter.Dispatch( W, h, 1 );
m_Device.Present( true );
progressBar.Value = (int) (0.01f * (BILATERAL_PROGRESS * (i+1) / callsCount) * progressBar.Maximum);
Application.DoEvents();
}
_Target.RemoveFromLastAssignedSlotUAV(); // So we can use it as input for next stage
}
示例2: ComputeBRDFIntegral
unsafe void ComputeBRDFIntegral( System.IO.FileInfo _TableFileName, uint _TableSize ) {
// ComputeShader CS = new ComputeShader( m_Device, new System.IO.FileInfo( "Shaders/ComputeBRDFIntegral.hlsl" ), "CS", new ShaderMacro[0] );
ComputeShader CS = new ComputeShader( m_Device, new System.IO.FileInfo( "Shaders/ComputeBRDFIntegral.hlsl" ), "CS", new ShaderMacro[] { new ShaderMacro( "IMPORTANCE_SAMPLING", "1" ) } );
Texture2D TexTable = new Texture2D( m_Device, _TableSize, _TableSize, 1, 1, PIXEL_FORMAT.RG32_FLOAT, false, true, null );
TexTable.SetCSUAV( 0 );
CS.Use();
CS.Dispatch( _TableSize >> 4, _TableSize >> 4, 1 );
CS.Dispose();
string DDSFileName = System.IO.Path.GetFileNameWithoutExtension( _TableFileName.FullName ) + ".dds";
// DirectXTexManaged.TextureCreator.CreateDDS( DDSFileName, TexTable );
throw new Exception( "Deprecated!" );
Texture2D TexTableStaging = new Texture2D( m_Device, _TableSize, _TableSize, 1, 1, PIXEL_FORMAT.RG32_FLOAT, true, false, null );
TexTableStaging.CopyFrom( TexTable );
TexTable.Dispose();
// Write tables
float2 Temp = new float2();
float F0_analytical;
float ambient_analytical;
float maxAbsoluteError_F0 = 0.0f;
float maxRelativeError_F0 = 0.0f;
float avgAbsoluteError_F0 = 0.0f;
float avgRelativeError_F0 = 0.0f;
float maxAbsoluteError_ambient = 0.0f;
float maxRelativeError_ambient = 0.0f;
float avgAbsoluteError_ambient = 0.0f;
float avgRelativeError_ambient = 0.0f;
float2[] Integral_SpecularReflectance = new float2[_TableSize];
PixelsBuffer Buff = TexTableStaging.Map( 0, 0 );
using ( System.IO.BinaryReader R = Buff.OpenStreamRead() )
using ( System.IO.FileStream S = _TableFileName.Create() )
using ( System.IO.BinaryWriter W = new System.IO.BinaryWriter( S ) )
for ( int Y=0; Y < _TableSize; Y++ ) {
float2 SumSpecularlyReflected = float2.Zero;
for ( int X=0; X < _TableSize; X++ ) {
Temp.x = R.ReadSingle();
Temp.y = R.ReadSingle();
W.Write( Temp.x );
W.Write( Temp.y );
SumSpecularlyReflected.x += Temp.x;
SumSpecularlyReflected.y += Temp.y;
// Check analytical solution
float NdotV = (float) X / (_TableSize-1);
float roughness = (float) Y / (_TableSize-1);
AnalyticalBRDFIntegral_Order3( NdotV, roughness, out F0_analytical, out ambient_analytical );
// AnalyticalBRDFIntegral_Order2( NdotV, roughness, out F0_analytical, out ambient_analytical );
float absoluteError_F0 = Math.Abs( F0_analytical - Temp.x );
float relativeError_F0 = F0_analytical > 1e-6f ? Temp.x / F0_analytical : 0.0f;
maxAbsoluteError_F0 = Math.Max( maxAbsoluteError_F0, absoluteError_F0 );
maxRelativeError_F0 = Math.Max( maxRelativeError_F0, relativeError_F0 );
avgAbsoluteError_F0 += absoluteError_F0;
avgRelativeError_F0 += relativeError_F0;
float absoluteError_ambient = Math.Abs( ambient_analytical - Temp.y );
float relativeError_ambient = ambient_analytical > 1e-6f ? Temp.x / ambient_analytical : 0.0f;
maxAbsoluteError_ambient = Math.Max( maxAbsoluteError_ambient, absoluteError_ambient );
maxRelativeError_ambient = Math.Max( maxRelativeError_ambient, relativeError_ambient );
avgAbsoluteError_ambient += absoluteError_ambient;
avgRelativeError_ambient += relativeError_ambient;
}
// Normalize and store "not specularly reflected" light
SumSpecularlyReflected = SumSpecularlyReflected / _TableSize;
float sum_dielectric = 1.0f - (0.04f * SumSpecularlyReflected.x + SumSpecularlyReflected.y);
float sum_metallic = 1.0f - (SumSpecularlyReflected.x + SumSpecularlyReflected.y);
Integral_SpecularReflectance[Y] = SumSpecularlyReflected;
}
TexTableStaging.UnMap( 0, 0 );
avgAbsoluteError_F0 /= _TableSize*_TableSize;
avgRelativeError_F0 /= _TableSize*_TableSize;
avgAbsoluteError_ambient /= _TableSize*_TableSize;
avgRelativeError_ambient /= _TableSize*_TableSize;
string TotalSpecularReflectionTableFileName = System.IO.Path.GetFileNameWithoutExtension( _TableFileName.FullName ) + ".table";
using ( System.IO.FileStream S = new System.IO.FileInfo( TotalSpecularReflectionTableFileName ).Create() )
using ( System.IO.BinaryWriter W = new System.IO.BinaryWriter( S ) )
for ( int i=0; i < _TableSize; i++ ) {
W.Write( Integral_SpecularReflectance[i].x );
W.Write( Integral_SpecularReflectance[i].y );
}
}