ue landscape 法线贴图采样数

使用landscape时,抓帧结果中,有一张法线贴图(不单是法线,四通道包含混合信息)。同样的图,使用了两个采样器采样。

一次采样是在landscape对应的ush文件中(LandscapeVertexFactory.ush)

float3x3 VertexFactoryGetPerPixelTangentBasis(FVertexFactoryInterpolantsVSToPS Interpolants)
{
    float3x3 Result;
#if PIXELSHADER || RAYHITGROUPSHADER || COMPUTESHADER
#if FEATURE_LEVEL >= FEATURE_LEVEL_SM4
    float4 SampleValue = Texture2DSample(LandscapeParameters.NormalmapTexture, LandscapeParameters.NormalmapTextureSampler, Interpolants.WeightHeightMapTexCoord.zw);
#else
    float4 SampleValue = Texture2DSample(LandscapeParameters.NormalmapTexture, LandscapeParameters.NormalmapTextureSampler, Interpolants.WeightMapTexCoord);
#endif
#if WEBGL
    float2 SampleNormal = float2(SampleValue.b, SampleValue.a) * float2(2.0,2.0) - float2(1.0,1.0);
#else
    float2 SampleNormal = float2(SampleValue.b, SampleValue.a) * float2(2.0,2.0) - float2(1.0,1.0);
#endif
    float3 WorldNormal = float3( SampleNormal, sqrt(max(1.0-dot(SampleNormal,SampleNormal),0.0)) );

    Result = CalcTangentBasisFromWorldNormal(WorldNormal);
#endif
    return Result;
}

只要使用了 LandscapeParameters.NormalmapTexture,将会产生一次采样。这是在FLandscapeComponentSceneProxy 中声明的LandscapeUniformShaderParameters参数。在cpu层,FLandscapeComponentSceneProxy::OnTransformChanged()中指定初始化。

 

另外一次采样是发生成材质结点中,使用了Layer Blend结点后,将会产生另外一次采样。虽然是相同的图,但是采样器却是另外一个。

 

当landscape的地面效果复杂,导至采样器不够用时,这里或许可以优化。统一成一个采样器。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值