Can i use output attachements to communicate with Object info node?

Sorry to ask, but the documentation is unreadable.
https://github.com/UPBGE/upbge/wiki/Release-notes-version-0.2.5#render-attachments

Render attachment are buffers for use in 2d filter,

They are almost identical to Arbitrary Output Values in blender 3.0 or so

1 Like

yes i saw with that outliner example . And so it’s possible to isolate objects on screen ? Example : with a 2d filter make an object the same color than other one on the screen (so the rendered color) ? There’s still lot of mystery around all those things and there’s no documentation

so we can have

vector3 aov_color = texture(bgl_dataTextures[0],gl_textCord)
float on = clamp( (aov_color[0]+aov_color[1]+aov_color[2])*1000,1,0);
gl_fragColor = mix(color,aov_color,on);

this should mix the render attachment if it has any color at all I think
(I may be a bit rusty on my glsl*)

isn’t this just mixing the input color aov with some undefined color? I made this example , but i was wondering if i can specifically target an object on screen … if it has to go with an attachement, what should i add to my custom 2d filter in the code … because in the first link they seem to say that there’s just this to do

The attachments are readable from any filters defining the sampler uniform “bgl_DataTextures[7]”, this uniform is bind as well as other uniforms in RAS_2DFilter::BindUniforms and the attachments textures in BindTextures/UnbindTextures.

just multiplying some red with each pixel … but let’s say i want to target a specific object on screen

uniform sampler2D bgl_RenderedTexture;

void main(void)
{
  vec4 txc = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
  vec2 texCoord = vec2(gl_TexCoord[0]).st;
  
  vec3 red = vec3(0.999, 0.387, 0.114) ;
  vec3 clr = vec3(txc) ;
  vec3 combo = clr * red ;

  gl_FragColor = vec4( combo , 1.0)  ;   
}

Also, i wonder how i can see the code of “Prewitt” ,“Sobel” and “Laplacian” filters because they target outliners but also inliners and i’m interested to get them.

You can check the shader I made on this thread to see how you can use a render attachment to mask an object.
You can find the default filters in the source code: [blender.git] / source / gameengine / Rasterizer / RAS_OpenGLFilters / (2.79b).

1 Like

thanks, i forgot that answer :cowboy_hat_face: this is very cool. But is it possible to target a specific object in the glsl code itself ?

GLSL filters only deal with colors and depth, that’s the reason render attachments were added, to have more control, trying to approach the deferred shading techniques.