practical texturing (webgl )

36
Practical Texturing (WebGL) CS559 – Spring 2018 Lecture 23 April 3 2018

Upload: others

Post on 30-Jan-2022

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Practical Texturing (WebGL )

Practical Texturing(WebGL)CS559 – Spring 2018

Lecture 23April 3 2018

Page 2: Practical Texturing (WebGL )

In brief …

Starting with a simple model …

Page 3: Practical Texturing (WebGL )

In brief …

… associate texture coordinates with primitives(can now do procedural textures)

Caveat : Issues with sampling & aliasing

Page 4: Practical Texturing (WebGL )

In brief …

… load an actual image, use mipmap(and figure out how to use it from shaders)

Caveat : Loading files, cross-origin issues

Page 5: Practical Texturing (WebGL )

In brief …

… then combine texture with color

Page 6: Practical Texturing (WebGL )

In brief …

… then combine texture with color, or lighting

Page 7: Practical Texturing (WebGL )

Add-ons …

Repeating/clampingTexture coordinates

Page 8: Practical Texturing (WebGL )

Add-ons …

Multiple textures

Page 9: Practical Texturing (WebGL )

Add-ons …

Bump mapping

More effectsnext week

Page 10: Practical Texturing (WebGL )

Texture coordinatesjsbin.com/pitetahihu/edit

.jsstart(){

initShaders();sendData();draw();

}

Page 11: Practical Texturing (WebGL )

Texture coordinatesjsbin.com/pitetahihu/edit

.jsstart(){

initShaders();sendData();draw();

}

fragmentShader

vertexShader

Page 12: Practical Texturing (WebGL )

Texture coordinatesjsbin.com/pitetahihu/edit

.jsstart(){

initShaders();sendData();draw();

}

Page 13: Practical Texturing (WebGL )

Texture coordinatesjsbin.com/pitetahihu/edit

.jsstart(){

initShaders();sendData();draw();

}

Page 14: Practical Texturing (WebGL )

Aliasingjsbin.com/pitetahihu/edit

Mismatch between:Texture feature size (color tiles)Fragment size

Page 15: Practical Texturing (WebGL )

Texturing with imagesjsbin.com/varefelatu/edit

(texture image)

Page 16: Practical Texturing (WebGL )

The full fixed-function pipeline (1992)Application

Program

GraphicsDriver

VertexProcessing

(TCL)

CommandBuffer(TriangleQueue)

Vertex

Queue

Vertex

Cache

Assembly

TriangleProcessing

Rasterize PixelProcessing

Pixel

Queue PixelTests

FrameBuffer

TextureMemory Rendertotexture

Vertexshading

GeometryShading

PixelShading

8 TMU minimum(default : texture unit 0)

Page 17: Practical Texturing (WebGL )

Texturing with images.jsstart(){

initShaders();sendData();initTextures();draw()

}

jsbin.com/varefelatu/edit

Page 18: Practical Texturing (WebGL )

Texturing with images.jsstart(){

initShaders();sendData();initTextures();draw()

}

jsbin.com/varefelatu/edit

Page 19: Practical Texturing (WebGL )

Texturing with images.jsstart(){

initShaders();sendData();initTextures();draw()

}

jsbin.com/varefelatu/edit

Page 20: Practical Texturing (WebGL )

Texturing with images.jsstart(){

initShaders();sendData();initTextures();draw()

}

jsbin.com/varefelatu/edit

Page 21: Practical Texturing (WebGL )

Texturing with images.jsstart(){

initShaders();sendData();initTextures();draw()

}

Optionsgl.TEXTURE_2Dgl.TEXTURE_CUBE_MAP

jsbin.com/varefelatu/edit

Page 22: Practical Texturing (WebGL )

Texturing with images.jsstart(){

initShaders();sendData();initTextures();draw()

}

Optionsgl.LINEAR_MIPMAP_LINEARgl.LINEAR_MIPMAP_NEARESTgl.NEAREST_MIPMAP_LINEAR

jsbin.com/varefelatu/edit

Page 23: Practical Texturing (WebGL )

Texturing with images

.jsstart(){

initShaders();sendData();initTextures();draw()

}

fragmentShader

attach to TMU #0

jsbin.com/varefelatu/edit

Page 24: Practical Texturing (WebGL )

Texturing with images

.jsstart(){

initShaders();sendData();initTextures();draw()

}

fragmentShader

jsbin.com/varefelatu/edit

Page 25: Practical Texturing (WebGL )

Texturing with images

.jsstart(){

initShaders();sendData();initTextures();draw()

}

fragmentShader

lookup returns vec4

jsbin.com/varefelatu/edit

Page 26: Practical Texturing (WebGL )

Texturing with images(non-mipmap filters)

.jsstart(){

initShaders();sendData();initTextures();draw()

}

Optionsgl.LINEARgl.NEAREST

jsbin.com/varefelatu/edit

Page 27: Practical Texturing (WebGL )

Texturing with images(asynchrony issues)

jsbin.com/qoyudupoqe/edit

.jsstart(){

initShaders();sendData();initTextures();draw()

}

Page 28: Practical Texturing (WebGL )

Texturing with images(cross-origin issues)

jsbin.com/qoyudupoqe/edit

.jsstart(){

initShaders();sendData();initTextures();draw()

}

http://myurl.com/cube.js

Page 29: Practical Texturing (WebGL )

Texturing with images(cross-origin issues)

Cross-origin resource sharing disallowedMore restrictive policy for Canvas drawing than viewing in web page (img tag)Some browsers even don’t recognize “file://” as a shared origin

jsbin.com/varefelatu/edit

Page 30: Practical Texturing (WebGL )

Texturing with images(cross-origin issues)

jsbin.com/qoyudupoqe/edit

Must be CORS-approved

Page 31: Practical Texturing (WebGL )
Page 32: Practical Texturing (WebGL )

Texturing with images(cross-origin issues)

jsbin.com/gekavofimu/edit

Page 33: Practical Texturing (WebGL )
Page 34: Practical Texturing (WebGL )

Texturing and lightingjsbin.com/kecizocura/editjsbin.com/voyexukevi/edit

fragmentShader

Page 35: Practical Texturing (WebGL )

Multiple texturesjsbin.com/popojatufi/edit

fragmentShader

.jsstart(){

initShaders();sendData();initTextures();draw()

}

Page 36: Practical Texturing (WebGL )

Multiple texturesjsbin.com/weluvebodu/edit

.jsstart(){

initShaders();sendData();initTextures();draw()

}