26

These functions will perform very badly. I suggest using functions that are written with the GPU in mind. Here are mine: vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - ...


16

I've always disliked that way of defining shaders (in a string). I prefer to do mine in a text file and read it in when loading. Defining it in a string is annoying for debugging and it just looks messy to me. It's just so much easier to be able to type it out and see it formatted like it should be, instead of inside a string. I also have a separate class ...


16

The problem with using texture atlases and adjacent texels leaking has to do with the way linear texture filtering works. For any point in the texture that is not sampled exactly at the center of a texel, linear sampling will sample 4 adjacent texels and compute the value at the location you asked as the weighted (based on distance from the sample point) ...


14

A two step check process On the first step, you check the bounding box, and if there is no collision there, then the test is over. If there is collision, you move over to the second pass On the second pass, if you want more precision, and you want a true pixel perfect solution, then you can do just that, a pixel perfect check pass Since your image is a ...


13

You seem to be doing a lot on unnecessary binding/unbinding. If you are using a VAO, then you should only bind the VAO when you set it up and when drawing the geometry. You only bind the VBO/IBO again when you need to update them. After drawing or updating a buffer, you don't necessarily have to unbind it, though it might be a good idea to do so to avoid ...


13

The approach you've described, using locks, would be very inefficient and most likely slower than using a single thread. The other approach of keeping copies of data in each thread would probably work well "speed-wise", but with a prohibitive memory cost and code complexity to keep the copies in sync. There are several alternative approaches to this, one ...


12

Circle collider. Good enough for it I would say unless you're doing something fancy with certain parts being affected by physics or the colliding looking unnatural, and even if you need to split it up into several parts I have one thing to say to you: Don't overcomplicate it. You don't need a full quad tree structure for this. Just have several boxes or ...


11

To understand what's going on, you have to understand the rendering pipeline: Your geometry (the quad) is initially defined in world space, think of this as some global coordinate system. Inside of the vertex shader those are transformed to normalised device coordinates (NDC), a virtual coordinate system defined so, that everything from -1 to 1 will get ...


8

Shader (and thus material) management is a rather tricky problem you run into when your graphics system gets more complex and you notice hard coding every shader would lead into massive code duplication. Here's a few alternative ways to solve it: Small examples where there are only a couple of shaders tend to hard-code them as strings to avoid file handling ...


8

Create a scale matrix with a scale of -1 on the axis you want to mirror.


7

The Solution Hell yeah!!! I'm one happy chap now! :D OK, I finally manage to get Stencil working with texture :) (also learned a number of things along the way, e.g. we can check color.alpha and use discard as a way to remove transparent pixel and the glBlend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) trick becomes obsolete) So the first thing I noticed I ...


7

To complete what Josh said, Convolution Matrix is what you want: Convolution in Gimp Another link What you probably are looking for: Convolution Kernels in OpenGL


7

As you say, the two formulas don't behave the same way mathematically. So if it makes a difference to the visuals, your first priority should be to pick the one that gives you the better-looking result. Both formulas will be a single instruction on the vast majority of GPUs. x * 0.5 + 0.5 can be done with a mad (multiply-add) instruction, and max is a ...


7

You said highp floats are not supported on your hardware, so I assume you're using mediump. The OpenGL ES shading language spec says that mediump has a minimum relative precision of 2^(-10), or 1/1024. So if a and b are two adjacent mediump values, the ratio (b-a)/a can be as large as 1/1024. Unfortunately, if you look at 65.0 and 64.98, the ratio (65.0 - ...


7

vec3 norm = vec3(uViewMatrix * uModelMatrix * aNormal); The normal cannot be transformed like a point, to transform a normal you use the inverse transpose matrix. If you want the fun details of why this is here is a qoute from the OpenGL Red Book that explains it better then I ever will: Mathematically, it's better to think of normal vectors not as ...


6

See the paper in the GPU Gems series treating this subject: http://http.developer.nvidia.com/GPUGems/gpugems_ch01.html What you can do is to adapt that idea (Gerstner waves) and compute the normals for each of your rendered fragment. The way to do that would be to assign a water texture (without too much light information in it, since you're gonna compute ...


6

USE GLES2 AndEngine is a little tricky to get configured properly the first time you try. I recommend installing the version stored at RealMayo's github, which is a stable version. That's a version of GLES2 and yes, it's definitely worthwhile to use GLES2 over GLES1. Many new features were added that make life easier, improve performance, and add great ...


6

Draw calls by themselves are not always the bottleneck, it is what happens between them that is. Generally when you issue a draw call, the command buffer (state changes, data uploads, etc.) is evaluated and the expense of changing many states is actually deferred until this point. For instance, if you issue the same draw call back-to-back the second draw ...


5

CAVEAT: This is from the perspective of desktop OpenGL development; things may be different on mobile platforms. EGL is Khronos's attempt to create a unified official cross-platform standard to replace (or at least abstract around) the platform-specific windowing/context-creation APIs like Windows's WGL, Unix's GLX, and Apple's Core GL. It sounds great in ...


5

Yeah, I would say go with a 4-vertex triangle stripped quad. If you are drawing large numbers of these triangle strips using the same color, and the same set of texture coordinates, you could do 1 of 2 things: 1) Send the 4 vertices for each object and store the color and texcoords in uniforms 2) "Hardware instancing"


5

You are taking a 512x512 image and smooshing it into an area approximately 120x120 pixels. Thus, you should expect that each pixel is about the average of a 5x5 block. You're using linear texture filtering so that would be expected. It might be better to use unscaled images if you're going to reduce the resolution by such a large amount. You can control the ...


5

Yes, it's typical to convert into triangles. When reading the mesh in, it's simple to convert a quad into a triangle. It will depend on the format you're exporting to. For example, the format I use, Blender will export all the vertices, then it will export index information for triangles and quads. So it's a simple matter of arranging the indices to take a ...


5

If you want to permanently change quads to tris in Blender use Ctrl+T in Edit-Mode


5

Programming in GLESSL is a bit different than programming for a normal CPU. Since you're using OpenGLES 2, I will assume you are using GLESSL 1.0. So I will be pulling quotes from its documentation. In general, GLESSL offers you a variety of types as programming aids, with some guarantees regarding their behavior, but leaves the actual low level ...


5

You are asking for a concept of scenes inside one activity. This is as easy as creating an abstract scene or an interface that will have methods like renderMe() and onUpdate(long timeElapsed). Then in your engine or game-loop you simply render the current scene. How do you switch between scenes is upto you. You can have a governing class SceneManager. So how ...


5

Alpha blending in 3D is tricky, simply due to the fact that you're (usually) still rendering the quad (or polygon) to the depth buffer using the depth buffer, even if your visible texture is just a tiny part of that. To achieve proper rendering you'll have to render everything in the correct order, essentially from back to front. If you don't use the ...


5

The general rule of thumb when drawing alpha polys is: 1 - Draw all solid polys first. 2 - Sort back to front if you can. The main reason for this is to ensure that the final colour produced by the blending equation is consistent frame to frame. I often don't bother with this step unless it is something provided by the engine and I can justify the extra ...


5

From what I read from the shaders the light is in world-space and the light calculation is done on the object in part in untransformed object-space. You need to compute your lighting with both light & model in world-space or both in camera space. Whenever moving the camera messes up the lighting it means some of the data is calculated in a different ...


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