texture2D - The Book of Shaders

文章推薦指數: 80 %
投票人數:10人

The texture2D function returns a texel, i.e. the (color) value of the texture for the given coordinates. The function has one input parameter of the type ... Texture2D Retrievestexelsfromatexture Declaration vec4texture2D(sampler2Dsampler,vec2coord) vec4texture2D(sampler2Dsampler,vec2coord,floatbias) Parameters samplerspecifiesthesamplertowhichthetexturefromwhichtexelswillberetrievedisbound. coordspecifiesthetexturecoordinatesatwhichtexturewillbesampled. biasspecifiesanoptionalbiastobeappliedduringlevel-of-detailcomputation. Description Thetexture2Dfunctionreturnsatexel,i.e.the(color)valueofthetextureforthegivencoordinates.Thefunctionhasoneinputparameterofthetypesampler2Dandoneinputparameterofthetypevec2:sampler,theuniformthetextureisboundto,andcoord,the2-dimensionalcoordinatesofthetexeltolookup. Thereisanoptionalthirdinputparameterofthetypefloat:bias.Aftercalculatingtheappropriatelevelofdetailforatexturewithmipmapsthebiasisaddedbeforetheactualtexturelookupoperationisexecuted. Sidenote:OniOSdevicestexturelookupfunctionalityisonlyavailableinthefragmentshader. SeeAlso textureCube



請為這篇文章評分?