Frage zu HLSL Konstanten



  • Hallo zusammen
    Ich kämpfe gerade ein wenig mit den HLSL Konstanten. Folgenden Code habe ich in C++:

    // obtain the currently assigned backbuffer and render target
     Surface *sfBab,*sfRnt = 0x00;
     this->pDev->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&sfBab);
     this->pDev->GetRenderTarget(0,&sfRnt);
    
     // compose and assign the required vertex constants (if the assigned render target
     // is the backbuffer a transformation to the ndc will be necessary)
     float32 aCon[4] = {static_cast<float32>(sfRnt->Width)/sfRnt->Height,sfBab == sfRnt,0.0f,0.0f};
     this->pDev->SetVertexShaderConstantF(0,aCon,1);
    
     // release both the render target and the backbuffer
     sfRnt->Release();
     sfBab->Release();
    

    Und in HLSL:

    // ####################################### define global variables #######################################
    // *******************************************************************************************************
    float Asr: register(c0[0]); // the aspect ratio
    float Ndc: register(c0[1]); // flag if the vertex coordinates must be transformed into the ndc
    // *******************************************************************************************************
    // #######################################################################################################
    

    Aber irgendwie ist Ndc immer 0.0f. Ich frage mich, wie man den Wert nun korrekt ausliest. Mir ist klar dass ich einfach float2 Param: register(c0); machen können, aber dies würde die Lesbarkeit des Codes glaube ich erheblich einschränken und es interessiert mich nun auch aus reiner Neugier, wie denn der Zugriff korrekt funktioniert?

    Mfg Samuel


Anmelden zum Antworten