GLSL shaders acting weird

Started by
25 comments, last by adam17 18 years, 9 months ago
i think u understand it now but ill say it again (ive seen a few ppl trip up on it, including myself)

glUniform1iARB(textureunit_12, 12);

uniform sampler2D textureunit_12;
A/vec4 tex1 = texture2D( textureunit_12, gl_TexCoord[0].st);

activetexture( GL_TEXTURE12 )
glBindTexture( GL_TEXTURE_2D, clouds_texture ); <- the clouds texture will be accessed in line A/

------------
also another IMO clearer way instead of writing gl_TexCoord[0] = is
varying vec2 texcoord;
texcoord = gl_MultiTexCoord0;

btw drop all the ARB's its not become part of opengl2.0
Advertisement
Quote:Original post by Sneftel
For my money, there is exactly ONE text on GLSL worth reading, and that is the Orange Book. It's a little pricey, so see if there's a library somewhere you can borrow it from, but it's worth every penny.

EDIT: Actually, you're GDNet+... look here to get it from Addison-Wesley at a discount.

Seconded. Direct and to the point - one of the best API-focused books I've read.
->zedzeek
i understand everything except for the part about why i wouldnt want to use gl_TexCoord[].
Quote: i understand everything except for the part about why i wouldnt want to use gl_TexCoord[]

just for clarity reasons thats all, nothing major
also since most cards only allow 32 varying floats
going
gl_TexCoord[0] = gl_MultiTexCoord0
will use up 4 of the 32 since even thoiugh usually u only need the .st coords
u can pack texture coords (and other things) together in a single varying

vec4 texccords = vec4(gl_MultiTexCoord0.st, gl_MultiTexCoord1.st ) // dont now if thats correct syntax

btw drop all the ARB's its not become part of opengl2.0 (i meant noW become)
that makes alot of sense. ill keep that in mind when i start doing bigger things like normal mapping and parallax mapping.

as for the ARB stuff i would drop them but everything in my library has ARB attached and that would be way too much work to change. ill just wait until someone changes up the library again.
im in the process now of changing my shader stuff from arb_shader to opengl2.0 shader, the gl2.0 version is way better designed (no objects handles etc)
thats the benifits of the ARB implementing something as an extension first before adding it to the core, it gives the extension a trail period so the final version is better.
normally extensions dont change to much when they get promoted to the core, unfortunatly with shader_objects there are a lot of changes
eg
Old ARB extensions commands New OpenGL 2.0 commands
glAttachObjectARB glAttachShader
glCreateProgramObjectARB glCreateProgram
glCreateShaderObjectARB glCreateShader
glDeleteObjectARB glDeleteShader for shader objects,
glDeleteProgram for program objects
glDetachObjectARB glDetachShader
glGetAttachedObjectsARB glGetAttachedShaders
glGetHandleARB glGetIntegerv(GL_CURRENT_PROGRAM, &retval)
glGetInfoLogARB glGetShaderInfoLog for shader objects,
glGetProgramInfoLog for program objects
glGetObjectParameterfvARB No equivalent
glGetObjectParameterivARB glGetShaderiv for shader objects,
glGetProgramiv for program objects
No equivalent glIsProgram
No equivalent glIsShader
glUseProgramObjectARB glUseProgram
thats not going to solve my problem by changing this stuff right?

heh im lazy so if it doesnt help, i wont change it right now
ok i have scoured what seems like every source that would be of any help like the ogl 2.0 spec, and glsl specs to name a few. has anybody come up with an idea of what could be going wrong?

i found this link [link="http://www.shadertech.com/forums/viewtopic.php?t=2745"]click[/link] but i didnt make a whole lot of sense out of it. it seems like exactly what im doing.

on a side note, is there any reason why my shader should be crashing when i use glGetUniformLocationARB for my alpha variable? when i use it, the model is black. if i comment it, the alpha variable changes as it should.

[Edited by - adam17 on July 1, 2005 1:55:58 AM]
sorry didnt realise youre still having problems
what exactlys going wrong?
can u do a simple shader eg try this

VS
void main(void)
{
gl_Position = ftransform();
}
FS
void main(void)
{
gl_FragColor = vec4( 1.0,0.0,0.0,1.0 );
}

that should draw everything red

once u get that working try this
---- VS ----------
void main(void)
{
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;

}

----- FS ----

uniform vec4 col;

void main(void)
{

gl_FragColor = vec4( texture2D( tex0, gl_TexCoord[0].xy ) );
}
yeah both of those work no problem. whats really weird is i can assign 2 different textures to TU0 and TU1. in the frag shader the second texture unit is always showing TU0.

im doing:
	glActiveTextureARB(GL_TEXTURE0_ARB);	glEnable(GL_TEXTURE_2D);	glBindTexture(GL_TEXTURE_2D, texture[1]);	glActiveTextureARB(GL_TEXTURE1_ARB);	glEnable(GL_TEXTURE_2D);	glBindTexture(GL_TEXTURE_2D, texture[2]);

and this:
	glUniform1iARB(tex0, 0);	glUniform1iARB(tex1, 1);

the textures are different ive done it using the fixed pipeline. what is REALLY bizarre is if i leave the location for the uniform for TU1 commented out i cannot sample TU1 by itself. although i can multiply and add it with no problems. basically TU1 can only be sampled if multiplied or added with TU0

This topic is closed to new replies.

Advertisement