游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1900|回复: 3

询问下关于这个shader的意思

[复制链接]

8

主题

79

帖子

126

积分

注册会员

Rank: 2

积分
126
发表于 2010-3-5 15:15:00 | 显示全部楼层 |阅读模式
sampler2D baseMap;
float fInverseViewportWidth;
float fInverseViewportHeight;

struct PS_INPUT
{
   float2 Texcoord : TEXCOORD0;
   
};


const float4 samples[4] = {
   -1.0,    0.0,    0,    0.25,
    1.0,    0.0,    0,    0.25,
    0.0,    1.0,   0,    0.25,
    0.0,    -1.0,   0,    0.25
};

float4 ps_main( PS_INPUT Input ) : COLOR0
{
   //return tex2D( baseMap, Input.Texcoord );
   
   float4 col = float4(0,0,0,0);

   // Sample and output the box averaged colors
   for(int i=0;i<4;i++)
      col += samples.w*tex2D(baseMap, Input.Texcoord +
       float2(samples.x*fInverseViewportWidth,
              samples.x*fInverseViewportHeight));
   return col;
   
}

我不是很明白 为什么

float2(samples.x*fInverseViewportWidth,
              samples.x*fInverseViewportHeight)

samples 要乘以 fInverseViewportWidth  这样做的意义是什么?


Cheers!

8

主题

79

帖子

126

积分

注册会员

Rank: 2

积分
126
 楼主| 发表于 2010-3-5 15:22:00 | 显示全部楼层

Re:询问下关于这个shader的意思

想 明白了

自己回答下

自己回答: 像素混合他取的是 当前点的周围 4个像素

-1. 0, 0 ...

由于贴图坐标是映射的 0 -1

所以吧这个像素也需要映射到 0 - 1

就乘以了 fInverseViewportWidth

如果不对的话 麻烦哪位帮忙纠正了.. 3Q

15

主题

62

帖子

64

积分

注册会员

Rank: 2

积分
64
发表于 2010-3-5 16:13:00 | 显示全部楼层

Re:询问下关于这个shader的意思

就是把offset设置成+-一个texcel,进行过滤。
lz自己的解释是对的

8

主题

716

帖子

716

积分

高级会员

Rank: 4

积分
716
发表于 2010-3-5 20:07:00 | 显示全部楼层

Re:询问下关于这个shader的意思

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

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-12 17:43

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表