Sign in to follow this  
fms

What's wrong with this ARB_fragment_program?

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this