Advertisement

Porting Mirko's Ravers Nature for ATi

Started by February 11, 2003 04:10 PM
85 comments, last by vincoof 21 years, 11 months ago
For those of you who have not read this thread, the idea is simple : setup Mirko Teran's Mini-Contest entry in order to run fully on ATi Radeon cards (target is 8500 or higher for now) because the current version runs fully on nVidia cards *only* and of course because this demo rocks everyone should be able to see it ! Since the thread (shown above) is going off-topic, I thought it would be better to start a new thread, so there it is. I will post some fragment shaders in this thread when I'll have time. If you have any idea (for instance, if porting the demo for Matrox j/k) or simply want to participate : you're welcome ! [edited by - vincoof on February 11, 2003 5:15:48 PM]
hmm, I have an at 8500 and it bitches about not having some extension, but it still runs fine.
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Advertisement
In file UParticleSystemRC.h , the method :

  void UParticleSystemRC::SetupRegCom();  

may use the following shader :

  glBeginFragmentShaderATI();// Pass 1glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI); // Start pass// reg0 = r^2glColorFragmentOp2ATI(GL_DOT3_ATI, GL_REG_0_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);// reg0 = (1-r^2)^2glColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_REG_0_ATI, GL_NONE, GL_COMP_BIT_ATI,                      GL_REG_0_ATI, GL_NONE, GL_COMP_BIT_ATI);// reg1 = col_rgb * col_alphaglColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_1_ATI, GL_NONE, GL_NONE,                      GL_PRIMARY_COLOR_ARB, GL_ALPHA, GL_NONE,                      GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE);// final color = (1-r^2)^2 * col_rgb * col_alphaglColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_REG_1_ATI, GL_NONE, GL_NONE);glEndFragmentShaderATI();  

and if color sum is enabled (or lighting enabled), the last operation may be replaced by :

  // final color = (1-r^2)^2 * col_rgb * col_alpha - secondaryglColorFragmentOp2ATI(GL_AD_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_REG_1_ATI, GL_NONE, GL_NONE,                      GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NEGATE_BIT_ATI);  
Everything that runs is fine, but are you sure you've seen all the scenes ? For instance, have you seen a terrain in the demo ?

[edited by - vincoof on February 11, 2003 6:08:24 PM]
In file UnityShaderPerPixel.h , the method :

  void UShaderPerPixel::InitRegComMultiLight();  

may use the following shader :

  glBeginFragmentShaderATI();// Pass 1glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);glSampleMapATI(GL_REG_1_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI);// reg0 = N.LglColorFragmentOp2ATI(GL_DOT3_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_REG_0_ATI, GL_NONE, GL_2X_BIT_ATI|GL_BIAS_BIT_ATI,                      GL_REG_1_ATI, GL_NONE, GL_2X_BIT_ATI|GL_BIAS_BIT_ATI);// final color = N.L * colorglColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE);glEndFragmentShaderATI();  

and if color sum is enabled (or lighting enabled), the last operation may be replaced, as usual.
In file UnityShaderPerPixel.h , the method :

  void UShaderPerPixel::InitRegComSingleLight();  

may use the following shader :

  glBeginFragmentShaderATI();// Pass 1glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);glSampleMapATI(GL_REG_1_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI);glSampleMapATI(GL_REG_2_ATI, GL_TEXTURE2_ARB, GL_SWIZZLE_STR_ATI);// reg3 = N.LglColorFragmentOp2ATI(GL_DOT3_ATI, GL_REG_3_ATI, GL_NONE, GL_NONE,                      GL_REG_1_ATI, GL_NONE, GL_2X_BIT_ATI|GL_BIAS_BIT_ATI,                      GL_REG_2_ATI, GL_NONE, GL_2X_BIT_ATI|GL_BIAS_BIT_ATI);// reg3 = (N.L)*lightColor+ambientglColorFragmentOp3ATI(GL_MAD_ATI, GL_REG_3_ATI, GL_NONE, GL_NONE,                      GL_REG_3_ATI, GL_NONE, GL_NONE,                      GL_CON_0_ATI, GL_NONE, GL_NONE,                      GL_CON_1_ATI, GL_NONE, GL_NONE);// final color = ((N.L)*lightColor+ambient) * textureglColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_REG_3_ATI, GL_NONE, GL_NONE,                      GL_REG_0_ATI, GL_NONE, GL_NONE);glEndFragmentShaderATI();  

Needless to say what to do if color sum or lighting is enabled !
Advertisement
In file UnityShaderTerrain.h , the method :

  void UShaderTerrain::InitRegComBasePass();  

may use the following shader :

  glSetFragmentShaderConstantATI(GL_CON_0_ATI, fogColor.c);glSetFragmentShaderConstantATI(GL_CON_1_ATI, sunColor.c);glBeginFragmentShaderATI();// Pass 1glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);glSampleMapATI(GL_REG_1_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI);// reg2 = TexBase*bias + TexSlope*(1-bias)glColorFragmentOp3ATI(GL_LERP_ATI, GL_REG_2_ATI, GL_NONE, GL_NONE,                      GL_PRIMARY_COLOR_ARB, GL_ALPHA, GL_NONE,                      GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_REG_1_ATI, GL_NONE, GL_NONE);// reg1 = fogFactor^2glColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_1_ATI, GL_NONE, GL_SATURATE_BIT_ATI,                      GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_COMP_BIT_ATI,                      GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_COMP_BIT_ATI);// reg0 = texture * sunColorglColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_REG_2_ATI, GL_NONE, GL_NONE,                      GL_CON_1_ATI, GL_NONE, GL_NONE);// reg0 = texture * sunColor * color = terrainglColorFragmentOp2ATI(GL_LERP_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NONE,                      GL_CON_0_ATI, GL_NONE, GL_NONE,                      GL_REG_0_ATI, GL_NONE, GL_NONE);// final color = fogColor * fog + terrain * (1-fog)glColorFragmentOp3ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                      GL_REG_3_ATI, GL_NONE, GL_NONE,                      GL_REG_0_ATI, GL_NONE, GL_NONE);// alpha = fogFactor^2glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,                      GL_REG_1_ATI, GL_BLUE, GL_NONE);glEndFragmentShaderATI();  

This time it would be better to disable fog, ie glDisable(GL_FOG).
With register combiners it''s not necessary since the register combiners include the fog stage,
but with fragment shader the fog stage is not overriden (just like color sum).
In file UnityShaderPerPixel.h , in the ollowing method :

  void UShaderPerPixel::UseSingleLight();  

The lines of code that initialize register combiner constants should be replaced by :

  SetFragmentShaderConstantATI( GL_CON_0_ATI, localLight[ 0 ].color.c );SetFragmentShaderConstantATI( GL_CON_1_ATI, ambient.c );  
Oops, sorry Julio !
I''ve been a bit fast I think
WOW! vincoof, you''re awesome. Did you try to compile this or is it straight translation from RC? Anyways. I''ll make a switch in the shaders to change NV & ATi verison at runtime. I''ll recompile demo and we''ll see if it works. Oh, yes. one more thing missing. Fragmet shader iextension initialization code. I don''t even know what extension string to look for.

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.

This topic is closed to new replies.

Advertisement