# translate from ARBfp to cg

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

## Recommended Posts

can someone thanslate this from ARB_fragment_program to cg fragment program ?
!!ARBfp1.0
TEMP R0;
MOV R0, fragment.position;
KIL R0.x;
OUTPUT out = result.color;
TEMP temp;
TEX temp, fragment.texcoord[0], texture[0], 2D;
MUL out, fragment.color, temp;
END


i need it for order independent transparency. texture[0] is a shadowmap which stores the depth values of the topmost fragments. now i want to draw the fragments which are behind these fragments. my first try was this:
void main	(
float4				iFragmentPos : TEXCOORD2,
float4			        iColor : COLOR,

uniform	samplerRECT	        iDepthBuffer,
uniform int			iPeel,

out float4			oColor : COLOR
)
{
float4 kil = texRECT(iDepthBuffer, iFragmentPos.xy);
oColor = float4(iColor.rgb, iColor.a * kil.r);
}


but the result looks like the first layer.

##### Share on other sites
here is another problem with cg code:
void main	(				float4				iFragmentPos : TEXCOORD2,			float4			        iColor : COLOR,										uniform	samplerRECT	        iDepthBuffer,			uniform int			iPeel,							out float4			oColor : COLOR		){	float4 kil = texRECT(iDepthBuffer, iFragmentPos.xy);        if(kil.r != 1.0)	{	       oColor = iColor;        } else {               oColor = iColor;        }}

this code doesn't display anything. iColor is float4(1,1,1,1);

##### Share on other sites
I can't really help you here since I'm not familiar enough with CG to convert on the fly like that, but for future reference: People on these forums usually aren't to eager to just do something for you when you could jsut as easily do it yourself. That may sound mean, but the reality is that unless you do it yourself you'll never learn, which is really the reason why most people post here, yes? The only other reasons I can think of is if you need a quick solution for a work or school project, in which case you should be doing it yourself anyway!

##### Share on other sites
believe it or not, i have searched the internet for several hours for some helpful information, but there is nothing out there. if i could convert it on my own, i would have done it already. i am smart enough to know that there aren't tens of people out there who are willing to help me, but if somebody gave me something to start with (function name, online documentation, examples) it would be in the sense of the forums.

##### Share on other sites
Here is the GL_ARB_fragment_program spec. That should get you started.

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 11
• 15
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633352
• Total Posts
3011483
• ### Who's Online (See full list)

There are no registered users currently online

×