8

You can achieve the effect you are looking for by setting the color value to non-pure red. In the picture below I have drawn a circle with additive blending multiple times with small offsets. On the left the color is pure red (255, 0, 0) and on the right it is (255, 20, 5). From these you can calculate that to get full yellow, you need 255/20=13 overlapping ...


5

With the introduction of programmable blending units, the intuitive meaning of alpha being a measure of opaqueness doesn't always hold. In the two-operand blend you have two contributing fragments: the source (what you're blending, the new fragment), the destination (what already exists in the spot you're blending to). You have two independent blending ...


5

In your first example (glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)), you're telling it to blend colors based on the alpha of the image which gets drawn on top (the "Foreground" one). So when you're blending 50% between the foreground color (38,50,168) and the background color (38,50,168) in the bottom left corner of the image, you unsurprisingly get ...


5

Missed mentioning that my intention is for clusters of point sprites with the same pigment (red) to additive blend to yellow and white. That right there is indicative of your problem. You cannot take a color value of (0.25, 0, 0), and add it to itself and get anything besides more red. It will not magically become yellow, then white. It will always be red, ...


3

Lets look at what your blend setup is actually doing: PDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); PDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE); This means that your colors are calculated by: ScreenPixel = OldPixel + NewPixel * NewPixel.a So expanding your blend sequence gives you: color += texture1 * texture1.a; color += ...


3

To build upon Sean's answer, you don't need to make a separate FBO in order to render the effect you're looking for. Unfortunately, you cannot do it in a single pass because you're asking for two different blending operations for the pixels depending on whether or not your orange triangle is overlapping the light blue one. Fortunately, this is an excellent ...


3

Turning Sam's comment into an answer, you need to do all your rending in two passes. For your first pass, draw only the foreground objects into an off-screen buffer/FBO. If you're using multiplicative blending you might get your desired effect with a white background; with additive blending, you may want a black background. Remember to clear to and update ...


3

One way that this can be done is to divide your materials into layer slots. As one example, REDengine 3, powering the Witcher 3, uses a background layer and an overlay layer for its terrain materials. You can store your material data in control map textures as in the case above, or in your vertex data. Either way, you end up storing the identity of the ...


3

