Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

BlendMode

in Questions Posts: 105

Hi! I am trying to understand blendMode but I fail. I need to replace pixels independent of their alpha value. So vec4(1,0,0,0.5) that is replaced by vec4(0,1,0,0.8) should output vec4(0,1,0,0.8). I need to know if I can do this using blendMode! Replaced means that geometry is drawn on top of other geometry.

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 8,456

    @MMGames Did you try a forum search. There have been several examples of blendmodes showing the different options and the results. Maybe you can try one of those with your values and find one that does what you want.

  • Posts: 105

    That's what I have done, but they don't do what I want then to do.

  • Posts: 2,020

    What effect are you trying to achieve?

  • Posts: 105

    I'm trying to store the x-value of a texture coordinate in the w-slot without getting the x,y,z-values mixed together with other fragments on the same pixel.

  • IgnatzIgnatz Mod
    Posts: 5,396

    The alpha (w) slot of an image pixel is not reliable because Codea may change it when anti aliasing. You should only use x,y,z to store data accurately.

  • Posts: 2,020

    @Ignatz Is that true even if you turn aliasing off with noSmooth?

    @MMGames what's the end result of this? I'm curious about why you'd want to control texCoords on a per-pixel basis. You can put up to 8 textures in a Shader, so you could have a separate texture for the texCoords.

  • Posts: 105

    It's because I don't want to render the scene three times: depth, normals and colors. (It's a deferred renderer and I can only render to one texture). So I try to render the scene once. I output depth (encoded in x,y,z because of the low precision) to my depthbuffer. Here normals are calculated by the cross product of the neighbour pixels. Color is then stored in the w-slot as a x-coordinate in a color-texture, where for example 0.5=red and 0.25=blue. But it doesn't work because the alpha-value affects x,y,z

Sign In or Register to comment.