Top > マテリアル-PPMでLUT

UE4:ver.4.19.0


2018-04-10_15h06_00.png
2018-04-10_19h13_22.png

まだデフォルトのLUTでもON/OFFで若干色味が変わってしまってるっぽい?

テストしたマテリアル手順

  1. LUTテクスチャの設定を下記に
    1. Filterを “Tri-linear” に
    2. Texture Groupを “ColorLookupTable” に
  2. Mateiralの設定を下記に
    1. Mateiral Domainを “Post Process” に
    2. Blendable Locatinを “Before Tonemapping” に
  3. ノードを下記に
    LUTMaterial.png
  4. Customノードはこんな感じ
    static const float LUTSize = 16;
    
    #if POST_PROCESS_MATERIAL
    
    // ColorLookupTable
    {
    
    
    	// sRGBToLinear
    	{
    		LinearColor = max(6.10352e-5, LinearColor); // minimum positive non-denormal (fixes black problem on DX11 AMD and NV)
    		LinearColor = LinearColor > 0.04045 ? pow( LinearColor * (1.0 / 1.055) + 0.0521327, 2.4 ) : LinearColor * (1.0 / 12.92);
    	}
    	
    	float3 LUTEncodedColor;
    #if 0 // if( r.HDR.Display.OutputDevice >= 3 )
    	
    	// LinearToST2084
    	{
    		const float m1 = 0.1593017578125; // = 2610. / 4096. * .25;
    		const float m2 = 78.84375; // = 2523. / 4096. *  128;
    		const float c1 = 0.8359375; // = 2392. / 4096. * 32 - 2413./4096.*32 + 1;
    		const float c2 = 18.8515625; // = 2413. / 4096. * 32;
    		const float c3 = 18.6875; // = 2392. / 4096. * 32;
    		const float C = 10000.;
    
    		float3 L = LinearColor/C;
    		float3 Lm = pow(L, m1);
    		float3 N1 = ( c1 + c2 * Lm );
    		float3 N2 = ( 1.0 + c3 * Lm );
    		float3 N = N1 * rcp(N2);
    		float3 P = pow( N, m2 );
    		
    		LUTEncodedColor = P;
    	}
    #else
    	 float LinearRange = 14;
    	 float LinearGrey = 0.18;
    	 float ExposureGrey = 444;
    	 float3 Lin;
    	 // LogToLin(0)
    	 {
    		Lin = exp2( ( float3(0,0,0) - ExposureGrey / 1023.0 ) * LinearRange ) * LinearGrey;
    	 }
    
    	// LinToLog
    	{
    		
    		// Using stripped down, 'pure log', formula. Parameterized by grey points and dynamic range covered.
    		float3 LogColor = log2(LinearColor + Lin) / LinearRange - log2(LinearGrey) / LinearRange + ExposureGrey / 1023.0;	// scalar: 3log2 3mad
    		//float3 LogColor = (log2(LinearColor) - log2(LinearGrey)) / LinearRange + ExposureGrey / 1023.0;
    		//float3 LogColor = log2( LinearColor / LinearGrey ) / LinearRange + ExposureGrey / 1023.0;
    		//float3 LogColor = (0.432699 * log10(0.5 * LinearColor + 0.037584) + 0.616596) + 0.03;	// SLog
    		//float3 LogColor = ( 300 * log10( LinearColor * (1 - .0108) + .0108 ) + 685 ) / 1023;	// Cineon
    		LogColor = saturate( LogColor );
    		
    		LUTEncodedColor = LogColor;
    	}
    #endif
    	
    	
    	float3 UVW = LUTEncodedColor * ((LUTSize - 1) / LUTSize) + (0.5f / LUTSize);
    	
    	float3 OutputColor = UnwrappedTexture3DSample( TextureLUT, TextureLUTSampler, UVW, LUTSize ).rgb;
    	OutputColor = OutputColor * 1.05;
    	
    	
    	// sRGBToLinear
    	{
    		// OutputColor = max(6.10352e-5, OutputColor); // minimum positive non-denormal (fixes black problem on DX11 AMD and NV)
    		// OutputColor = OutputColor > 0.04045 ? pow( OutputColor * (1.0 / 1.055) + 0.0521327, 2.4 ) : OutputColor * (1.0 / 12.92);
    	}
    
    
    	return OutputColor;
    }
    #else
    return float3(0,0,0);
    #endif
    

添付ファイル: fileLUTMaterial.png 343件 [詳細] file2018-04-10_19h13_22.png 341件 [詳細] file2018-04-10_15h06_00.png 325件 [詳細]

リロード   新規 編集 凍結 差分 添付 複製 名前変更   ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS
Last-modified: 2018-04-11 (水) 22:32:35 (2426d)