Background OpenGL blend funcs are just a means of specifying a mathematical formula as follows: src: the output from your fragment shader. dst: the colour in the framebuffer. sfactor: multiply src by this. dfactor: multiply dst by this. And add the two results together. (As a simplifying assumption I'm ignoring blend equation, blend func separate and ...


2

Well, your glBlendFunc(GL_ONE, GL_ONE) is likely to blame. The 1st argument to glBlendFunc is how much of the source (new pixel) to use. The 2nd arg is how much of the destination (pixel already there in the frame buffer) to use. You said to just add 100% of the source pixel with 100% of the destination pixel. That's probably not how you want to blend ...


2

Depending on the shader language/version you're using, you can use conditionals in your shader program to cover the 100% transparent case explicitly. Alpha testing really seems like it should be like a distinct shader from alpha blending. It doesn't seem like you can use it with premultiplied alpha, since the equations for alpha testing involve a ...


2

One thing you should avoid for sure is to query the uniform locations every frame with glGetUniformLocation. This might be hurting the performance a little bit. Cache the locations in any data structure of your choice or plain variables once the shader program is created. Also you've mentioned that for each light a fullscreen quad is drawn. This is likely ...


2

Have a look at Reoriented Normal Mapping, it will allow you to blend several normal maps on top of each other and give the intuitively expected result. The main idea is to transform the the normal to blend to the local space of the surface your blending on, or in this scenario, the normal mapped space of the surface.


2

On your first pass, you're additively blending your object into the stuff that's already in the render target. Since your object is presumably opaque, you want to make sure the stuff that's in the render target beneath your object is occluded. You could do this by setting your blend mode to glBlendFunc(GL_ONE, GL_ZERO) and rendering the object completely ...


2

It seems that your mask texture is alpha 1.0 everywhere. In order for this to work, your mask should have alpha set 1.0 for "HOLA" and alpha set to zero everywhere else. Hope it helps!


2

It's a simple interpolation. Let's assume that your heights span -1 to 1, 0 is water surface and you have 3 colours: dark green, light green and white. A way to do what you want is to have the following color_from_height function in the pixel or fragment shader (depending on how efficient you want to be). In my shader below I visualize the gradient, but the ...


2

This article seems to imply that the most efficient method is the latter: multiply by alpha, then convert to SRGB. As far as correctness, I realized that if your texture and framebuffer are SRGB, the GPU does SRGB conversion and then blends in linear space. Therefore if you are using SRGB textures and framebuffers, you should premultiply alpha in linear ...


2

It's unspecified. What that means is that the GL implementation is pretty much free to do whatever it wants. It might change nothing, it might reset to the defaults, it might make a best guess, it might do something else entirely different, and which of these it chooses might depend on other state set elsewhere. Also, you can't depend on somebody else's ...


2

There is an inverse kinematic method for blending animation with physics, it basicly tries to keep the same position and rotation of bone structure of another animated object with the ragdoll, after physics applied to the ragdoll it updates the bones in the late update. Link is here: Active Ragdoll But I found another way around for this problem its not ...


1

You can do this with 3ds Max. Create a plane. Subdivide it in to a lot of segments. Select Displace. Select your heightmap. Select Create -> Splines -> Section. Create a bunch of these "sections"; one for every height. Convert all your "sections" to "Editable Splines" Select Create -> Compound Objects -> Terrain. Fur further explanation, here is a YouTube ...


1

Modern hardware often lacks the ability to actually draw quads. If you're using a legacy API like OpenGL, the drivers will generally just emulate quad support by asking the hardware to draw two triangles. With general edge smoothing, you'd get pretty much exactly what you're seeing. Of course, polygon smoothing itself is a legacy artifact of OpenGL's ...


1

After playing around with things, I've decided to use Blender's stencil map feature (which is a reduced sort of splat map). It allows me to blend between two tileable textures on the same surface using a third as a stencil without having to use huge textures. I also had to write a custom shader in unity to have my stencil material display, but that wasn't ...


1

Although it may not be what you are looking for, I generated this to show how to use the stencil buffer to achieve what you want: The "black-shader" could just return (0,0,0,1); but could also sample from a texture (animated gradient, etc.)


1

A couple days of googling, testing, coding and I have it all figured out. 1. Shadows on Sprites.. There is a work around to having sprites cast and receive shadows. This thread in the unity forum has a way to do it with sprites: http://forum.unity3d.com/threads/why-cant-sprites-gameobjects-cast-shadows.215461/ The other way is to create your own sprite ...


1

I think I understand what you are trying to do. You want the sum of all layers' alpha to be 1 so that there the total color is overdrawn. You are on the right track. But your error seems in the way you compute the alphas. Take for example this starting point: 1: 0.7 2: 0.3 3: 0.0 Now you apply 0.5 on layer 3, the result should look something like: 1:...


1

"Ping pong is a technique to alternately use the output of a given rendering pass as input in the next one." (Example: http://www.seas.upenn.edu/~cis565/fbo.htm)


1

Your own idea isn't that far off. However, you'll have to multiply the final color, not the light color alone: final_light = (color1 * factor1 + color2 * factor2) / 2; To elaborate a bit more, both factor1 and factor2 are based on the distance to the light sources, their range, etc. I just picked multiplication over division - in your example, you could ...


1

I think you may not entirely understand how destination blending works. You claim that you set your output to (r*a, g*a, b*a, 0.0) and then use GL_ONE_MINUS_SRC_ALPHA for the destination blend factor. Because source alpha is constant (0.0) in this example, that works out to be equivalent to GL_ONE. Likewise, if you apply GL_ONE, GL_ONE_MINUS_SRC_ALPHA in ...


1

Tuns out that this is not accurate, as it's for a different alpha blend type. I'm going to give this one a shot, primarily since there aren't any answers for you yet. I'm not completely certain that my answer is accurate or complete, but it's going to be too big to supply as a comment, so here we go. The biggest feature you need to preserve is the order-...


1

Check out this link(Archive.org mirror), it should work for you (massive terrain + blended textures). Has a huge demo project size since he uses a big static mesh, but he applies the textures using a shader as well so you can take a peek at his blending algorithm. He also managed to make it seamless with multiple meshes.


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