unity 颜色空间linear下色差问题

我们项目美术是在linear下制作资源的,做一些比较真实一点的效果会比较容易些,在editer模式下看是比较精美的,但是打包完放在手机上,明显有一些色差问题,如图:


在手机上的效果:

在editer下的效果

后来找了很久,最终发现是lightmap计算方式不一致导致的,直接修改unity的UnityCG.cginc文件可完美解决问题:修改代码如下:

// Decodes doubleLDR encoded lightmaps.
inline half3 DecodeLightmapDoubleLDR( fixed4 color, half4 decodeInstructions)
{
    #if defined(UNITY_COLORSPACE_GAMMA)
        return 2.0 * color.rgb;
    #else
        return decodeInstructions.x * color.rgb;
    #endif
}

inline half3 DecodeLightmap( fixed4 color, half4 decodeInstructions)
{
#if defined(UNITY_NO_RGBM)
    return DecodeLightmapDoubleLDR( color, decodeInstructions);
#else
    return DecodeLightmapRGBM( color, decodeInstructions );
#endif
}

cg文件在unity安装目录下:Unity\Editor\Data\CGIncludes\UnityCG.cginc 找到对应的位置修改即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值