Colors and Materials
- material is about
- ambient
- specular
- diffuse
- Transparency
- caustics
Light
- AmbientLight //it is
- DiffuseLight //Direction
角度不同,光強不同
Phong Shading - Specular Light //The Direction of Light and the Position of the Viewer
- Why can see in another angle
- Blinn-Phong Reflection
- Gouraud Shading
- Normal
- Vertex Normal
- Surface Normal
- Shadow
- ShadowMapping
- Light Perspective
- Depth test
- Depth Buffer
- shadow factor
Texture
- glGenTextures(n, &m_shadowMap); //分配n個Texture, 并且設(shè)置其Handle
- glBindTexture(GL_TEXTURE_2D, m_shadowMap); //GL_TEXTURE_2D應(yīng)該是設(shè)置變量類型
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, WindowWidth, WindowHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
- GL_DEPTH_COMPONENT表明只有深度屬性
- NULL表示? - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);//設(shè)置Texture的屬性
- glActiveTexture(TextureUnit);//钓株?径密???
數(shù)據(jù)結(jié)構(gòu)
- GLuint VBO;//定義內(nèi)存
- glGenBuffers(1, &VBO);//分配內(nèi)存
- VBO
- Vector
- 內(nèi)存
- 數(shù)據(jù)存儲
Other
- Space枝哄?
- local space
- clip space
- NDC space
- texture space
- depth test
- WVP matrix
DrawCall
- ordered draw
- indexed draw
glDrawArrays(GL_TRIANGLES, 0, 3);
glDrawArray(GL_POINTS, index, count);//GL_POINTS is the type, index is the index to draw, count is how many to draw
glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, 0);//draw elements depending on IBO, GL_TRIANGLE is the image type, GL_UNSIGNED_INT is the elements type, 12 = 3*4 means there are 4 triangles, 0 is the index to draw
Buffer
- Buffer
Vector3f Vertex[1];//define a vertex array
Vertex[0] = [1, 1, 1]//set the value of 0
glGenBuffer(n, &VBO);//generate n buffers and set the handle to buffer
glBindBuffer(GL_ARRAY_BUFFER, VBO)://GL_ARRAY_BUFFER as the type and VBO is the handle
glBufferData(GL_ARRAY_BUFFER, VBO, sizeof(Vertex), Vertex, GL_STATIC_DRAW);//GL_STATIC_DRAW means we will not change the content
glEnableVertexAttribArray(i);//i是給Shader用的,表示接下來的VertexAttribPointer中的值可以被OPENGL使用街图。
glVertexAttribPointer(index, 3, GL_FLOAT, GL_FALSE, stride, 0);//如何處理數(shù)組中的元素,index表示數(shù)組的開頭懒构,3表示每個數(shù)組中向量的長度餐济,GL_FLOAT表示向量中元素的類型,GL_FALSE表示如何是否normalized,stride表示數(shù)組元素之間的偏移量
RenderBuffer
-
FrameBuffer
- Depth Buffer
- Color Buffer
- ways of attachments
- COLOR_ATTACHMENTi
- DEPTH_ATTACHMENT
- DEPTH_STENCIL_ATTACHMENT
- APIS
- glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);//綁定以后所有操作都會進行到這個FrameBuffer上
- 其他參數(shù)有 GL_DRAW_FRAMEBUFFER痴脾,GL_READ_FRAMEBUFFER,
+ glBindFramebuffer(GL_FRAMEBUFFER, 0); //設(shè)置為默認屏幕緩沖區(qū)
VertexBuffer
Mipmapping
一個Sphere的著色
UV_mapping
Texturing a Sphere
GLSL Programming/GLUT/Textured Spheres
Unfolding the Earth: Myriahedral Projections
Spherical Mapping with Normals
ShadowMapping
DepthTest
Learn CubeMap
描述
- 有6個texture
- 每個有mipmap
- 大多數(shù)情況下颤介,是用來做反射的
- it is an environment map
資料
- Cubemap_Texture
- Cubemap Learn OPENGL -- GOOD
- OpenGL Cube Map Texturing - by nvidia
Learn HeightField
資料
Cube
- 分解
- mipmap
- Sampler
- Array textures
- layer-faces.
- layer
- Layered Rendering
- environment map
問題
- 如何使用
- 與普通
Texture
的區(qū)別
Learn Texture
description
分解
- genTexture
- glBindTexture
- glActiveTexture
- glTexParameterf
- glTexImage2D
- TextureCoordinates
- Sampler
資料
Questions
- uv值的起點坐標是
Learn Ray marching
Descriptions
-
優(yōu)點
- 首先是它完美的解決了基于頂點的建模方法中透明物體的問題
- 其次是它渲染『無限』的物體或場景時不會造成任何存儲開銷
缺點
不夠直觀
需要用到許多數(shù)學(xué)計算
這是一類技術(shù),一個框架
利用射線一步一步進行
可以用作Blending
Ray marching and distance fields provide an efficient method of rendering mathematical surfaces, such as constructive solid geometry, or more complex shapes that cannot be easily determined, such as recursive shapes and fractals.
Dependencies
subsurface scattering.
raytracing
volumetric translucency
raycasting
distance functions
Distance-aided ray marching
volumetric rendering
normalize
read glsl code
References
Rendering Worlds with Two Triangles with raytracing on the GPU in 4096 bytes - a pdf
DEMO
https://github.com/kevinroast/webglshaders - very niubi
Exercises
Questions
Learn GL variables
- Built-in Variable
- uniform
- 是在一次render過程中不變的
- attribute
- 頂點的屬性
- 只能在Vertex.glsl中
- varying
- 在fragment和vertex之間傳輸
WEBGL retina
var devicePixelRatio = window.devicePixelRatio || 1; // Evaluates to 2 if Retina
renderer.setSize( canvasWidth/devicePixelRatio, canvasHeight/devicePixelRatio);
renderer.setClearColorHex( 0xffffff, 1.0 );
Learn GL expressions
- 參考
- if else