ThreeJS / WebGL: Pass the function in the shader

I have written a noise function outside of my shader that takes in a 3D coordinate (x,y,z) and outputs some noise value in [0, 1]. I'd like for this function to be available inside my vertex shader, so that I can animate vertex positions using the fu

How to animate mesh in webgl

I'm new in the field WebGL, and I should animate a human face, i have the mesh of polygons, downloaded from https://sketchfab.com/models/4d07eb2030db4406bc7eee971d1d3a97, how do I select the points on the eyes, mouth etc. and move them to create the

Culling lines and points based on & quot; normals & rdquo;

I'm trying to simulate things like glPolygonMode( GL_BACK, GL_LINE) in WebGL. I can draw with mode LINES instead of TRIANGLES, but I can't see how WebGL could automatically determine whether a particular segment is back-facing, because segments don't

Default in WebGL iOS texture rendering

This simple test of WebGL texture rendering using the three.js library: // Canvas dimensions canvasW = Math.floor(0.9*window.innerWidth); canvasH = Math.floor(0.75*canvasW); cAR = canvasW / canvasH; canvasWrapper = document.getElementById('canvasWrap

Wormhole effect: distortion space with opengl

I am looking for a way to do a wormhole effect like this: - https://www.youtube.com/watch?v=WeOBXmLeJWo&feature=youtu.be&t=43s I have already found nice tunnels in the examples, but here it is a little bit more involved. Actually the space appears

Perspective projection showing nothing

I'm trying to follow WebGLFundamentals.org and LearningWebGL tutorials and I reached the projection part. I create my scene something like LearningWebGL Tutorial 01 (with only the square): var canvas; var gl; var shaderProgram; // Vertex Shader var p

How can I prevent firefox from outputting a console error?

Following code checks if the browser is available for webgl or not. function is_webgl_available(){ try { return !!window.WebGLRenderingContext && !!document.createElement('canvas').getContext('experimental-webgl'); } catch(e) { return false; } } I

Encode floating-point data in a RGBA texture

I wrote some WebGL code that is based on floating point textures. But while testing it on a few more devices I found that support for the OES_texture_float extension isn't as widespread as I had thought. So I'm looking for a fallback. I have currentl

OpenGL ES (WebGL) making many small objects

I need to render a lot of small objects (2 - 100 triangles in size) which lies in deep hierarchy and each object has its own matrix. In order to render them I precalculate actual matrix for each object, put objects in a single list and I have two cal

How to apply a texture to a part of a face?

I want to apply a texture to only a specified portion of the face of a cube - not the whole face. I want to do this multiple times to the same face. For example, I want to put texture1.jpg on the top right corner of the face, texture2.jpg on the lowe

Perspective Projection Matrix WebGL

Can someone show me a function in javascript/webGL that will change 3d coordinates into 2d projected perspective coordinates? ThnxHere's a pretty typical perspective matrix function function perspective(fieldOfViewYInRadians, aspect, zNear, zFar, dst

Unform WebGL locations are null

I'm learning WebGL and I'm quite new to Stack Overflow too. So sorry if I do something wrong. My problem is that lighting doesn't quite work. I think I isolated the problem. Some of my uniforms locations are null. Searching for a solution I found out

webcl and webgl will not work at the same time

Hello Stack Overflow users! I've been searching all over with little (actually none) out there about my problem. I try hard not to ask questions that have already been asked but it seems like I'm the first to have this problem. I have installed the W

How many textures can I use in a webgl fragment shader?

Simple question but I can't find the answer in a specification anywhere. I'm probably missing the obvious answer somewhere. How many textures can I use at once in a WebGL Fragment shader? If it's variable, what is a reasonable number to assume for PC

Does Cordova support WebGL on IOS?

I am now using Cordova to port my HTML5/WebGL application to iOS device. However I have trouble enabling the WebGL working on iOS device. Does anybody know how WebGL is supported by Cordova? It would be very helpful if you can share a simple sample t

WebGL extension support on browsers

This may be something as simple as a dumb setting that I have in Chrome or Firefox, but I just don't know where to go to figure out if it is that or if it's something else. The basic thing I am trying to figure out is why extension support is so diff

Create a 3D map for the game fps - Three.js

I would like to create a 3d map like in Counter-Strike games, with Three.js, but I don't know in which format to create it? What tool should I use to create it?Here is a really good example of a 3d map created using three.js canvas renderer: http://w

Using THREE JS, I try to have a rocker for fog in a scene

EDIT: You cannot add FOG after the scene is rendered because it has to do computations with shaders. IF you do it, it will show the machine down because ALL shaders will have to be rerendered. IF you NEED fog, it is better computationally if you rend

Water / mirror surface in WebGL using three JS

I am trying to make a water surface in WebGL using Three.js. I think I will start with just a mirror as I think I know how to add displacement to make basic ripple effects. This is what I know: Reflection is usually made by rendering a vertically (y-

Threejs Using 3ds Max Objects with Textures

I purchased 3d human teeth model from turbosquid in a 3ds scene format. All I want to do is to extract individaul teeth from the file and use them in threejs script to display them on web page. What I did was exported one tooth from 3ds Max in .obj f

Copy the graphic processor texture to the processor

How can I copy a texture from GPU memory to the CPU in WebGL? I am updating the texture using texSubImage2D in runtime. I would like to avoid: storing a copy of a texture on a canvas rendering to texture and call readPixels Is there any other way? Al

THREE.Line with blur

Is there any options for Line with blur or others filters? I use alternative for Line with THREE.Plane with texture but imitate moving with position vector and lookAt is not simple as dynamic line with vertices[0] a vertices[1]. The Line object using

WebGL and rectangular textures (power of two)

WebGL is known to have poor support for NPOT (non-power-of-two) textures. But what about rectangular textures where both width and height are powers of two? Specifically, I'm trying to draw to a rectangular framebuffer as part of a render-to-texture

How to export the SolidWorks file for use in WebGL?

Is there a way to export or convert a SolidWorks file to be used in any way for WebGL?Not sure where you want to go with this, but http://showwebgl.com/ (see http://plopbyte.net/2011/04/showwebgl/ for a brief description) will upload and display mode

Click to zoom WebGL

I need to implement what amounts to a "Google Maps" style zoom effect in WebGL. Specifically I have a simple 2-dimensional scene that is always perpendicular to the camera. When a user clicks on the scene, the camera should zoom to a location th