opengl - GLSL Partially Overlapping Textures -


i'm trying blend 2 partially overlapping textures in glsl , wondering if i'm misunderstanding concept of multi-texturing. required textures overlap or can have 2 offset textures blend overlap?

i have 2 images similar following (minus grid lines , text): example image

ideally, overlapping sections of image blend nicely final result 1 smooth image combines 2 together. overlapping orange pixels, example, blend or take higher intensity.

i'm new glsl , have been using article glsl shader article uses fragment shader blend textures (fairly standard).

following article, i@m setting each texture so:

gluseprogramobjectarb( m_hprogramobject ); glint nparamobj = glgetuniformlocationarb( m_hprogramobject, pparamname_i ); ... glactivetexture(gl_texture0 + ntextureid_i ); glbindtexture(gl_texture_2d, ntextureid_i); gluniform1iarb( nparamobj, ntextureid_i ); 

i bind each texture , draw triangle strips. textures created as:

glbindtexture( gl_texture_2d, m_ntextureid ); gltexparameteri(gl_texture_2d, gl_texture_wrap_s, gl_clamp); gltexparameteri(gl_texture_2d, gl_texture_wrap_t, gl_clamp); gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_linear); gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_linear);  glpixelstorei(gl_unpack_alignment, 1); glpixelstorei(gl_unpack_row_length, 0); glpixelstorei(gl_unpack_skip_rows, 0); glpixelstorei(gl_unpack_skip_pixels, 0);  glteximage2d(gl_texture_2d, 0, 4, nwidth, nheight, 0, gl_rgba,     gl_unsigned_byte, pbydata); 

does process seem reasonable or misunderstanding concept? tips or advice on how achieve this?

that process seems adequate. advantage of using fragment shader complete control on how textures combined. offset, may want 2 sets of texture coordinates - 1 each image - or generate them implicitly. figuring out want , writing fragment shader difficult bit. unfortunately if want blend many different textures, fragment shader used in way can quite expensive or wont work many textures bound.

your example image doesn't blending has occurred @ - images positioned on each other. in case, it's easier draw separate bits of geometry mapped textures.

blending typically done fixed pipeline blending stage. example using following calls...

one of common configuration alpha blending over operator: glblendfunc(gl_src_alpha, gl_one_minus_src_alpha) in amount blended given alpha value of colour drawing - possibly influenced a component in gl_rgba texture. can further manipulate blend equations if needed. see blending.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -