WebGL

Hello world example of WebGL parallelism

送分小仙女□ 提交于 2019-12-05 10:56:10
There are many abstractions around WebGL for running parallel processing it seems, e.g.: https://github.com/MaiaVictor/WebMonkeys https://github.com/gpujs/gpu.js https://github.com/turbo/js But I am having a hard time understanding what a simple and complete example of parallelism would look like in plain GLSL code for WebGL. I don't have much experience with WebGL but I understand that there are fragment and vertex shaders and how to load them into a WebGL context from JavaScript. I don't know how to use the shaders or which one is supposed to do the parallel processing. I am wondering if one

Blending with HTML background in WebGL

走远了吗. 提交于 2019-12-05 10:55:34
I am drawing flat colors and textures into WebGL canvas. My colors and textures have varying alpha values and I want them to be blended correctly. I want to have transparent background (they should be blended with HTML content, which is under canvas). In WebGL, I use gl.clearColor(0, 0, 0, 0); gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); gl.enable(gl.BLEND); It works correctly, when HTML background is black. But when I set a JPG pattern as a background of , I draw black triangle (alpha=1) and white triangle (alpha=0.5), I can see the background pattern in place where triangles intersect

Uniform vertex displacement for skinned mesh shader (Animated outline, Three.js)

荒凉一梦 提交于 2019-12-05 10:44:00
I think I've solved implementation of rendering borders/outlines over meshes in Three.js, a technique many games use for highlighting objects/characters. Diablo 1 and 3 for example Here are details and demo of my solution . Now what remains to be done are animated meshes (for characters etc). The problem is, skinned mesh is animated with a vertex shader and I also used a shader to scale (displace) the mesh out along the normals. It might be pretty straight-forward but unfortunately my math skills are pretty much non-existent. The problem So to have the meshes scaled up AND animated in the

two meshes, same texture, different offset?

不打扰是莪最后的温柔 提交于 2019-12-05 09:34:57
Using three.js, I'm working on a web page to display a flip cube (a.k.a. magic cube; see e.g. the video on this page ). On a flip cube, there are typically images that are spread out across multiple pieces of the cube. For example, the boat image shown above is spread across the faces of four cubelets. In three.js terms, there are multiple meshes that need to use the same image for their material texture, but each at a different offset. As far as I understand it, in three.js, offset is a property of a texture , not of a material or a mesh. Therefore, it would appear that you cannot have a

webgl: share texture with other program/shader

浪尽此生 提交于 2019-12-05 08:53:20
问题 i have two shaders that use different vertexarrays and different uniform values but they use the same texture (spritesheet/atlas). is it possible for them to share the same texture (without causing the texture to be sent to the gpu twice)? background: My game has some serious performance issues on my laptop and they seem to be gpu related. My current implementation uses two canvases, one for my background and one for my foreground. they then get composed for the final image (draw onto 3rd

three.js textures working with CanvasRenderer, but show up as black with WebGLRenderer

穿精又带淫゛_ 提交于 2019-12-05 07:48:29
问题 I'm drawing an image to a canvas (using the cityTexture method in http://haldean.github.com/citycanvas/city.js) and then using that as a texture. This works perfectly when I use three.js's CanvasRenderer, but the textures show up as black when using a WebGLRenderer. I'm generating the textures as squares with side lengths of 256. Demo and code is here, with a CanvasRenderer on top, and a WebGLRenderer on the bottom: http://haldean.github.com/citycanvas/3d.html This wouldn't be an issue,

What's the purpose of magic 4 of last row in matrix 4x4 for 3D graphics?

不想你离开。 提交于 2019-12-05 07:03:27
When I read the book about WebGL, I've seen the next matrix description: There is an information about the last row in book ( WebGL Beginner's Guide Beginner's Guide Diego Cantor, Brandon Jones ): The mysterious fourth row The fourth row does not bear any special meaning. Elements m4, m8, m12 are always zero. Element m 16 (the homogeneous coordinate) will always be 1. So, if the last row is always [ 0, 0, 0, 1 ] , I don't understand the next: Why is it necessary be strictly [ 0, 0, 0, 1 ] , why not just all the values be 0 or even some other value? But, if to view the source code of glMatrix

WebGL: Everything is blurry despite using same code

Deadly 提交于 2019-12-05 07:02:54
Just starting out with WebGL, trying to draw some basic lines, not even polygons. I found a few examples, copy-pasted them locally and run them out of Firefox, they look good: sharp, clearly defined edges. Then, I create my own project, refactoring the (bad!) samle code, using RequireJS to load, etc, the sample still works but now my edges/points/lines are all BLURRY. Like some bad antialiasing setting is messing everything up. I tried everything, at first my code looked somewhat different (though functionally the same, IMHO), then I refactored more to make it look almost identical to the

获取gpu

淺唱寂寞╮ 提交于 2019-12-05 04:30:46
//获取gpu function getGpu(){ var gpu = ""; var canvas = document.getElementById("glcanvas"); var gl = canvas.getContext("experimental-webgl"); var dbgRenderInfo = gl.getExtension("WEBGL_debug_renderer_info"); if (dbgRenderInfo != null) { gpu = gl.getParameter(dbgRenderInfo.UNMASKED_RENDERER_WEBGL); }; return gpu; }; getGpu(); 直接调用就可以;可以解决在ie下,WebGL 内容用时过长,无法在 GPU 上呈现。正在临时切换到软件呈现 ,获取到的gpu为mircroce... 来源: https://www.cnblogs.com/fyjz/p/11905965.html

Conflict when using two or more shaders with different number of attributes

a 夏天 提交于 2019-12-05 03:04:09
问题 I'm trying to implement picking(using colors and readPixels) in a WebGL program of mine. When I start my program I create to seperate shaderProgram. One for phong shading and another that simply give shapes a color to be use to detect which shape has been clicked on. The phong shader has 2 attributes. Vertex position and vertex normal. The picking one simply has the position. Now I discovered that for some odd reason, when both of these shaders exist in the same program and I'm using the