gl-shader | WebGL shader wrapper | Graphics library

 by   stackgl JavaScript Version: 4.2.1 License: MIT

kandi X-RAY | gl-shader Summary

kandi X-RAY | gl-shader Summary

gl-shader is a JavaScript library typically used in User Interface, Graphics, WebGL applications. gl-shader has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can install using 'npm i gl-shader' or download it from GitHub, npm.

WebGL shader wrapper
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              gl-shader has a low active ecosystem.
              It has 108 star(s) with 21 fork(s). There are 11 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 5 open issues and 6 have been closed. On average issues are closed in 2 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of gl-shader is 4.2.1

            kandi-Quality Quality

              gl-shader has 0 bugs and 0 code smells.

            kandi-Security Security

              gl-shader has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              gl-shader code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              gl-shader is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              gl-shader releases are not available. You will need to build from source code and install.
              Deployable package is available in npm.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gl-shader
            Get all kandi verified functions for this library.

            gl-shader Key Features

            No Key Features are available at this moment for gl-shader.

            gl-shader Examples and Code Snippets

            No Code Snippets are available at this moment for gl-shader.

            Community Discussions

            QUESTION

            gl-shader: Error compiling shader: Compile failed. ERROR: 0:9: 'assign' : cannot convert from '4-component vector
            Asked 2021-May-02 at 15:32

            I am trying to write a shader when I can pass both image saturation value like this https://gl-react-cookbook.surge.sh/saturation?menu=true and image colorscaling like this https://gl-react-cookbook.surge.sh/colorscale?menu=true in react native for that I am using opengl in react native. As from the example, I can run both the image saturation and image colorScaling separately but I don't know how to add them together. I am new to opengl i tried reading the docs but could not find any help. Please help me to figure out how to get both the functionality. Here is my Code.

            Error I am getting

            ...

            ANSWER

            Answered 2021-May-02 at 15:32

            Just read the error messages you got:

            Source https://stackoverflow.com/questions/67357925

            QUESTION

            Is the GLSL version requirement of this SSDO demo self-conflicting?
            Asked 2020-Jun-20 at 13:16

            I tried to run the SSDO demo code from here but met with several problems that confused me even further after I had spent hours searching for solutions. Nevertheless, now I am almost certain that the problems are with the GLSL version.

            Note that:

            • The demo uses glew and glut.
            • My environment is Microsoft Visual Studio Community 2019 on Windows 10 pro supported by Parallels Desktop on a 15" MacBook Pro 2018.
            Stage 1

            Before any modifications to the code, I got a bunch of error messages:

            ...

            ANSWER

            Answered 2020-Jun-20 at 13:16
            1. Is the demo correct at all?

            No. Let's look at some of the details here:

            stage 1

            Apparently I searched for texelFetch2D, but garnered only very limited information. Yet based on the information, I tentatively assumed that replacing it with texelFetch would help, which requires a GLSL version no less than 1.30, according to this page.

            texelFetch2D does not exist in standard GLSL. It is a function introduced in the GL_EXT_gpu_shader4 extension, which never went directly into core GL functionality. Conceptually, texelFetch is the correct replacement when using GLSL 130 or above.

            Altohugh this shader might compile on some implementations, it is not backed up by any standard, and shouldn't be assumed to work.

            Interestingly, in SSBO.frag, the demo correctly requests that extension, so that code should work on an implementation supporting that extension:

            Source https://stackoverflow.com/questions/62485782

            QUESTION

            How do I convert OpenGLES shaders to Metal compatible ones?
            Asked 2019-Dec-31 at 20:04

            I have a project which uses about 2 dozen .vsh and .fsh files to draw 2D tiles using OpenGLES. Since that is deprecated, I want to convert my project to Metal. My head is now swimming with vocabulary and techniques involved in both systems - graphics is not my forte.

            Can I use OpenGLES to compile the .vsh/.fsh files, and then save them in a metal-compatible format? The goal would be to then use the saved information in a metal-centric world and remove all the OpenGLES code from the project. I've spent a few days on this already, and yet I don't understand the processes enough to fully attempt the transition to Metal. Any/all help is appreciated.

            I saw this: "On devices that support it, the GLSL code you provide to SKShader is automatically converted to Metal shading language and run on a Metal renderer", which leads me to believe there is a way to get this done. I just don't know where to begin. OpenGL ES deprecated in iOS 12 and SKShader

            I have seen this: Convert OpenGL shader to Metal (Swift) to be used in CIFilter, and if it answers my question, I don't understand how.

            I don't think this answers it either: OpenGL ES and OpenGL compatible shaders

            Answers/techniques can use either Objective-C or Swift - the existing code is Objective-C, the rest of the project has been converted to Swift 5.

            ...

            ANSWER

            Answered 2019-Dec-31 at 19:52

            There are many ways to do what you want:

            1) You can use MoltenGL to seamlessly convert your GLSL shaders to MSL.

            2) You can use open-source shader cross-compilers like: krafix, pmfx-shader, etc.

            I would like to point out that based on my experience it would be better in terms of performance that you try to rewrite the shaders yourself.

            Source https://stackoverflow.com/questions/59547620

            QUESTION

            Textures have a black color regardless of the data I put in them
            Asked 2019-Sep-01 at 18:50

            I tryed to put data in the fragment shader to color 2 triangles through textures, but the color given is black (maybe default?), not green or red as expected.

            The source from where I tryed to do that is https://webglfundamentals.org/webgl/lessons/webgl-shaders-and-glsl.html#textures-in-fragment-shaders. I put everything from there in my source and I thought that if I put a green pixel with a red pixel in my texture, then it needs to have a different color than black, but was black.

            That's the fragment shader:

            ...

            ANSWER

            Answered 2019-Sep-01 at 18:50

            You've to set the texture minifying function to a "non mipmap" filter, else the texture is not mipmap complete. e.g.:

            Source https://stackoverflow.com/questions/57743667

            QUESTION

            Updating WebGL Textures in WebAssembly from HTMLVideoElement
            Asked 2019-May-21 at 12:42

            I have a project* in which I play two videos, run a simple shader that shows edges and blends them, and display the result in a canvas. The project is based on this tutorial. The goal I try to achieve is to understand whether running on JS and WebAssembly is faster than just WebGL work in JS, but at the moment I'm switching between JS and WebAssembly on every frame, which seems to be very expensive.

            In every frame the code copies the content of each HTMLVideoElement into a WebGL texture in JS:

            ...

            ANSWER

            Answered 2019-May-21 at 12:42

            I found that compiling to Asm.JS instead of WASM removes the cost of the context switches, thus fixing my issue. It's not a perfect solution, but it still provides better performance than JS.

            Source https://stackoverflow.com/questions/55123070

            QUESTION

            How to use lots of textures for computation in WebGL
            Asked 2019-Mar-15 at 04:49

            Just focusing on the uniforms/attributes/varyings for a single vertex/fragment shader pair, I'm wondering how you might model the following system using textures. Focusing on 2D.

            • position: The current object's position.
            • translation: The objects proposed next position based on some CPU calculations up front.
            • velocity: The objects velocity.
            • rotation: The objects next rotation.
            • forces (like gravity or collision): The object's summed forces acting on it in each direction.
            • temperature: The object's temperature.
            • mass/density: The object's mass/density.
            • curvature: Moving along a predefined curve (like easing).

            At first I wanted to do this:

            ...

            ANSWER

            Answered 2019-Mar-15 at 02:25

            The question you linked is not about too many attributes but too many varyings, 99.9% of WebGL implementations support up to 16 attributes which is not only on par with the maximum number of texture units supported on most platforms but should be fine assuming that you don't need to transfer all that data from the vertex to the fragment shader. If you're not doing any larger batching you might just use uniforms to begin with. That said if you, for whatever reason decide to go with textures you'd probably use only one UV coordinate and align all your data textures, otherwise you'd really just have almost doubled your bandwidth requirements for no reason.

            With that out of the way, your dataset itself can be compacted quite a bit. You could store position and rotation as a quaternion(in 2D you could even just use a vec3 with x,y,α) the velocity and torque(which is missing from your original dataset) are really just the delta of the current position and the next one, so you only need to store one of those sets(either velocity/torque or next position/rotation), force seems irrelevant as you'd apply those on the CPU, mass and temperature are scalar values so they'd totally fit into one vec2 along with some other jazz. But the more I try to make sense of it the more immature this seems, you can't really do the simulation on the GPU yet half of your attributes are simulation attributes that are not required for rendering and it feels like you're prematurely optimizing something that isn't even close to existing yet, so word of advice: just build it and see.

            Source https://stackoverflow.com/questions/55174136

            QUESTION

            Passing large array into uniform in WebGL
            Asked 2018-Dec-20 at 01:02

            Wondering if it's possible to pass a large array into a WebGL shader, like this:

            ...

            ANSWER

            Answered 2018-Dec-20 at 01:02

            Most WebGL implementations have a limit of 1024 or less uniform vectors

            In other words huge can't be greater than 1024 vec4s or whatever the limit of your particular GPU is. Also note that based on uniform packing rules specified in the spec that also means the largest float uniform array is also 1024 or whatever the limit of your particular GPU is.

            You can declare arrays

            Source https://stackoverflow.com/questions/50032570

            QUESTION

            OpenGL program won't display any objects?
            Asked 2018-Nov-14 at 06:03

            An OpenGL project can't display any object anymore. I tried to remake everything from scratch but it still doesn't works.

            Main Code

            ...

            ANSWER

            Answered 2018-Nov-14 at 06:03

            In your program the Depth Test (glEnable(GL_DEPTH_TEST)).
            The depth of a fragment is stored in a separate buffer. This buffer has to be cleared too, at the begin of every frame, as you do it with the color buffer. See glClear:

            Source https://stackoverflow.com/questions/53290996

            QUESTION

            Getting OpenGL Shader variables into C++ without writing a custom parser
            Asked 2018-Sep-25 at 14:07

            I couldn't find anything about this so here goes: What I'm trying to do is make a generic game engine, I want to be able to load any 3D object and apply any shader to that model.

            I'm at the point where I need to know where the vertex attributes in the shader are so I can feed them to glVertexAttribPointer, However, glVertexAttribPointer takes as input the location of the attribute. Different shaders could have different locations for the vertices. Is there a way to query the attributes in a shader and store them in a list in c++?

            Post Answer: I've found the following answer that explains it in more detail.

            ...

            ANSWER

            Answered 2018-Sep-25 at 13:23

            You can query active shader attributes by using glGetActiveAttrib. In combination with glGetAttribLocation, you can build up such a lookup table.

            But even with this lookup table, you'd have to use a different VAO for each combination of mesh and shader. I suggest you go the other way round and define which attribute location belongs to which attribute. You can either enforce that with glBindAttribLocation during shader compilation, or you use layout qualifiers (layout(location = ...)) in the shader. Using this, you will be able to use the same VAO with all of your shaders.

            Source https://stackoverflow.com/questions/52499121

            QUESTION

            How to create and use very large palette textures for use in opengl?
            Asked 2018-Jun-20 at 10:58

            Details: I have a glsl fragment shader with a uniform texture, "u_MapTexture" with several thousand colors on it (max of about 10k-15k unique rgb values). I also have a uniform palette texture ("u_paletteTexture") that is 16384 × 1 that I want to use to index the colors on u_MapTexture to. My problem is that no matter what I try mathematically, I can't seem to properly index the colors from the first texture to the palette texture using the RGB values of the passed color. Amy thoughts or ideas as to how I could do this?

            Wasn't sure whether to post this here, on Gamedev SE, or on the Math SE.

            Edit: I guess I might not have added enough information about the problem in, so here are some more details.

            My current idea for the map is to keep an indexed palette of province colors, and to perform a palette-swap operation in my fragment shader (like the one outlined in this SO question: Simulating palette swaps with OpenGL Shaders (in LibGDX)). My shader is pretty much exactly copied from the linked article.

            My problem: finding a way to uniquely index the province map (the original texture) -> province colors (the indexed palette texture).

            At first, I decided that the palette texture would be configured as a (255+255)×(255+255) texture. This would give a large maximum number enough number of countries to choose from that would never in practice be reached.

            I thought you could get the appropriate index of the palette texture of a country's color by getting its index in the texture as so: the index of each country would have been located at that palette texture's (x, y)->(r+g),(g+b)

            I ran some example colors through this simple equation and came across a troubling scenario:

            ...

            ANSWER

            Answered 2018-Jun-19 at 20:54

            Not sure I understand exactly what you want to do.

            First of all, the only way to uniquely map all 8-bit RGB colors to indices is to have 256^3 indices. You can shuffle the bits around to have a non-identity mapping (like here), but you still need that many destination indices.

            If only a subset of all colors is used and you want fewer than 256^3 destination indices (as you seem to describe), some mechanism needs to be put in place to avoid collisions. Unless you have some special properties in the source colors that can be exploited mathematically, this mechanism will require some form of storage (like another texture or an SSBO).

            Now what I don't understand is what you want to map to indices. Do you want to map all possible colors to a unique index? Does everything related to the mapping have to be done exclusively inside the shader? You mention countries and provinces, but I don't quite get how they relate exactly to the mapping you want.

            Source https://stackoverflow.com/questions/50920357

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install gl-shader

            You can install using 'npm i gl-shader' or download it from GitHub, npm.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
            Maven
            Gradle
            CLONE
          • HTTPS

            https://github.com/stackgl/gl-shader.git

          • CLI

            gh repo clone stackgl/gl-shader

          • sshUrl

            git@github.com:stackgl/gl-shader.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link