1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Texture example for GPGPU for FX Composer 2.5 required ?!

Discussion in 'Nvidia' started by Skybuck Flying, Sep 19, 2009.

  1. 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 ?!?

    1. Advertising

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

    1. Advertising

  3. 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 ***

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

  4. from the cg_specification.pdf:

    (Anybody using pdf for programmer manuals is a fucking retard ! <- bad copy

    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
    of the Cg standard library functions are supported. Table 32 presents the Cg
    standard library functions that are supported by these profiles. See the
    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)

  5. 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
    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 ! ;)

  6. There actually is a reference manual to answer my own question but it's
    fucked 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

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

  8. 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)
    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.
    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)
    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.
    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
    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.
    tex2Dbias, tex2Dlod, tex2Dproj

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

  10. 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 ! ;) :)

    Skybuck =D
  11. Ok, the documentation is better... tex2D is present.

    I hope I don't run into any gtx 7900 compatibility...

    Documentation says 100% compatible with cg 1.5 ;) :)

    Skybuck =D
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Skybuck Flying
    Skybuck Flying
    Sep 28, 2009
  2. JF Mezei

    Reboot required: another example

    JF Mezei, Sep 10, 2009, in forum: Apple
    Doug Anderson
    Sep 11, 2009
  3. Skybuck Flying

    FX Composer 2.5 Render to Texture ?

    Skybuck Flying, Sep 20, 2009, in forum: Nvidia
    Sep 21, 2009
  4. Skybuck Flying
    Skybuck Flying
    Sep 21, 2009
  5. Skybuck Flying
    Skybuck Flying
    Oct 27, 2009

Share This Page