欢迎来到第壹文秘! | 帮助中心 分享价值,成长自我!
第壹文秘
全部分类
  • 幼儿/小学教育>
  • 中学教育>
  • 高等教育>
  • 研究生考试>
  • 外语学习>
  • 资格/认证考试>
  • 论文>
  • IT计算机>
  • 法律/法学>
  • 建筑/环境>
  • 通信/电子>
  • 医学/心理学>
  • ImageVerifierCode 换一换
    首页 第壹文秘 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    From-ShaderX-2-–-Shader-Programming-Tips-and-Trick.docx

    • 资源ID:865204       资源大小:470.73KB        全文页数:29页
    • 资源格式: DOCX        下载积分:5金币
    快捷下载 游客一键下载
    账号登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    下载资源需要5金币
    邮箱/手机:
    温馨提示:
    快捷下载时,如果您不填写信息,系统将为您自动创建临时账号,适用于临时下载。
    如果您填写信息,用户名和密码都是您填写的【邮箱或者手机号】(系统自动生成),方便查询和重复下载。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    From-ShaderX-2-–-Shader-Programming-Tips-and-Trick.docx

    AdvancedImageProcessingwithDirectX9PixelShadersJasonL.Mitchell,MarwanY.AnsariandEvanHart3DApplicationResearchGroupATIResearchIntroductionWiththeintroductionoftheps_2_0pixelshadermodelinDirectX9.0,weareabletosignificantlyexpandourabilitytouseconsumergraphicshardwaretoperformimageprocessingoperations.Thisisduetothelongerprogramlength,theabilitytosamplemoretimesfromtheinputimage(s)andtheadditionoffloatingpointinternaldatarepresentation.InthefirstShaderXbook,weusedtheps_l_4pixelshadermodelinDirectX8.1toperformbasicimageprocessingtechniquessuchassimpleblurs,edgedetection,transferfunctionsandmorphologicaloperatorsMitchell02.Inthischapter,wewillextendourimageprocessingtoolboxtoincludecolorspaceconversion,abetteredgedetectionfiltercalledtheCannyfilter,separableGaussianandmedianfilters,andareal-timeimplementationoftheFastFourierTransform.ReviewAsshowninouroriginalimageprocessingchapterinthefirstShaderXbook,post-processingof3Dframesisfundamentaltoproducingavarietyofinterestingeffectsingamescenes.ImageprocessingisperformedonaGPUbyusingthesourceimageasatextureanddrawingascreen-alignedquadrilateralintothebackbufferoranothertexture.Apixelshaderisusedtoprocesstheinputimagetoproducethedesiredresultintherendertarget.Figure 1 - Using a pixel shader for image processing by rendering from one image to anotherOutputImageImageprocessingisespeciallypowerfulwhenthecolorofthedestinationpixelistheresultofcomputationsdoneonmultiplepixelsfromthesourceimage.Inthiscase,wesamplethesourceimagemultipletimesandusethepixelshadertocombinethedatafromthemultiplesamples(ortaps)toproduceasingleoutput.ColorSpaceConversionBeforewegetintointerestingmulti-tapfilters,we,llpresentapairofshaderswhichcanbeusedtoconvertbetweenHSVandRGBcolorspaces.Theseshadersperformsomerelativelycomplexoperationstoconvertbetweencolorspaceseventhoughtheyareonlysingle-tapfilters.ForthosewhomaynotbefamiliarwithHSVspace,itisacolorspacewhichisdesignedtobeintuitivetoartistswhothinkofacolor'stint,shadeandtoneSmith78.InterpolationinthiscolorspacecanbemoreaestheticallypleasingthaninterpolationinRGBspace.Additionally,whencomparingcolors,itmaybedesirabletodosoinHSVspace.Forexample,inRGBspace,thecolor100,0,0)isverydifferentfromthecolor0,0,100.However,theirVcomponentsinHSVspaceareequal.Colors,representedbyhue,saturation,valuetriplesaredefinedtoliewithinahexagonalpyramidasshowninFigure2below.Thehueofacolorisrepresentedbyananglebetween0°and360oaroundthecentralaxisofthehexagonalcone.Acolor,ssaturationisthedistancefromthecentral(achromatic)axisanditsvalueisthedistancealongtheaxis.Bothsaturationandvaluearedefinedtobebetween0and1.WehavetranslatedthepseudocodeRGB-to-HSVtransformationfromFoley90totheDirectX9HighLevelShadingLanguage(HLSL)andcompileditfortheps_2_0target.IfyouareunfamiliarwithHLSL,youcanreferbacktotheintroductorychapter"'IntroductiontotheDirectX®9HighLevelShadingLanguage."AsdescribedinSmith79,youcanseethattheRGB_to_HSV()functioninthisshaderfirstdeterminestheminimumandmaximumchannelsoftheinputRGBcolor.ThemaxchanneldeterminesthevalueoftheHSVcolor,orhowfaralongtheachromaticcentralaxisofthehexagonalconetheHSVcolorwillbe.ThesaturationisthencomputedasthedifferencebetweenthemaxandminRGBchannelsdividedbythemax.Hue(theanglearoundthecentralachromaticaxis)isthenafunctionofwhichchannelhadthemaxmagnitudeandthusdeterminedthevalue.float4RGB_to_HSV(float4color)(floatrzg,b,delta;floatColorMaxzcolorMin;floath=0,s=0,v=0;float4hsv=0;r=color0;g=color1;b=color2;ColorMax=max(rzg);ColorMax=max(colorMax,b);colorMin=min(rzg);colorMin=min(colorMin,b);v=colorMax;/thisisvalueif(colorMax!=O)(s=(colorMax-colorMin)/colorMax;if(s!=O)/ifnotachromatic(delta=colorMax-colorMin;if(r=colorMax)h=(g-b)/delta;elseif(g=colorMax)Ih=2.0+(b-r)/delta;else/bismaxIh=4.0+(r-g)/delta;h*=60;if(h<0)(h+=360;hsv0=h/360.0;/movinghtobebetween0and1.hsv1=s;hsv2=v;returnhsv;TheHSV-to-RGBtransformation,alsotranslatedfromFoley901,isshownbelowinHLSL.float4HSV_to_RGB(float4hsv)(float4color=0;floatfzpzq,t;floath,s,v;floatr=0,g=0,b=0;floati;if(hsvl=0)(if(hsv2!=0)(color=hsv2;else(h=hsv.x*360.0;s=hsv.y;v=hsv.z;if(h=360.0)(h=0;)h/=60;i=floor(h);f=h-i;p=v*(1.0-s);q=V*t=V*(1.0-(s(1.0-(s*f);*(1.0-f);if(i=0)(r=v;g=t;b=)P;elseif(i=1)r=q;g=v;b=)P;elseif(i=2)r=P;g=v;b=)t;elseif(i=3)r=P;g=q;b=V;elseifI(i=4)r=t;g=P;b=V;elseif(i=5)r=v;g=P;b=)q;color.r=r;color.g=g;color.b)=b;returncoloOtherColorSpacesItisworthnotingthatRGBandHSVarenottheonlycolorspacesofinterestincomputergraphics.Forexample,theoriginalpaperSmith78whichintroducedHSValsointroducedacolorspac

    注意事项

    本文(From-ShaderX-2-–-Shader-Programming-Tips-and-Trick.docx)为本站会员(p**)主动上传,第壹文秘仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知第壹文秘(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 1wenmi网站版权所有

    经营许可证编号:宁ICP备2022001189号-1

    本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。第壹文秘仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知第壹文秘网,我们立即给予删除!

    收起
    展开