Jump to content
  • Advertisement
Sign in to follow this  
Zische

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.

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

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
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 this post


Link to post
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 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!