translate from ARBfp to cg

Started by
3 comments, last by Kalidor 18 years, 7 months ago
can someone thanslate this from ARB_fragment_program to cg fragment program ?

!!ARBfp1.0
OPTION ARB_fragment_program_shadow;
TEMP R0;
MOV R0, fragment.position;
TEX R0.x, R0, texture[1], SHADOWRECT;
ADD R0.x, R0.x, -0.5;        
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.
Advertisement
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);
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!
// The user formerly known as Tojiro67445, formerly known as Toji [smile]
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.
Here is the GL_ARB_fragment_program spec. That should get you started.

This topic is closed to new replies.

Advertisement