normalrect.fp
来自「PDE simulator on GPU.」· FP 代码 · 共 36 行
FP
36 行
!!FP1.0
#here compute the normal of a vector which in a 2d Texture
#add all elements together into ONE element
#HERE Texture Unit----RECT, just ONE channel
DECLARE TexOffset ={0,0,0,0};
#sample the current position (i,j)
TEX R0, f[WPOS], TEX0, RECT;
#sample the (i+W/2,j)
ADD R1, f[WPOS], TexOffset.xwww;
TEX R1, R1, TEX0, RECT;
ADD R0, R0, R1;
#sample the (i,j+W/2)
ADD R1, f[WPOS], TexOffset.wxww;
TEX R1, R1, TEX0, RECT;
ADD R0, R1, R0;
#sample the (i+W/2, j+W/2)
ADD R1, f[WPOS], TexOffset.xxww;
TEX R1, R1, TEX0, RECT;
#sum 4 positions together in 1 channel
ADD o[COLR], R1, R0;
#If in 4 Channels, we need to sum RGBA components together
#ADD R2, R1, R0;
#ADD R2.x, R2.x,R2.y;
#ADD R2.x, R2.x,R2.z;
#ADD o[COLR], R2.x,R2.w;
END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?