0001:
0002:
0003:
0004:
0005:
0006:
0007:
0008:
0009: struct vert2frag
0010: {
0011: float4 hpos : HPOS;
0012: float4 tcoords : TEX0;
0013: };
0014:
0015:
0016:
0017: fragout main(vert2frag I
0018: , uniform texobj2D SrcTex : texunit0
0019: )
0020: {
0021: fragout O;
0022:
0023: float2 shiftX = { ( 1.0f+0.0f)/128.0f, ( 0.0f+0.0f)/128.0f };
0024: float2 shiftZ = { ( 0.0f+0.0f)/128.0f, ( 1.0f+0.0f)/128.0f };
0025: float2 shift3 = { (-1.0f+0.0f)/128.0f, ( 0.0f+0.0f)/128.0f };
0026: float2 shift4 = { ( 0.0f+0.0f)/128.0f, (-1.0f+0.0f)/128.0f };
0027:
0028: float3 texX = 2.0f*f3tex2D( SrcTex, I.tcoords.xy+shiftX )-1.0f;
0029: float3 texZ = 2.0f*f3tex2D( SrcTex, I.tcoords.xy+shiftZ )-1.0f;
0030: float3 tex3 = 2.0f*f3tex2D( SrcTex, I.tcoords.xy+shift3 )-1.0f;
0031: float3 tex4 = 2.0f*f3tex2D( SrcTex, I.tcoords.xy+shift4 )-1.0f;
0032:
0033: float3 du = {1,0.5f*(texX.x-tex3.x),0};
0034: float3 dv = {0,0.5f*(texZ.x-tex4.x),1};
0035: O.col.xyz = 0.5f*normalize(cross(du, dv))+0.5f;
0036:
0037: return O;
0038: }
0039: