Simple Cube Mapping on ARB_fragment_program

I am trying to implement Simple Cube Mapping with ARB_fragment_program (not GLSL and not Cg).
I dont know ARB_fragment_program very good. And this does not work:


OUTPUT output = result.color;

TEMP base;
TEX base, fragment.texcoord[0], texture[0], CUBE;
MOV output, base;


Any Idea? Thank you.


Can you be more specific about what is wrong? What do you see on the screen with this program? Have you tried

MOV result.color.a, 1.0;

to make sure that your color is opaque?

i try your code but nothing…
the problem is that i can’t see the objects that i render with the shader.
Do you have any example of cubemapping with arb_fragment_program? I can’t find anything…
There must be a simple cube mapping fragment_program on this planet…

My code was massy and i had an mistake a the shader setup.
Now it works with this:

TEX result.color, fragment.texcoord[0], texture[0], CUBE;

dut I still have the problem. The problem is the same with the problem you have when you do cubemapping with the fixed pipeline without enabling the texgens.
How I will enable the texgens with the ARB_fragment_program?
thank you!

If you read the spec for ARB_fragment_program, you will note that TexGen is not available when a fragment program is enabled. It is up to you to write the appropriate code to generate the texture coordinates you want.

TexGen is vertex shading functionality. It’s overridden by a vertex shader, not by a fragment shader. It should work fine with just a fragment program. I quickly checked the spec and didn’t find anything saying otherwise.

Humus you are right! I enable the auto tex toord generation and it works! But now i have one more problem. when I rotate the camera the cubemap rotates also! I mean… if I am over the cubemapped water and i start rotate the camera on the y-axis (looking left/right) I always have infrond the same cube map face. Maybe Need tou play with the texture matrix inside the vertex shader? But I dont know how :frowning: some one can help me?

ok… I find the Doom3 Cube mapping shader:
I use it And seems to work. But I have a other problem now…
I have a Sphere (auxSolidSphere() :wink:
I aply the cube map on it and its ok. But If I try to make it transpert enabling the GL_BLEND
I get this strange error/artifact:

I have tried all the Blend Funcs. All have this problem.

AnyIdea what is wrong? I guess not the Doom3 shader :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue:

Turn on backface culling. Problem is order of triangle rendering. If you render backfaces too, then if backfaces are rendered before frontfaces it will modify framebuffer and frontfaces will modify too. But if you render frontfaces first it will update depth buffer and backfaces will not be rendered.

In case of sphere, depending on camera position, sometimes backfaces will be rendred first and produce rendering errors.


well… think I found it… A glEnable(GL_CULL_FACE) fix the problem… :wink:

@Humus: you’re right, assuming per-vertex cube map coordinates are good enough. If not, then generating the appropriate reflection vector per pixel is fairly efficient, and doesn’t need a normalize.

Well, when someone refers to TexGen I take that as a call to glTexGen(). True though that reflection vectors are better computed in the fragment shader since it’s not a linear property.