Skip to Main Content
WebGL Insights
book

WebGL Insights

by Patrick Cozzi
August 2015
Intermediate to advanced content levelIntermediate to advanced
416 pages
16h 58m
English
A K Peters/CRC Press
Content preview from WebGL Insights
28918.11 Texture MIP Level Selection
18.11 Texture MIP Level Selection
If we do not choose an appropriate texture MIP level selection in the vertex shader, the
terrain may look odd and exhibit more visible morph transitions due to aliasing. At the
current setting, the innermost grid matches the resolution of the texture. We will use a
MIP factor that matches the grids closely.
Listing 18.10 Calculating the MIP level.
float getMiplevel(vec2 position, float texelSize){
float dist = max(abs(position.x), abs(position.y));
float cellSize = startGridScale/(gridSize*2.0);
float correction = log2(cellSize/texelSize);
float distanceLevel = max(0.0,
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning HTML5 Game Programming: Build Online Games with Canvas, SVG, and WebGL

Learning HTML5 Game Programming: Build Online Games with Canvas, SVG, and WebGL

James L. Williams

Publisher Resources

ISBN: 9781498716079