请选择 进入手机版 | 继续访问电脑版

开源计算机图形学社区(Open Source Computer Graphics Community) |OpenGPU Forum (2007-2013)| OpenGPU Project

 找回密码
 注册
搜索
查看: 452|回复: 0

求教ue4对于不支持浮点纹理的显卡进行线性计算的方法 [复制链接]

Rank: 12Rank: 12Rank: 12

注册时间
2012-6-6
积分
742
发表于 2017-2-7 12:32:51 |显示全部楼层
最近看到,在不支持浮点纹理的显卡上,ue4用这种mosaic的方法模拟12bit/channel,然后保证线性计算时候保存到纹理时不会出现精度损失,但ppt上讲的不是很清楚,想请教大家具体做法是什么,有参考文献吗,以及这么做会导致分辨率的损失吗?

以下是ue4中相关代码:
MaterialFloat3 HdrMosaic(MaterialFloat3 LinearColor, MaterialFloat2 VPos)
{
        MaterialFloat2 V;
        V = VPos.xy * 0.5;
        V.y += V.x;
        V = frac(V);
        MaterialFloat2 C;
        C = (V * MaterialFloat2(2.0 * (-0.5/255.0), MOSAIC_MUL)) + MaterialFloat2(-0.5/255.0, MOSAIC_ADD);
        return (LinearColor * C.y) + C.x;
}

#define DEMOSAIC_MUL (((1.0/DRK_MUL) - (1.0/HDR_MUL)) * 2.0)
#define DEMOSAIC_ADD (1.0/HDR_MUL)

// Resolve pass to remove mosaic and restore color.
MaterialFloat3 HdrDemosaic(MaterialFloat3 Pixel, MaterialFloat3 OtherPixel, MaterialFloat2 VPos)
{
        MaterialFloat A = frac(dot(VPos + View.DemosaicVposOffset, MaterialFloat2(0.5, 0.5)));
        MaterialFloat B = 0.5 - A;
        A = A * DEMOSAIC_MUL + DEMOSAIC_ADD;
        B = B * DEMOSAIC_MUL + DEMOSAIC_ADD;

        // On ES2 devices we demosaic during the tonemapping pass which renders upside down, account for that here.
        #if COMPILER_GLSL_ES2
                return max((Pixel * B), (OtherPixel * A));
        #else
                return max((Pixel * A), (OtherPixel * B));
        #endif
}

最近看过此主题的会员

您需要登录后才可以回帖 登录 | 注册

‹‹
我的工具栏

关于我们|手机版|Archiver|开源计算机图形学社区(Open Source Computer Graphics Community) | OpenGPU Project | OpenGPU Forum (2007-2013)

GMT+8, 2017-2-22 11:59 , Processed in 0.047695 second(s), 12 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部