Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9155581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:37:16+00:00 2026-06-17T12:37:16+00:00

How do I convert such technique (from nVidia InstancedTesselation sample) to plain HLSL +

  • 0

How do I convert such technique (from nVidia InstancedTesselation sample) to plain HLSL + DirectX 11 C++ code?

float4 PreprocessedLoDVS( uint id : SV_InstanceID, uniform int method) : LODS
{
    float4 tessLevel;
    if (method == 1)    //Gregory
    {
        float3 positionControlPoints[20];
        //  8     9     10     11
        // 12   0\1     2/3    13
        // 14   4/5     6\7    15
        // 16    17     18     19
        LoadGregoryPositionControlPoints(id, positionControlPoints);
        tessLevel.x = evaluateEdgeLoD(positionControlPoints[16], positionControlPoints[14], positionControlPoints[12], positionControlPoints[8]);
        tessLevel.y = evaluateEdgeLoD(positionControlPoints[19], positionControlPoints[15], positionControlPoints[13], positionControlPoints[11]);
        tessLevel.z = evaluateEdgeLoD(positionControlPoints[16], positionControlPoints[17], positionControlPoints[18], positionControlPoints[19]);
        tessLevel.w = evaluateEdgeLoD(positionControlPoints[8], positionControlPoints[9], positionControlPoints[10], positionControlPoints[11]);
    }
    else if (method == 0) {  //Regular
        float3 positionControlPoints[16];
        //  0     1     2     3
        //  4     5     6     7    
        //  8     9     10    11
        //  12    13    14    15
        LoadRegularControlPoints(id, positionControlPoints);
        tessLevel.x = evaluateEdgeLoD(positionControlPoints[ 0], positionControlPoints[ 4], positionControlPoints[ 8], positionControlPoints[12]);
        tessLevel.y = evaluateEdgeLoD(positionControlPoints[ 3], positionControlPoints[ 7], positionControlPoints[11], positionControlPoints[15]);
        tessLevel.w = evaluateEdgeLoD(positionControlPoints[ 0], positionControlPoints[ 1], positionControlPoints[ 2], positionControlPoints[ 3]);
        tessLevel.z = evaluateEdgeLoD(positionControlPoints[12], positionControlPoints[13], positionControlPoints[14], positionControlPoints[15]);
    }
    else if (method == 2) {  //Bezier
        float3 positionControlPoints[16];
        //  0     1     2     3
        //  4     5     6     7    
        //  8     9     10    11
        //  12    13    14    15
        LoadBezierPositionControlPoints(id, positionControlPoints);
        tessLevel.x = evaluateEdgeLoD(positionControlPoints[ 0], positionControlPoints[ 4], positionControlPoints[ 8], positionControlPoints[12]);
        tessLevel.y = evaluateEdgeLoD(positionControlPoints[ 3], positionControlPoints[ 7], positionControlPoints[11], positionControlPoints[15]);
        tessLevel.z = evaluateEdgeLoD(positionControlPoints[12], positionControlPoints[13], positionControlPoints[14], positionControlPoints[15]);
        tessLevel.w = evaluateEdgeLoD(positionControlPoints[ 0], positionControlPoints[ 1], positionControlPoints[ 2], positionControlPoints[ 3]);
    }
    else if (method == 3) {  //Pm
        //          18  14  13   12                             
        //          19           8         
        //          20           7              
        //          0   1   2    6                 
        float3 positionControlPoints[24];
        LoadPmControlPoints(id, positionControlPoints);
        tessLevel.x = evaluateEdgeLoD(positionControlPoints[ 0], positionControlPoints[20], positionControlPoints[19], positionControlPoints[18]);
        tessLevel.y = evaluateEdgeLoD(positionControlPoints[ 6], positionControlPoints[ 7], positionControlPoints[ 8], positionControlPoints[12]);
        tessLevel.z = evaluateEdgeLoD(positionControlPoints[18], positionControlPoints[14], positionControlPoints[13], positionControlPoints[12]);
        tessLevel.w = evaluateEdgeLoD(positionControlPoints[ 0], positionControlPoints[ 1], positionControlPoints[ 2], positionControlPoints[ 6]);
    }
    else {
        tessLevel=float4(2,2,2,2);
    }
    return tessLevel;
}

technique10 LoDRegularTechnique
{
    pass P0
    {
        SetDepthStencilState( DisableDepthWrites, 0 );

        SetVertexShader( CompileShader( vs_4_0, PreprocessedLoDVS(0) ) );
        SetGeometryShader( ConstructGSWithSO( CompileShader( vs_4_0, PreprocessedLoDVS(0) ), "LODS.xyzw" ) );
        SetPixelShader( NULL );
    }
}

PreprocessedLoDVS looks like usual vertex shader, except “LODS” signature, and what about geometry shader?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:37:17+00:00Added an answer on June 17, 2026 at 12:37 pm

    This link explains it pretty nicely, but basically to summarize.

    Compile your shader to blob, using PreprocessedLoDVS and vs_4_0 as profile

    Create an Stream output layout, which is an array of D3D11_SO_DECLARATION_ENTRY , that will be LODS semantic with 4 components.

    Create your vertex shader using CreateGeometryShaderWithStreamOut

    Create a buffer with D3D11_BIND_STREAM_OUTPUT flag (same as you would create any other buffer, from that sample you will need also Shader Resource Flag, since you will need SRV to bind back as Buffer input).

    Bind this buffer to stream output (using SOSetTargets)

    Set your Vertex Shader to the pipeline and do your draw call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written this code to convert string in such format 0(532) 222 22
I have often encountered an error such as cannot convert from 'method group' to
Is there an actual package in CPAN to convert such string: my $string =
To use such great function as ConvertAll() , I have to convert IList to
How do I convert a list of int s to a single string, such
This is arnorhs' code, which converts a date & time into human timing, such
I convert all links from example.com/action to example.com/index.html#action which is then parsed by my
How to convert strings such as uniqueidentifier , timestamp , image , money ,
I need to convert C code to Java. The minimal C code is: void
I would like to convert time strings (Such as 2:12:0) to decimal format in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.