Motherboard Forums


Reply
Thread Tools Display Modes

Texture example for GPGPU for FX Composer 2.5 required ?!

 
 
Skybuck Flying
Guest
Posts: n/a
 
      09-19-2009, 08:49 PM
Hello,

I want to load a texture into FX Composer 2.5

The texture is supposed to be rendered over a plane.

That's all.

I cannot figure out to do this with vertex and pixel shaders.

Can somebody make a simple vertex and pixel shader that will work in FC
Composer 2.5 ?!?

Bye,
Skybuck.


 
Reply With Quote
 
 
 
 
Skybuck Flying
Guest
Posts: n/a
 
      09-19-2009, 08:58 PM
It's easy when clicking "create new effect, phong blabla".

I shall have to reverse engineer this shader effect.

Because the documentation takes me nowhere.

Bye,
Skybuck.


 
Reply With Quote
 
 
 
 
Skybuck Flying
Guest
Posts: n/a
 
      09-19-2009, 09:09 PM
Reverse enginering done, the secret seems to be in the tex2D function ?!

Wow it actually has functions ?! <GJE>

Now to find the documentation for it... hmm <GJE>

// *** Begin of simple texture shader ***

//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS ////////////////
float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >;

//// TWEAKABLE PARAMETERS ////////////////////

//////// COLOR & TEXTURE /////////////////////

texture ColorTexture <
string ResourceName = "default_color.dds";
string UIName = "Diffuse Texture";
string ResourceType = "2D";
>;


sampler2D ColorSampler = sampler_state {
Texture = <ColorTexture>;
MinFilter = LinearMipMapLinear;
MagFilter = Linear;
WrapS = Repeat;
WrapT = Repeat;
};


//////// CONNECTOR DATA STRUCTURES ///////////

/* data from application vertex buffer */
struct appdata {
float3 Position : POSITION;
float4 UV : TEXCOORD0;
};

/* data passed from vertex shader to pixel shader */
struct vertexOutput {
float4 HPosition : POSITION;
float2 UV : TEXCOORD0;
};

///////// VERTEX SHADING /////////////////////

/*********** Generic Vertex Shader ******/

vertexOutput std_VS(appdata IN) {
vertexOutput OUT = (vertexOutput)0;
float4 Po = float4(IN.Position.xyz,1);
OUT.UV = IN.UV.xy;
OUT.HPosition = mul(WvpXf,Po);
return OUT;
}

///////// PIXEL SHADING //////////////////////

float4 std_PS(vertexOutput IN) : COLOR {
float3 diffuseColor = tex2D(ColorSampler,IN.UV).rgb;
return float4(diffuseColor, 1.0);
}

///// TECHNIQUES /////////////////////////////

technique Main <
string Script = "Pass=p0;";
> {

pass p0 <
string Script = "Draw=geometry;";
> {

VertexProgram = compile vp40 std_VS();
DepthTestEnable = true;
DepthMask = true;
CullFaceEnable = false;
BlendEnable = false;
DepthFunc = LEqual;
FragmentProgram = compile fp40 std_PS();
}
}

/////////////////////////////////////// eof //

// *** End of simple texture shader ***

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      09-19-2009, 09:27 PM
from the cg_specification.pdf:

(Anybody using pdf for programmer manuals is a ****ing retard ! <- bad copy
pasting)

Copieied the second part wasn't even possible.

Here is the first part:

It "talks" about a standard library ? WTF IS IT TALKING ABOUT ?!

Standard Library Functions
Because the DirectX pixel shader 1_X profiles have limited capabilities, not
all
of the Cg standard library functions are supported. Table 32 presents the Cg
standard library functions that are supported by these profiles. See the
standard
library documentation for descriptions of these functions.
Table 32 Supported Standard Library Functions
dot(floatN, floatN)
lerp(floatN, floatN, floatN)
lerp(floatN, floatN, float)
tex1D(sampler1D, float)
tex1D(sampler1D, float2)
tex1Dproj(sampler1D, float2)
tex1Dproj(sampler1D, float3)
tex2D(sampler2D, float2)
tex2D(sampler2D, float3)
tex2Dproj(sampler2D, float3)
tex2Dproj(sampler2D, float4)
texRECT(samplerRECT, float2)
texRECT(samplerRECT, float3)
texRECTproj(samplerRECT, float3)


Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      09-19-2009, 09:29 PM
More crap from the specification:

I actually wonder if there's such a thing as a CG programmer's reference or
anything like that ?

page 192:
"
Cg Standard Library Functions
Cg provides a set of built-in functions and predefined structures with
binding
semantics to simplify GPU programming. These functions are discussed in “Cg
Standard Library Functions” on page 19
"

Apperently this means a document called: "Cg Standard Library functions".

Me go search for it with google !

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      09-19-2009, 09:34 PM
There actually is a reference manual to answer my own question but it's
****ed up beyond comprehesion in a way.

It combines opengl, directx and shading and function stuff...

Without actually explaining what everything is...

There are no chapters, no examples, no nothing.

