opengl - Read depth values while stencil testing(same texture) -


i know bad idea read/write from/to same texture/location, because result in undefined behaviour. in case, if depth testing disabled , read depth values in shader, ok stencil testing @ same time reading depth values within same texture?

in opinion there should not problems, because i'm not reading stencil buffer values in shader. or, there hardware related problems when texture bound reading in shader , opengl uses stencil testing?

this texture filled depth/stencil values. wan't avoid heavy brdf lighting(directional light) calculations on specific pixels(the sky).

example code:

//contains depth/stencil texture(deferreddepthstenciltextureid). //two fbo's sharing same depth/stencil texture. lightaccumulationfbo->bind();  glenable(gl_stencil_test); glstencilfunc(gl_equal, 1, 0xff); //disable writing stencil buffer, i.e. bits write-protected. glstencilmask(0x00);  gldisable(gl_depth_test); glenable(gl_blend); glblendfunc(gl_one, gl_one); //additive blending. light accumulation.  glactivetexture(gl_texture0); glbindtexture(gl_texture_2d, deferreddepthstenciltextureid); //gl_depth24_stencil8 //bind other textures here...  shader.bind(); //uniforms here... postprocessquad->renderquad(); shader.unbind();  //unbind textures here. ...  gldisable(gl_blend); glenable(gl_depth_test); gldisable(gl_stencil_test);  lightaccumulationfbo->unbind(); 

but in case, if depth testing disabled , read depth values in shader, ok stencil testing @ same time reading depth values within same texture?

no. whether operation defined or not based on images attached fbo , read from. not components of said images. , no, write masking not save undefined behavior.

so unless stencil texture separate depth texture, that's not going work. , luck finding hardware allow separate depth/stencil images.

even gl 4.5/nv/arb_texture_barrier, answer still no. functionality makes exceptions above rule, operations due fragment shader outputs. stencil test operations not fragment shader outputs, don't apply.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -