Giter Club home page Giter Club logo

Comments (3)

greggman avatar greggman commented on August 29, 2024 2

It depends on what you're trying to do. For example if you're trying to generate a histogram or do some GPGPU thing then you probably want pixel coords

The feature is in GLSL using the texelFetch function. You give a sampler, integer pixel coordinates and a mip level

  vec4 color = texelFetch(someUniformSampler, ivec2(pixelX, pixelY), intMipLevel);

from webgl2-fundamentals.

greggman avatar greggman commented on August 29, 2024 2

If you consider textures to be 2D arrays (or 3D arrays for 3D textures) then texelFetch lets you specifically address a single array element where that element contains up to 4 values (vec4, ivec4, uvec4, etc...). You can use texelFetch in either the vertex or fragment shaders.

The only sample on the site that uses texelFetch at the moment is the skinning article

It makes an array of 4 by N matrices in a texture and uses texelFetch to retrieve a matrix based on the index of the bone/joint for that matrix. You can compare it to the WebGL1 skinning article. WebGL1 doesn't have texelFetch so there's a whole section saying how to compute normalized texture coordinates to achieve something similar.

Sorry but there's no really GPGPU articles yet.

You're correct that for the fragment shader the GPU is destination based. It figures out which pixels it needs to draw and then executes the fragment shader asking what color it should make that pixel.

from webgl2-fundamentals.

jacobbogers avatar jacobbogers commented on August 29, 2024

Thanks greggman, you helped me alot)

from webgl2-fundamentals.

Related Issues (20)

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.