Tag Info

Hot answers tagged

4

This is a pretty advanced topic. Generally people like to use Boolean Set Operations implemented with a BSP tree for this kind of destruction, which revolves around splitting polygons over planes. Take a look at this paper by Naylor to learn how. This will let you overlay one mesh upon another and perform a subtraction. The results of the subtraction can ...


3

If the final shader outputs the image to the framebuffer, have a look at the glReadPIxels function (This function is often used to create screenshots in games example 1 | example 2) If you wish to get the data from a texture (in case the texture is larger than the screen resolution, this might be a better solution), have a look at the glGetTexImage ...


2

I would implement it as a multipass algorithm, a bit similar to shadow maps. You render the character to a frame buffer, color(RGBA) and depth(Z). Now you simply apply the frame buffer to the regular buffer (with depth). Then you render the watter, you sample from the frame buffer. If the value A=0, you render the watter normally. If A!=0 and Z>=current ...


2

From your original equation a_position.x = a_position.x + amplitude * sin(phase + a_position.x); We'll just be taking at look at the sin portion as this is where this effect comes from sin(phase + a_position.x); Let's look at the sin function over a half of a period for different positions (phase is in degrees) Position 1 - a_position.x = 0 sin(0 + 0) ...


1

There are many ways to handle this kind of logic in a shader: Use dynamic branching: Plain ifs are not that slow on modern hardware. Test and profile it. If it doesn't slow down your application, this is probably the most straightforward and flexible solution. Use shader subroutines: This is a new GLSL feature. It is supposed to be faster than dynamic ...


1

You can use the inbuilt GLSL lessThan() and greaterThan() functions (supported in all GLSL versions). These give two boolean vectors as a result. https://www.opengl.org/sdk/docs/man/html/greaterThan.xhtml http://www.opengl.org/sdk/docs/man4/html/lessThan.xhtml Then, you can use 'equal' (https://www.opengl.org/sdk/docs/man/html/equal.xhtml) on those ...


1

How about: vec3 delta = abs(textureColor - vec3(0.85, 0.85, 0.85)); // Get delta from middle vec3 if (delta.r <= 0.05) && (delta.g <= 0.05) && (delta.b <= 0.05) Performance needs to be profiled, but it's sure shorter to write


1

Answer: Added the vertexIDs in a second uv(set x value to the id) channel in the mesh(from my c# code), and then in the shader I could use the ids as I needed, example: void function(inout appdata_full v) { int vertexID = v.texcoord1[0]; ... }


1

The shader was fine. But when I tried to use other shaders I realized what was wrong. It was the C++ code that was lacking lines (rrr!! This is the reason why I hate shaders! It's so complicated to make a link in your head between every line you write in one file and what must be written in the other for it to be recognized!). In the display function, I ...



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