0
\$\begingroup\$

While compiling the following code. I get a error

float tess = saturate((gMinTessDistance - d) / (gMinTessDistance - gMaxTessDistance));

// Rescale [0,1] --> [gMinTessFactor, gMaxTessFactor].
vout.TessFactor = tess;

if i do this it works.

float tess = saturate((gMinTessDistance - d) / (gMinTessDistance - gMaxTessDistance));

// Rescale [0,1] --> [gMinTessFactor, gMaxTessFactor].
vout.TessFactor = 0.4;

..

struct VertexOut
{
    float3 PosL       : POSITION;
    float3 NormalW    : NORMAL;
    float3 TangentW   : TANGENT;
    float2 Tex        : TEXCOORD;
    float  TessFactor : TESS;
};

Here is code for vertex shader part

VertexOut VS(VertexIn vin)
{
    VertexOut vout;

    // Transform to world space space.
    vout.PosL = mul(float4(vin.PosL, 1.0f), gWorld).xyz;
    vout.NormalW = mul(vin.NormalL, (float3x3)gWorld);
    vout.TangentW = mul(vin.TangentL, (float3x3)gWorld);

    // Output vertex attributes for interpolation across triangle.
    vout.Tex = mul(float4(vin.Tex, 0.0f, 1.0f), gTexTransform).xy;

    float d = distance(vout.PosL, gEyePosW);

    // Normalized tessellation factor. 
    // The tessellation is 
    //   0 if d >= gMinTessDistance and
    //   1 if d <= gMaxTessDistance.  
    float tess = saturate((gMinTessDistance - d) / (gMinTessDistance - gMaxTessDistance));

    // Rescale [0,1] --> [gMinTessFactor, gMaxTessFactor].
    vout.TessFactor = tess;

    return vout;
}

Im in Directx 12 Shader model 5.0

\$\endgroup\$
  • 1
    \$\begingroup\$ "I get a error" You'd get better help if you included the error you got. \$\endgroup\$ – Vaillancourt Aug 15 at 17:59
  • \$\begingroup\$ Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work? \$\endgroup\$ – Glorfindel Aug 15 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.