TilingFP.cg
资源名称:3dwind2.0.rar [点击查看]
上传用户:xhbjoy
上传日期:2014-10-07
资源大小:38068k
文件大小:1k
源码类别:
游戏引擎
开发平台:
Visual C++
- sampler RT : register(s0);
- float4 Tiling_ps(float4 inPos : POSITION,
- float2 iTexCoord : TEXCOORD0,
- uniform half NumTiles,
- uniform half Threshhold) : COLOR
- {
- half3 EdgeColor = {0.7, 0.7, 0.7};
- half size = 1.0/NumTiles;
- half2 Pbase = iTexCoord - fmod(iTexCoord, size.xx);
- half2 PCenter = Pbase + (size/2.0).xx;
- half2 st = (iTexCoord - Pbase)/size;
- half4 c1 = (half4)0;
- half4 c2 = (half4)0;
- half4 invOff = half4((1-EdgeColor),1);
- if (st.x > st.y) { c1 = invOff; }
- half threshholdB = 1.0 - Threshhold;
- if (st.x > threshholdB) { c2 = c1; }
- if (st.y > threshholdB) { c2 = c1; }
- half4 cBottom = c2;
- c1 = (half4)0;
- c2 = (half4)0;
- if (st.x > st.y) { c1 = invOff; }
- if (st.x < Threshhold) { c2 = c1; }
- if (st.y < Threshhold) { c2 = c1; }
- half4 cTop = c2;
- half4 tileColor = tex2D(RT, PCenter);
- half4 result = tileColor + cTop - cBottom;
- return result;
- }