Giter Site home page Giter Site logo

Comments (3)

shrekshao avatar shrekshao commented on September 18, 2024

Do you recommend to try WebCL for this project?

from project5a-webgl-forward-plus-shading-with-gltf.

likangning93 avatar likangning93 commented on September 18, 2024

I think Kai said WebCL is kind of dead. CPU-based light tiling seems like it'll be the best way to go :(

I'm pretty out of the loop here, but we definitely can't do something like, run a fragment shader over all the pixels in the tile gbuffer? Maybe each tile is 128x128 pixels, and we set a cap of 128 * 32 lights (pack each light's attributes into 6 floats or something). Each light could get a unique ID in the light gbuffer. That way, I think each thread would just have to compute which light/tile it is in charge of, compute if it intersects the tile, and write just that value as true/false.

from project5a-webgl-forward-plus-shading-with-gltf.

shrekshao avatar shrekshao commented on September 18, 2024

Sounds like something worth a try.
Actually we only need to store the light idx, no need to pack all attributes.
The process as I understand goes like this:

  • light culling step
    • render a full quad
    • tile size 16 * 16, use a RGBA float texture, so each tile has 1024 entries, our scene can have at most 1024 lights.
    • each thread in this tile handle overlapping test for one light. Write 1.0 for true, 0.0 for false.
  • light accumulation step
    • each thread/pixel find its tile, then loop through the 16 * 16 RGBA buffer, if there's an 1.0, retrieve the light attributes with the index, and shade this pixel

Potential Problems/Limitations:

  • Total light number depends on the tile size. 16x16 -> 1024 lights, 8x8 -> 256 lights. (not a big problem I think)
  • Need one more pass to get min and max depth for each tile frustum planes for light culling (can be ommited if only use left, right, up, front planes for culling, in this case even depth prepass is not needed)
  • At the final shading stage, will the if statement judging if a light is overlapping lead to serious branching issue which results in each thread still parsing through every light in the scene? (One good news is this light overlapping list is same for threads in one tile. But is this tile aligned perfectly with that launched by the shader?)

Overall I think it is worth a try. Thanks Gary. Let me know if there's any misunderstanding

from project5a-webgl-forward-plus-shading-with-gltf.

Related Issues (3)

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.