aboutqx / simple-webgl

simple webgl exp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Webgl Source for debug error

https://chromium.googlesource.com/chromium/blink/+/master/Source/modules/webgl

https://dxr.mozilla.org/mozilla-central/source/dom/canvas/WebGLContextFramebufferOperations.cpp

pbr

hdr

hdr 设置float texture filter为linear必须启用extension

    gl.getExtension('OES_texture_float')
    gl.getExtension('OES_texture_float_linear')

exposure(曝光)

As we said before HDR images have a lot more information in both the lower and the higher range of pixel brightness values. That allows us to change the exposure just like in a real camera.

    ...
    gl_FragColor.rgb = texture2D(uEnvMap, envMapEquirect(reflectionWorld)).rgb;

    gl_FragColor.rgb *= uExposure;

    if (uCorrectGamma) {
        gl_FragColor.rgb = toGamma(gl_FragColor.rgb);
    }
    ...

webgl2(opengl es3.0)

First off, rendering to floating point requires an extension in WebGL2, EXT_color_buffer_float.

You can see in the table here copied from the spec section 3.8.3.2 that floating point textures are not renderable in WebGL2 by default.

glTexImage2D internal format,format,type combinations

From stackoverflow

Example renderable(can be attach to a framebuffer)

    gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, gl.RGBA32F, 512, 512, 0, gl.RGBA, gl.FLOAT, null)

Depth texture is avaliable,while webgl1 need WEBGL_depth_texture extension.

"The problem with this is that depthBuffer cannot be used as a texture. RenderBuffers do not provide a mechanism for reading back the values written into them, and as such while WebGL would utilize the buffer to correctly depth-test the scene the information stored within was effectively "lost"." toji link

pbr work flow

使用cmft生成radiance.dds时,须将mipmap调到最大(log2(size)),否则生成的数据会有空数据,造成报错 texImage2D: ArrayBufferView not big enough for request.

生成radiance格式为cubemap, dds rgba32

iiradiance格式可为faces list, hdr rgbe,尺寸可以小一点,实时filter iiradiance别忘记设置为小尺寸,例如32x32,否则会有性能问题,出现webgl context lost。

DistributionGGX里的最后除以的max(denom, 0.001)最好直接改成denom,这样才有锐利(sharp)的点光源效果

deferred shading

使用blitFramebuffer从framebuffer中copy深度到屏幕framebuffer时,需要depth internal format匹配 屏幕的时DEPTH24_STENCIL8 stackoverflow

skeletal animation

gltf格式有定义动画的json,内容是float32array的bin数据文件,能直接被copy到gpu,其他是图片,能加快解析速度 引擎无关的gltf-loader 使用WebAssembly能提升性能,参考

About

simple webgl exp


Languages

Language:JavaScript 74.2%Language:GLSL 23.0%Language:HTML 2.6%Language:SCSS 0.2%