PDA

View Full Version : GL_TEXTURE_RECTANGLE_NV or TEXTURE_2D



outTony
06-17-2003, 12:31 AM
did anyone tryed GL_TEXTURE_RECTANGLE_NV with texture shader? or TEXTURE_2D with texture shader.

there's only texture shaders demos with cubemaps.

can anybody tell me, where can i find a nice demo (with src of course) with this kind of target textures?

i am trying to make one test with this, but it's not functional. i used nvidia's dot_product_reflect demo as a base

Cab
06-17-2003, 12:50 AM
I've tried them. You can use both of them. For rectangle textures you should notice that they don't support mipmaps, their coordinates are [0,width)x[0,height), ...
I think there are a few examples in nVidia's SDK. One I remember that use both texture modes with nv_texture_shader is the texture_shader_offset_2d example (found at DEMOS\OpenGL\src\texshd_offset_2d in the NVSDK).
(You can donwload the SDK at developer.nvidia.com)

Hope this helps.

outTony
06-17-2003, 04:12 AM
Do you have that test, that u tried? If so, could you send me it?

This is a part of my code, but I donít know, where I have mistake

void Init()
{
nvparse(
"!!RC1.0 \n"
"out.rgb = tex3; \n"
);
nvparse_print_errors(stderr);

signed_normalmap.new_list(GL_COMPILE);
nvparse(
"!!TS1.0 \n"
"texture_2d(); \n"
"dot_product_2d_1of2(tex0); \n"
"dot_product_2d_2of2(tex0); \n"
"texture_2d(); \n"
);
nvparse_print_errors(stderr);
signed_normalmap.end_list();
}

void render()
{
glEnable(GL_TEXTURE_SHADER_NV);
glEnable(GL_REGISTER_COMBINERS_NV);

glActiveTextureARB( GL_TEXTURE0_ARB );
normals_byte.bind();

glActiveTextureARB( GL_TEXTURE3_ARB );
glBindTexture(GL_TEXTURE_2D, decal.GetId());
glEnable(GL_TEXTURE_2D);

signed_normalmap.call_list();


glBegin(GL_QUADS);

// cut--begin
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0,0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0,0);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0,0);
glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 0,0);
glVertex2f(-1,-1);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0,1);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0,1);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0,1);
glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 0,1);
glVertex2f(-1, 1);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1,1);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1,1);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 1,1);
glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 1,1);
glVertex2f( 1, 1);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1,0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1,0);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 1,0);
glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 1,0);
glVertex2f( 1,-1);
// cut--end

glEnd();

glutSwapBuffers();
}

Cab
06-17-2003, 06:57 AM
Originally posted by outTony:
Do you have that test, that u tried? If so, could you send me it?


I can't send you anything. Sorry. But as I told you, you can find some examples in NVIDIA's SDK.

[QUOTE]
nvparse(
"!!TS1.0 \n"
"texture_2d(); \n"
"dot_product_2d_1of2(tex0); \n"
"dot_product_2d_2of2(tex0); \n"
"texture_2d(); \n"
);
[\QUOTE]

Is your texture 0 signed bytes (or hilo), if not you should use:
nvparse(
"!!TS1.0 \n"
"texture_2d(); \n"
"dot_product_2d_1of2(expand(tex0)); \n"
"dot_product_2d_2of2(expand(tex0)); \n"
"texture_2d(); \n"
);

Anyway, I have checked and you are trying to do something similar to the dotproduct_2d you can find in NIVIDIA SDK (DEMOS\OpenGL\src\dot_product_2D). The code is not using nvparse for the texture shaders but you can convert it very easy.

Hope this helps.

Cab
06-17-2003, 07:12 AM
Originally posted by outTony:
Do you have that test, that u tried? If so, could you send me it?

This is a part of my code, but I donít know, where I have mistake

void Init()
{
nvparse(
"!!RC1.0 \n"
"out.rgb = tex3; \n"
);
nvparse_print_errors(stderr);

signed_normalmap.new_list(GL_COMPILE);
nvparse(
"!!TS1.0 \n"
"texture_2d(); \n"
"dot_product_2d_1of2(tex0); \n"
"dot_product_2d_2of2(tex0); \n"
"texture_2d(); \n"
);
nvparse_print_errors(stderr);
signed_normalmap.end_list();
}

void render()
{
glEnable(GL_TEXTURE_SHADER_NV);
glEnable(GL_REGISTER_COMBINERS_NV);

glActiveTextureARB( GL_TEXTURE0_ARB );
normals_byte.bind();

glActiveTextureARB( GL_TEXTURE3_ARB );
glBindTexture(GL_TEXTURE_2D, decal.GetId());
glEnable(GL_TEXTURE_2D);

signed_normalmap.call_list();


glBegin(GL_QUADS);

// cut--begin
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0,0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0,0);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0,0);
glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 0,0);
glVertex2f(-1,-1);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0,1);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0,1);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0,1);
glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 0,1);
glVertex2f(-1, 1);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1,1);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1,1);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 1,1);
glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 1,1);
glVertex2f( 1, 1);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1,0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1,0);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 1,0);
glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 1,0);
glVertex2f( 1,-1);
// cut--end

glEnd();

glutSwapBuffers();
}

I have read your code now. And I have to ask you. Do you understand what dot_product_2d texture shader does?
It uses texcoord1 (s1,t1,r1) to do a dot product with the value of the texture (usually a normal map) from texture0 and texcoord2 (s2,t2,r2) to do a dot product with the same value to obtain s and t respectively to use it with the texture you have in unit 2.
You usually put light vector in texcoord1 and half-light vector in texcoord2 (both in tangent space). If you do the math and put a texture lookup in unit 2 you will have a diffuse and specular bumpaming per pixel.

Hope this helps.

outTony
06-18-2003, 01:36 AM
propably you are right, i dont completly understand it.
light vector helps, but the surface is very rough. propably some vector have to be scaled down.

i am reading now textureshaders.pdf, there's described everyhing but i have to decrypt it 1st.

can anybody tell my. two things?
1, how to scale vector
2, where i have to bind 2d texture to displace it?