Jump to content
  • Advertisement
Sign in to follow this  
fms

What's wrong with this ARB_fragment_program?

This topic is 4822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am writing this shader and I don't seem to follow why "SUBR" is not providing me the correct results. I checked the contents of the variables and they seems to be fine. Apparently when I try to do the subtraction between "Coordinates" and "Position", the "COLOR" results in some junk values. Here is the source code: ################################################# "!!ARBfp1.0\n" "OPTION NV_fragment_program2;\n" "ATTRIB ParticleIndex = fragment.texcoord[2];\n" "OUTPUT COLOR = result.color;\n" "PARAM Root = {0.0, 0.0};\n" "PARAM Width = program.env[0]; # width is 4\n" "TEMP MassAddress;\n" "TEMP Position;\n" "TEMP Coordinates;\n" "TEMP GridIndex;\n" "TEMP Index;\n" "TEMP fraction;\n" "TEMP temp;\n" "TEX Coordinates, ParticleIndex, texture[2], RECT;\n" "TEX MassAddress, Root, texture[0], RECT;\n" "MOVR Index.x, MassAddress.z;\n" "CAL DECODEINDEX;\n" "TEX MassAddress, GridIndex, texture[0], RECT;\n" "TEX Position, GridIndex, texture[1], RECT;\n" "SUBR COLOR, Coordinates, Position;\n" "DECODEINDEX:\n" "DIVR GridIndex.y, Index.x, Width.x;\n" "FRCR fraction.x, GridIndex.y;\n" "MULR GridIndex.x, fraction.x, Width.x;\n" "RET;\n" "END\n"; ################################################# Please help. Platform : x86(AMD) , Linux RedHat 9.0 Graphics Hardware : GeForce 6600 GT Thanks. - FMS

Share this post


Link to post
Share on other sites
Advertisement
Do you realize that your DECODEINDEX subroutine will be executed twice? Once from the CAL instruction and again after the SUBR instruction. You either need to put a RET after the SUBR or put the subroutine at the beginning of the program and label the instruction where you want the program to start with "main:". Why is it a subroutine in the first place, though? You'll get much better performance by just inlining that code.

I don't think that executing the DECODEINDEX subroutine twice would ruin the value of COLOR. I don't see any reason why you're getting garbage.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!