View Full Version : Simple Cube Mapping on ARB_fragment_program
10-09-2004, 02:23 AM
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;
TEX base, fragment.texcoord, texture, CUBE;
MOV output, base;
Any Idea? Thank you.
10-09-2004, 07:39 AM
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?
10-15-2004, 11:19 AM
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...
10-15-2004, 10:34 PM
My code was massy and i had an mistake a the shader setup.
Now it works with this:
TEX result.color, fragment.texcoord, texture, 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?
10-16-2004, 06:27 AM
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.
10-16-2004, 07:44 PM
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.
10-16-2004, 08:58 PM
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 :( some one can help me?
10-17-2004, 03:26 AM
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() ;)
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 :p :p :p
10-17-2004, 05:25 AM
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.
10-17-2004, 05:26 AM
well.. think I found it... A glEnable(GL_CULL_FACE) fix the problem... ;)
10-17-2004, 06:35 AM
@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.
10-19-2004, 03:32 PM
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.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.