texture2D - The Book of Shaders
文章推薦指數: 80 %
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
延伸文章資訊
- 1WebGL编程笔记3:纹理图片texture - Rain Man - 博客园
gl_FragColor = texture2D(u_texture, vec2(outUv.x, outUv.y));. } `; let canvas = document.getEleme...
- 2[WebGL] Texture example by 2d canvas - gists · GitHub
[WebGL] Texture example by 2d canvas. GitHub Gist: instantly share code, notes, and snippets.
- 3Using textures in WebGL - Web APIs | MDN - Mozilla
The textureCoordinates array defines the texture coordinates corresponding to each vertex of each...
- 4WebGL Textures
How textures work in WebGL. ... We use the texture coordinates passed from the vertex shader and ...
- 5webgl textures · WebPlatform Docs
Creating the texture