d3d11tex.hlsl revision 92617aeac109481258f0c3863d09c1b8903d438b
13d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman/************************************************************************** 23d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * 33d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * Copyright 2010 Luca Barbieri 43d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * 53d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * Permission is hereby granted, free of charge, to any person obtaining 63d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * a copy of this software and associated documentation files (the 73d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * "Software"), to deal in the Software without restriction, including 83d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * without limitation the rights to use, copy, modify, merge, publish, 93d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * distribute, sublicense, and/or sell copies of the Software, and to 10565cc44bea707ff3865fbeb731e4790dd9874786Dan Gohman * permit persons to whom the Software is furnished to do so, subject to 11565cc44bea707ff3865fbeb731e4790dd9874786Dan Gohman * the following conditions: 123d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * 133d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * The above copyright notice and this permission notice (including the 143d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * next paragraph) shall be included in all copies or substantial 153d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * portions of the Software. 163d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * 173d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18686775deca8b8685eb90801495880e3abdd844c2Chris Lattner * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 193d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 202d7cb069fe101da3971a07900ff583380bcac184Duncan Sands * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 213d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 223d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 233d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 243d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman * 253d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman **************************************************************************/ 263d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman 273d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan GohmanTexture2D tex0; 283d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan GohmanTexture2D tex1; 29c9fe6056e4ce8ffad1ef439fca3318a5faf1c075Kostya Serebryanysampler samp0; 303d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohmansampler samp1; 3114110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne 323d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohmanstruct IA2VS 333d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman{ 343d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman float4 position : POSITION; 353d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman float2 texcoord : TEXCOORD; 363d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman}; 373d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman 383d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohmanstruct VS2PS 393d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman{ 403d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman float4 position : SV_POSITION; 413d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman float2 texcoord : TEXCOORD; 423d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman float4 factors : FACTORS; 43c9fe6056e4ce8ffad1ef439fca3318a5faf1c075Kostya Serebryany}; 443d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman 450b5c4fc2ae3b503c2b1f354bf52b718aa50a6aeeDan GohmanVS2PS vs(IA2VS input) 463d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman{ 472d7cb069fe101da3971a07900ff583380bcac184Duncan Sands VS2PS result; 482d7cb069fe101da3971a07900ff583380bcac184Duncan Sands result.position = input.position; 492d7cb069fe101da3971a07900ff583380bcac184Duncan Sands result.texcoord = input.texcoord * 8; 503d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman result.factors.xy = input.texcoord; 513d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman result.factors.zw = 1 - input.texcoord; 523d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman return result; 533d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman} 54224d75972a836b06e2ca708d1eafdac6f762c487Dan Gohman 553d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohmanfloat4 ps(VS2PS input) : SV_TARGET 56224d75972a836b06e2ca708d1eafdac6f762c487Dan Gohman{ 57224d75972a836b06e2ca708d1eafdac6f762c487Dan Gohman float4 a0 = tex0.Sample(samp0, input.texcoord); 58224d75972a836b06e2ca708d1eafdac6f762c487Dan Gohman float4 a1 = tex0.Sample(samp1, input.texcoord); 59224d75972a836b06e2ca708d1eafdac6f762c487Dan Gohman float4 a = a0 * input.factors.z + a1 * input.factors.x; 60224d75972a836b06e2ca708d1eafdac6f762c487Dan Gohman 613d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman float4 b0 = tex1.Sample(samp0, input.texcoord); 62224d75972a836b06e2ca708d1eafdac6f762c487Dan Gohman float4 b1 = tex1.Sample(samp1, input.texcoord); 633d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman float4 b = b0 * input.factors.z + b1 * input.factors.x; 643d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman 653d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman return a * input.factors.w + b * input.factors.y; 66c9fe6056e4ce8ffad1ef439fca3318a5faf1c075Kostya Serebryany} 670b5c4fc2ae3b503c2b1f354bf52b718aa50a6aeeDan Gohman