Hot answers tagged

11 votes

Performance degrading when resolution increases for a 4k screen

One way to limit the resolution of your game is to have your camera render to a RenderTexture. You can create a RenderTexture in script to match the current aspect ratio of your window/screen, or even ...
user avatar
  • 115k
10 votes
Accepted

Noisy edges, smoothing out edges between faces via fragment shader

Other answers here suggest using a texture. Here's a technique that doesn't use textures. You want the boundaries between hexagons to be interesting. It's easier to make interesting boundaries when ...
user avatar
  • 5,886
10 votes

Difference between "buffer" and "array" in OpenGL?

A Vertex Array Object (VAO) is an object which contains one or more Vertex Buffer Objects and is designed to store the information for a complete rendered object. (pulled from khronos) Each ...
user avatar
  • 29.1k
8 votes
Accepted

lookAt with orthographic camera (gl-matrix)

When I use the identity view matrix, I can see my model, but when I use LookAt, it is not visible. How can I see my model using ...
user avatar
  • 8,964
7 votes
Accepted

Difference between "buffer" and "array" in OpenGL?

The naming of Vertex Array Object is somewhat unfortunate. There's three different things that appear (used to appear) in/with/around your application, and which are (have been, historically) named ...
user avatar
  • 1,364
6 votes
Accepted

File saved to IndexedDB lost unless we change scenes

D'oh! This is covered in the WebGL troubleshooting documentation (which did not come up in my web search results for 'Unity IndexedDB'). Unity does not flush changes to IndexedDB immediately when you ...
user avatar
  • 3,565
5 votes
Accepted

Low quality bilinear sampling in WebGL/OpenGL/DirectX

As luck would have it Iñigo Quilez wrote an article about this which popped up in my Facebook feed this morning. Hardware texture intepolation is fast and convenient. It is bilinear (plus ...
user avatar
  • 115k
5 votes
Accepted

2D Websocket WebGL game

1: Should the client wait for confirmation before moving the player? Websockets use the TCP protocol, which can have very irregular latencies from time to time (which is usually why UDP is ...
user avatar
  • 112k
5 votes

Performance degrading when resolution increases for a 4k screen

The text & button size issue can be addressed by changing the Canvas Scaler component on the canvas to a mode other than Constant Pixel Size: In Scale With Screen Size mode, you set a reference ...
user avatar
5 votes

Performance degrading when resolution increases for a 4k screen

I know that you tagged the question as unity-webgl, but some people might find this question while developing a desktop game and might find this answer useful: For a desktop game, you can use the ...
user avatar
  • 112k
4 votes

How can I tell a fragment shader to not write a particular pixel?

The discard statement comes in handy. You didn't say too much about your decision path, so I'll offer an example using a simple texture lookup: ...
user avatar
  • 726
4 votes
Accepted

Efficient Dynamic Memory Management

deleteBuffer will delete the buffer in WebGL (and OpenGL) but I'm just curious, is there any reason not to just reuse the same buffer just put new data in it? (eg. have a pool of buffers?)
user avatar
  • 802
4 votes

Difference between "buffer" and "array" in OpenGL?

This terminology is rooted in the history of OpenGL. What's important to remember is that, for most of the GL versions which are relevant here, OpenGL was evolved incrementally and by adding new ...
user avatar
3 votes

10% idle time in WebGL

Idle - is "doing nothing" (that is not bad though). As you run your game with consistent frame rate, in ideal world requestAnimationFrame will do 60 frames a second. Your game logic + rendering might ...
user avatar
3 votes

Which UVs to use when I have more UVs coordinates than vertices Obj

You are using the wrong UV coordinates and yes, it's normal to have more UVs than positions. Consider a cube. A cube has 8 positions but for correct normals it needs either 3 normals per position ...
user avatar
  • 802
3 votes
Accepted

How to generate or smooth really large procedural terrain?

At the radius of the Earth, with the center at the origin, 32-bit floating point offers us about half-metre precision laterally, so that's not enough to position centimetre-level detail. So, our ...
user avatar
  • 115k
3 votes
Accepted

The types of buffers typically used in robust WebGL/OpenGL apps

If you set up an project with your idea, - what you want to archive as a final result. You also need to question yourself, how to structure different data. With the question you asked, everything can ...
user avatar
  • 56
3 votes
Accepted

How to use 2D textures in OpenGL / WebGL for physics

I can't possibly cover everything, nor do I know every technique... in fact, I am unfamiliar with OpenGL 4.0 and newer. yet, I think I know enough to expand the way you think about this. However, have ...
user avatar
  • 18.9k
2 votes
Accepted

Linking one uniform variable to many shaders

You can make an analogy of a GL shader program to a program running on a desktop PC. It is natural to expect that it should have its own private "memory space" for variables. This is necessary for ...
user avatar
  • 3,027
2 votes

Strange if-else branching behavior in a fragment shader

It's pretty clear that your uniform isn't getting to the shader. As proved by pre-setting lightType manually. My 2nd guess would be precision hints but it looks like you're sending pretty small ...
user avatar
  • 1,901
2 votes
Accepted

What object3D properties are required to make rayCaster.intersectObjects() work?

The properties are dependent on the override of the class that inherits from object which is currently being used. You can see what properties are required by looking at the overridden method that ...
user avatar
2 votes

How can I scale up sprites but maintain visual quality?

Assuming you are using the DOM (not canvas) for your Isometric grid, these ways may be possible: Draw your Images at 10× the highest resolution you display them at, e.g. (1200×1200 for an image being ...
user avatar
2 votes
Accepted

WebGL techniques for normal mapping on morph targets?

You can interpolate tangents just like you would everything else, there should be no problems with that, as long as your mesh (morph target) count is low - I think there was a rather low limit on how ...
user avatar
  • 3,578
2 votes

How are CSS and WebGL coordinates related?

They are not. Webgl coordinates refers to the positions of pixels in a canvas element and CSS describes the position of any HTML element in a page. You have to do math to apply the correct ...
user avatar
2 votes

WebGL (three.js) - rendering object behind camera far plane

Lens flare is always in front of any thing rendered so you may as well just disable the depth test when you draw it as the last thing. A sun/skybox can be drawn first with depth writing disabled. ...
user avatar
2 votes

How can I scale up sprites but maintain visual quality?

You can't. No processing can add quality or resolution to your textures if it wasn't there from the beginning. If you really need better quality, then you must use bigger assets. Then your question ...
user avatar
  • 201
2 votes

WebGL - send part of texture to GPU

I don't think it's possible to specify a source pitch for the buffer in CPU memory like you could with a lower level API. However, you can specify an offset into your pixels using a DataView, so you ...
user avatar
  • 6,576
2 votes

Create a WebGL native plugin

Fixed by changing my C# script: ...
user avatar
2 votes

WebGL color quantization

Unless you have a specific 256 colors palette in mind, you could just use the "8-bit truecolor" as described at 8-bit color Wikipedia page. To do that, you need to map R and G channels onto 8 values (...
user avatar
  • 36

Only top scored, non community-wiki answers of a minimum length are eligible