www.pudn.com > GPU-KLT-1.0.zip > pyramid_pass2.cg


/*
Copyright (c) 2008 University of North Carolina at Chapel Hill

This file is part of GPU-KLT.

GPU-KLT is free software: you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

GPU-KLT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
details.

You should have received a copy of the GNU Lesser General Public License along
with GPU-KLT. If not, see .
*/

void main(uniform sampler2D src_tex : TEXUNIT0,
                            float4 st0 : TEXCOORD0,
                            float4 st1 : TEXCOORD1,
                    uniform float  lod,
                        out float4 color : COLOR)
{
   // This is the (even) binomial kernel [1 3 3 1]
   float4 f = float4(1.0, 3.0, 3.0, 1.0) / 8.0f;

   float4 g;
#if 1
   g.x = pack_4ubyte(tex2D(src_tex, st0.xy).zyxw);
   g.y = pack_4ubyte(tex2D(src_tex, st0.zw).zyxw);
   g.z = pack_4ubyte(tex2D(src_tex, st1.xy).zyxw);
   g.w = pack_4ubyte(tex2D(src_tex, st1.zw).zyxw);
#else
   // Explicit Lod version
   g.x = pack_4ubyte(tex2Dlod(src_tex, float4(st0.xy, 0, lod)).zyxw);
   g.y = pack_4ubyte(tex2Dlod(src_tex, float4(st0.zw, 0, lod)).zyxw);
   g.z = pack_4ubyte(tex2Dlod(src_tex, float4(st1.xy, 0, lod)).zyxw);
   g.w = pack_4ubyte(tex2Dlod(src_tex, float4(st1.zw, 0, lod)).zyxw);
#endif

   // BGRA for faster transfers.
   color.zyxw = unpack_4ubyte(dot(f, g));
   //color.zyxw = unpack_4ubyte(50*lod + 50);
}