ue4 lightmap的解码

一. lq的解码过程     lightmapCommon.ush   GetLightMapColorLQ()函数:

1. 纹理采样:

ue4 lightmap的解码

 

 2. 亮度、颜色还原

ue4 lightmap的解码

 

 3. 还原亮度

ue4 lightmap的解码

 

 4. 还原最大贡献方向

ue4 lightmap的解码

 

 5. 最终颜色还原

ue4 lightmap的解码

 

 二、 hq解码过程  lightmapCommon.ush   GetLightMapColorHQ()函数

1. 纹理采样:分为有vt和没有vt:

ue4 lightmap的解码

 

 2. 亮度还原

ue4 lightmap的解码

 

 3. 颜色还原

ue4 lightmap的解码

 

 4. 还原方向,是否定义方向,是否是双向植被:

ue4 lightmap的解码

 

 5. 最终颜色:

ue4 lightmap的解码

 

 三、 skyOcclusion和aomaterialMask的解码

float4 GetSkyBentNormalAndOcclusion(VTPageTableResult LightmapVTPageTableResult, float2 LightmapUV, uint LightmapDataIndex, float2 SvPositionXY)
{
	float4 TextureValue;
#if LIGHTMAP_VT_ENABLED
	TextureValue = SampleLightmapVT( LightmapVTPageTableResult, 3u, LightmapDataIndex, LightmapResourceCluster.VTSkyOcclusionTexture, LIGHTMAP_SHARED_SAMPLER(SkyOcclusionSampler)); 
#else
	TextureValue = Texture2DSample( LightmapResourceCluster.SkyOcclusionTexture, LIGHTMAP_SHARED_SAMPLER(SkyOcclusionSampler), LightmapUV );
#endif

	// Unpack vector
	TextureValue.rgb = TextureValue.rgb * 2 - 1;
	// Undo sqrt which allocated more precision toward 0
	TextureValue.a = TextureValue.a * TextureValue.a;
	return TextureValue;
}

float GetAOMaterialMask(VTPageTableResult LightmapVTPageTableResult, float2 LightmapUV, uint LightmapDataIndex, float2 SvPositionXY)
{
	float TextureValue;
#if LIGHTMAP_VT_ENABLED
	TextureValue = SampleLightmapVT( LightmapVTPageTableResult, 4u, LightmapDataIndex, LightmapResourceCluster.VTAOMaterialMaskTexture, LIGHTMAP_SHARED_SAMPLER(AOMaterialMaskSampler)).x; 
#else
	TextureValue = Texture2DSample( LightmapResourceCluster.AOMaterialMaskTexture, LIGHTMAP_SHARED_SAMPLER(AOMaterialMaskSampler), LightmapUV ).x;
#endif

	// Undo sqrt which allocated more precision toward 0
	return TextureValue * TextureValue;
}

  

四、 ue4 lightmap编码特点的思考:

1. 好处:

ue4 lightmap的解码

 

 2. 不足:

ue4 lightmap的解码

 

ue4 lightmap的解码

上一篇:配置Nginx反向代理、HTTPS和认证


下一篇:简单了解JS中的几种遍历