The relation between everything is even more missing then the general opengl
crap.

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      09-19-2009, 09:37 PM
The most amazing discovery and conclusion is that tex2D one of the most
important functions is not even in the reference manual.

To me it seems that people making these documents did their very best for
other people to get into this material.

One word comes to mind: sabotage or deliberate.

If this is how Nvidia tries to gather more developers for it's technogoly
then it will surely crash and burn to death.

Time will tell if I will be right.

For the sake of nvidia the hope is on the cuda documentation if it's just as
bad and crap nvidia will go nowhere but general crap computing.

Or the select lucky few.

Select lucky few != general purpose computing.

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      09-19-2009, 09:41 PM
The only documentation for tex2D which I seem to be able to find up to this
point is from a possibly illegal bit torrent file which I downloaded a
while ago.

It's a big bittorrent file containing all kinds of graphics and game
development related documents.

One document is called:

cg-2.0 may 2008.

I am not sure if it's legal or illegal.

From the documentation:

"
tex2D(Cg) CgStandard Library tex2D(Cg)
NAME
tex2D - performs a texture lookup in a given 2D sampler and, in some cases,
a shadow comparison. May
also use pre computed derivatives if those are provided.
SYNOPSIS
float4 tex2D(sampler2D samp, float2 s)
float4 tex2D(sampler2D samp, float2 s, int texelOff)
float4 tex2D(sampler2D samp, float3 s)
float4 tex2D(sampler2D samp, float3 s, int texelOff)
float4 tex2D(sampler2D samp, float2 s, float2 dx, float2 dy)
float4 tex2D(sampler2D samp, float2 s, float2 dx, float2 dy, int texelOff)
float4 tex2D(sampler2D samp, float3 s, float2 dx, float2 dy)
float4 tex2D(sampler2D samp, float3 s, float2 dx, float2 dy, int texelOff)
int4 tex2D(isampler2D samp, float2 s)
int4 tex2D(isampler2D samp, float2 s, int texelOff)
int4 tex2D(isampler2D samp, float2 s, float2 dx, float2 dy)
int4 tex2D(isampler2D samp, float2 s, float2 dx, float2 dy, int texelOff)
unsigned int4 tex2D(usampler2D samp, float2 s)
unsigned int4 tex2D(usampler2D samp, float2 s, int texelOff)
unsigned int4 tex2D(usampler2D samp, float2 s, float2 dx, float2 dy)
unsigned int4 tex2D(usampler2D samp, float2 s, float2 dx, float2 dy,
int texelOff)
PARAMETERS
samp Sampler to lookup.
s Coordinates to perform the lookup. If an extra coordinate compared to the
texture dimensionality
is present it is used to perform a shadow comparison. The value used in the
shadow comparison is
always the last component of the coordinate vector.
dx Pre computed derivative along the x axis.
dy Pre computed derivative along the y axis.
texelOff Offset to be added to obtain the final texel.
DESCRIPTION
Performs a texture lookup in sampler samp using coordinates s, may use and
derivatives dx and dy, also
may perform shadow comparison and use texel offset texelOff to compute final
texel.
PROFILE SUPPORT
tex2D is supported in all fragment profiles and all vertex profiles starting
with vp40, variants with shadow
comparison are only supported in fp40 and newer profiles, variants with
texel offsets are only supported in
gp4 and newer profiles. Variants with integer textures are also only
supported in gp4 and newer profiles.
SEE ALSO
tex2Dbias, tex2Dlod, tex2Dproj
Cg
"

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      09-19-2009, 09:44 PM
The documentation of the nvidia cg toolit is from 2006, and 2007... and
apperently old and missing a lot.

The question is now why is this ?

Did I download this toolkit a long time ago and is it out of date ?!?

Or did nvidia supply old information with the toolkit...

I did see that there is a new toolkit available...

I shall investigate further.

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      09-19-2009, 09:51 PM
Well I don't even have a toolkit download in my folder... I probably
directly downloaded it to my install folder... and I am not even sure where
I got it from... at the time I was probably checking it out and not to
serious about it... (Would be nice if internet explorer had a default
download folder damn it ! )

But now I am serious about it...

Going to download all the latest versions ! Yeah... 2009 versions available
!

Gonna check it all out and report back if it's any better !

Bye,
Skybuck =D


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting a floating point texture to a rgba texture so it's ready to be flipped to the screen ?! ;) Skybuck Flying Nvidia 28 10-27-2009 09:28 PM
GPGPU example plus needed OpenGL and CG libraries for Delphi 2007 now available ! Skybuck Flying Nvidia 6 09-28-2009 06:25 AM
Basic texture example (texture+sampler+vertex shader+pixel shader) for FX Composer 2.5 (cgfx) Skybuck Flying Nvidia 9 09-21-2009 10:21 PM
FX Composer 2.5 Render to Texture ? Skybuck Flying Nvidia 6 09-21-2009 09:14 PM
Reboot required: another example JF Mezei Apple 14 09-11-2009 02:35 PM


All times are GMT. The time now is 02:40 PM.


Welcome!
Welcome to Motherboard Point
 

Advertisment