Sign in to follow this  
AndyMills

OpenGL Multitexturing using ONLY the Shader

Recommended Posts

Hi All I'm trying to do some multitexturing in a Win32 OpenGL app, but I don't want to use the built in OpenGL functions to do it as it means including the glext header and registering all of the multitexture functions etc. (also, I'm trying to get used to using shaders more). I have a terrain which has a texture which covers the whole terrain without repeating, and a repeating detail map, so both textures have different sets of texture coordinates. Is it possible to generate the second set of texture coordinates within the shader? Also, what is the best way to combine the textures? I don't mind doing this in either GLSL or CG. Hope that makes enough sense! Thanks! -Andy

Share this post


Link to post
Share on other sites
You can send both sets of texcoords to the shader through Vertex Attributes, so there's no reason why you'd have to generate it in the shader (unless it is a really simple calculation, but I'm assuming the texcoords are independent). If you want to generate them in the shader you certainly can do that also.

To combine you just bind two samplers for the shader, sample both texels, and combine them any way you want (mix, add, multiply, etc). Depends on what kind of detail texture you have.

I'm not sure if this answers your question, if you have more specific question feel free to ask.

Share this post


Link to post
Share on other sites
as huntsman said you still need to use glActiveTexture to bind multiple texture units, if its registering all the gl extention functions thats the problem why not just use glee or glew to manage extensions then you get functionality of all extensions and you dont have to bother messing around doing it manually.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this