Tag Info

Hot answers tagged

17

I can't tell if that specific image you linked was painted that way originally or not, but the resulting effect looks similar to an edge detection filter. Edge detection post-processing is often done using a Sobel filter implementation. For example, as seen here (a CPU-side implementation). The effect can be achieved in shaders as well (here is an HLSL ...


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

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 ...


12

Yes, it is possible. However, it isn't particularly worthwhile. First, unless you have access to the NV_draw_buffers extension (as the name implies, it is NVIDIA-only. So unless you're running on Tegra, you don't have it), framebuffer objects under ES 2.0 can only render to one image at a time. So to generate your G-buffers, you will need to render your ...


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 ...


9

What you'd need to do to "bend" an object is to apply some appropriate combination of translation/rotation/scaling to only some subset of the vertices of the object in question -- probably weighting that transformation accordingly. Doing this is a pleasant-looking fashion will necessitate using more vertices than may be otherwise strictly necessary to ...


9

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 - ...


9

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) ...


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 ...


7

For the actual math of warping, this can get very complicated, why don't you start here?. I'll now talk about how you can apply this, assuming you've already got the math for how you will do your deformations down. 2 ways: 1) Every frame, visit every vertex in the cylinder model and offset it in some way. 2) Offset the vertices in the vertex shader as ...


7

What you're trying to achieve is basically a subset of the topic of mesh deformation. But since you're a begginer, I'm afraid this type of information might be a bit too strange for now. I'll try to lay down the basic notions though. In order to do this you'll need two things: Your mesh needs to have enough vertices for you to transform. For instance if ...


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


6

The best approach is to change the value of your matrix. It is a parameter that is sent to the shader once per object and costs very little to update; changing all your vertices would mean updating the VBO with a very high bandwith cost.


6

OpenGL and OpenGL ES, despite the similar names, are two different specifications. They may have similarly named functions, but there will be semantic differences between what these functions do. And of course, there will be differences in what features they support. PBOs are not supported on ES (except for ES 3.0, which recently came out but isn't widely ...


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 ...


6

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 ...


5

The main problem is Fillrate. On mobile GPUs, your fill rate is low that you can't do Deferred shading in realtime at native resolution. On iPhone 4 & iPad 1, fillrate is just ridiculous. The only device IOS with good fillrate is iPad 2, but i doubt there is enough... On android, only Tegra devices have the GL_NV_draw_buffers to use MRT but fillrate is ...


5

If all you need to transform is the vertex positions, then I agree that there's no reason not to precompute the entire MVP matrix. If you need to transform things like normal vectors and tangent vectors as well, you'll need more matrices. Probably your normals and tangents should end up in world space, or perhaps view space, so you'll want to transform ...


5

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 ...


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

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 ...


5

You can implement the clipping plane functionality using vertex and fragment shaders and using discard fragment. The other option is described in this paper, where it introduces a technique that modifies the projection matrix so the near and far planes are re-positioned to become a general purpose clipping plane. This way you can implement that without ...


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 ...


4

The book "Guide to Graphics Software Tools" uses JOGL to his examples. There are examples for shaders in GLSL, HLSL and Cg. Edited In http://www.davidcornette.com/glsl/download.html there are examples with source code. http://www.guyford.co.uk/index.php/forum/14-java-jogl/15-jogl-example-glsl-shader-setup has a bit of code.


4

Disable writing to the color buffer and depth buffer: glColorMask(false, false, false, false); glDepthMask(false); Then do your draw as normal (with stencil testing/writing enabled), and restore color/depth writing afterward by repeating those calls with true instead of false. This should automatically short-circuit the pixel shader, I believe.


4

Here are a few thoughts : for your "invisible" background, make sure that your texture has a power of two resolution, and lies in a "drawable-nodpi" resource folder the strange artifact may be caused by dithering (you can use glDisable(GL_DITHER) to prevent this) for your character, it's most likely a problem in your large texture where the pixels around ...


4

You need to normalise all base vectors. The purpose of the cross products is to get a direction, so there is no need to normalise before the cross product, but you need to do it afterwards. You can skip the step if you know the arguments were normalised and orthogonal to each other. The following: const vec_t f((centre-eye).normalised()), ...


4

Calling game and update logic when CADisplayLink fires is the correct way of doing things on iOS. Have you profiled your game to see what is taking a long time and interfering with a smooth frame rate? A nice way of keeping logic updates smooth and decoupled from rendering on iOS is to handle updates when CADisplayLink is called then signal another thread ...


4

This might be tough and I'm not convinced that you will have acceptable performance on android devices at the end, but it seems that at least one game has been released on android using LibRocket. You can write a few wrapper classes in c++ that allow LibRocket to use your own rendering functions. These classes can call back the proper java functions of your ...



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