简体   繁体   中英

Texture Sampling Alpha

Can someone tell me how can I force alpha to be set to 1 in my sampler?I gather that it would require use of

glSamplerParameteri( arg1, arg2,arg3)

I am not sure what arg2 and arg3 should be .I believe arg1 is sampler name.

See : http://www.opengl.org/sdk/docs/man4/xhtml/glSamplerParameter.xml for how to use glSamplerParameter.

void glSamplerParameteri(GLuint sampler, GLenum pname, GLint param);

Parameters

sampler Specifies the sampler object whose parameter to modify.

pname Specifies the symbolic name of a single-valued sampler parameter. pname can be one of the following: GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, GL_TEXTURE_WRAP_R, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_LOD, GL_TEXTURE_MAX_LOD, GL_TEXTURE_LOD_BIAS GL_TEXTURE_COMPARE_MODE, or GL_TEXTURE_COMPARE_FUNC.

param Specifies the value of pname.


However, I'm not sure of what you're trying to do. Are you just trying to set the alpha value of some pixels in the sampler? If so this is the wrong approach, you should just draw with the alpha values you want (or clear the whole texture with some alpha value).

You cannot do this with a sampler object. What you're looking for is to set the texture's swizzling , which is set on the texture object , not the sampler object.

The specific command would be as follows:

glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);

This requires an implementation that supports OpenGL 3.3 or better, or the ARB_texture_swizzle extension.

If you don't have either of those, then just set it in the shader.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM