shadername = glGenFragmentShadersATI(1);glBindFragmentShaderATI(shadername);glBeginFragmentShaderATI();// Pass 1glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI); // LglSampleMapATI(GL_REG_1_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI); // lightColor// reg4 = L.LglColorFragmentOp2ATI(GL_DOT3_ATI, GL_REG_4_ATI, GL_NONE, GL_NONE, GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_2X_BIT_ATI|GL_BIAS_BIT_ATI, GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_2X_BIT_ATI|GL_BIAS_BIT_ATI);// reg3 = lightColor*distAttglColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_3_ATI, GL_NONE, GL_NONE, GL_REG_1_ATI, GL_NONE, GL_NONE, GL_CON_0_ATI, GL_NONE, GL_NONE);// reg1 = L/2 * (1-L.L) + L = normalized( N ) ; still don''t know why btw !glColorFragmentOp3ATI(GL_MAD_ATI, GL_REG_1_ATI, GL_NONE, GL_NONE, GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_BIAS_BIT_ATI, GL_REG_4_ATI, GL_NONE, GL_COMP_BIT_ATI, GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_2X_BIT_ATI|GL_BIAS_BIT_ATI);// reg2 = N.LglColorFragmentOp2ATI(GL_DOT3_ATI, GL_REG_2_ATI, GL_NONE, GL_NONE, GL_REG_1_ATI, GL_NONE, GL_NONE, GL_REG_0_ATI, GL_NONE, GL_2X_BIT_ATI|GL_BIAS_BIT_ATI);// final fragment = (N.L)*lightColor*distAttglColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI, GL_REG_2_ATI, GL_NONE, GL_NONE, GL_REG_3_ATI, GL_NONE, GL_NONE);glEndFragmentShaderATI();
mini demo enties are up... go get em :-)
Hmm this might do the trick:
Except for multexturing, extensions are still beyond me but I do have both vc++.net and the ati 8500 card, if that helps...I can test & compile. BTW, the only NV extensions I get when printing the opengl extension string (so, the only ones I support) is GL_NV_texgen_reflection and GL_NV_BLEND_SQUARE.
ps: I could toy with a simplifed source after Wednesday (have to learn it sooner or later!)
[edited by - Cat_B on February 10, 2003 9:26:02 PM]
ps: I could toy with a simplifed source after Wednesday (have to learn it sooner or later!)
[edited by - Cat_B on February 10, 2003 9:26:02 PM]
vincoof : L*(3-L^2)/2 is from some nVidia doc. It works if vector is not normalized alot. It burns a GCS but you need one texture unit less. in practice it gave me about 15% boost in speed... so it''s worth it... I''ll try to insert code into shader when I get home.. I have an exam in 30 minutes... formal languages & automata theory... blah!
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Cat_B: the NV extensions supported by Radeon8500 are extensions that became common and are not really "NVIDIA-specific". For instance, the NV_blend_square extension became part of the core since OpenGL 1.4
DarkWIng: If you want to insert the fragment shader code, the shader constant may be initialized.
For instance, if register combiners constant is initialized like this :
The equivalent initialization for fragment shader looks like :
Be careful : if you call it between glBeginFragmentShader and glEndFragmentShader, the constant value is local otherwise it is global. In order to be closer to a register combiners style, you may call it outside the glBegin/EndFragmentShader (thus constant is global).
The normalize vector thing is really weird. It''s not a real normalization, but it may work. Doh!
DarkWIng: If you want to insert the fragment shader code, the shader constant may be initialized.
For instance, if register combiners constant is initialized like this :
GLfloat distAtt[4] = { /* ... whatever ... */ };glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, distAtt);
The equivalent initialization for fragment shader looks like :
GLfloat distAtt[4] = { /* ... whatever ... */ };glSetFragmentShaderConstantATI(GL_CON0_ATI, distAtt);
Be careful : if you call it between glBeginFragmentShader and glEndFragmentShader, the constant value is local otherwise it is global. In order to be closer to a register combiners style, you may call it outside the glBegin/EndFragmentShader (thus constant is global).
The normalize vector thing is really weird. It''s not a real normalization, but it may work. Doh!
I''ve finally got my hands on your source code and I''ve seen you''re intensively using display lists. Be careful about shaders. Register combiners can be compiled in a display list but fragment shaders can''t. Though they can be "pre-compiled" once and then you just have to bind it (like textures).
I''ll try to post or mail as many shaders as I can translate (I think all of them can be translated since ATi''s shading language is more flexible than NVIDIA''s).
I''ll try to post or mail as many shaders as I can translate (I think all of them can be translated since ATi''s shading language is more flexible than NVIDIA''s).
I just managed to run my demo on my Dad''s old PII-233/TNT2/Win95
It chugged *badly* at some points, but overall was bearable (given it was written on an Athlon XP1400 and not tested on anything slower
)
...just so as to brag
It chugged *badly* at some points, but overall was bearable (given it was written on an Athlon XP1400 and not tested on anything slower

...just so as to brag

fractoid: this hardware is not gonna be a reference target hopefully 
I remember NeHe saying that demos should run fine on eg PII-450 with TNT2 at the very least.
When you have a processor and a graphics card that is twice as fast (at least) it''s pretty frustrating to limit yourself sometimes
DarkWIng: I forgot that tell that if color sum is enabled (or lighting enabled) you have to "subtract" the secondary color, because unlike register combiners, the fragment shader does not override color sum stage (neither fog btw).
If color sum is enabled, the last line should be replaced by :
Also, if blending is enabled, you surely want to set an alpha component, but I don''t think it''s going to happen (since your register combiner configuration discards the G variable in the final combiner stage) so I won''t post the fragment shader line that does it, but it''s easy of course.

I remember NeHe saying that demos should run fine on eg PII-450 with TNT2 at the very least.
When you have a processor and a graphics card that is twice as fast (at least) it''s pretty frustrating to limit yourself sometimes

DarkWIng: I forgot that tell that if color sum is enabled (or lighting enabled) you have to "subtract" the secondary color, because unlike register combiners, the fragment shader does not override color sum stage (neither fog btw).
If color sum is enabled, the last line should be replaced by :
// final fragment = (N.L)*lightColor*distAtt - secondary// secondary is subtracted because color sum stage is applied next.// Fragment shaders override texturing *only*, unlike register combiners which// override texture environment as well as color sum and fog.glColorFragmentOp2ATI(GL_MAD_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, GL_REG_2_ATI, GL_NONE, GL_NONE, GL_REG_3_ATI, GL_NONE, GL_NONE, GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NEGATE_BIT_ATI);
Also, if blending is enabled, you surely want to set an alpha component, but I don''t think it''s going to happen (since your register combiner configuration discards the G variable in the final combiner stage) so I won''t post the fragment shader line that does it, but it''s easy of course.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement