draw grid coordinates, ebook
[ Pobierz całość w formacie PDF ]
// (C) 2011 Jan-Willem Krans (janwillem32 <at> hotmail.com)// This file is part of Video pixel shader pack.// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.// This program 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 General Public License for more details.// You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.// draw grid coordinates// This shader can be run as a screen space pixel shader.// If possible, avoid compiling with the software emulation modes (ps_?_sw). Pixel shaders require a lot of processing power to run in real-time software mode.// This shader will draw a grid of pixels, with colors depending on even or odd horizontal and vertical coordinates.float2 c0;float4 main(float2 tex : TEXCOORD0) : COLOR{float2 n = frac((tex*c0-.5)/3.+1/6.);// pixel counterfloat4 c = (n.x < 1/3.)? float4(.5, 0, 0, .5) : (n.x < 2/3.)? float4(0, .5, 0, .5) : float4(0, 0, .5, .5);// add horizontal colorsc += (n.y < 1/3.)? float4(.5, 0, 0, .5) : (n.y < 2/3.)? float4(0, .5, 0, .5) : float4(0, 0, .5, .5);// add vertical colorsreturn c;// output RGB grid}
[ Pobierz całość w formacie PDF ]