Git Product home page Git Product logo

simple-webgl's Introduction

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能提升性能,参考

simple-webgl's People

Contributors

aboutqx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.