Skip to main content
deleted 11 characters in body
Source Link

[Alternative Solution] Thanks for help guys. i just found out with your helps that my idea won't work since the depth in pipeline will be restricted only between 0~1.

Here is my another solution that i figured out. i post it here just in case for someone who need z order system. i came to modify projection matrix calculation. and have multiple of it, so that i have 5 hierarchy for rendering in my framework. you can set as many as you want btw.

// in class of application, not shader of GPU
#define Z_ORDER_MAX         5

#define Z_ORDER_UI          0
#define Z_ORDER_HIGHER      1
#define Z_ORDER_STANDARD    2
#define Z_ORDER_LOWER       3
#define Z_ORDER_BACKGROUND  4  
  
projMats = new XMMATRIX[Z_ORDER_MAX];

for (int i = 0; i < Z_ORDER_MAX; ++i)
{
    float minD = i * 0.2f;
    float maxD = (i + 1)*0.2f;
    float A = (maxD * (f / (f - 1)) - minD * (n) / (f - 1));
    float B = n * (minD - A);
 // i can guess, after multiplication and perspective division, z value would be 'A+B/z'.  and then instead ranging them between 0~1, i does 0~0.2/0.2~0.4 so on.

    projMats[i] =
        XMMATRIX(
            1.0f / (aspectRatio*tan(verticalViewAngle*0.5f)), 0, 0, 0,
            0, 1.0f / tan(verticalViewAngle*0.5f), 0, 0,
            0, 0, A, 1,
            0, 0, B, 0);
}

and when you render any object, you choose and use the projMatrix corresponds to z order index that you want to set.

[Alternative Solution] Thanks for help guys. i just found out with your helps that my idea won't work since the depth in pipeline will be restricted only between 0~1.

Here is my another solution that i figured out. i post it here just in case for someone who need z order system. i came to modify projection matrix calculation. and have multiple of it, so that i have 5 hierarchy for rendering in my framework. you can set as many as you want btw.

// in class of application, not shader of GPU
#define Z_ORDER_MAX         5

#define Z_ORDER_UI          0
#define Z_ORDER_HIGHER      1
#define Z_ORDER_STANDARD    2
#define Z_ORDER_LOWER       3
#define Z_ORDER_BACKGROUND  4  
  
projMats = new XMMATRIX[Z_ORDER_MAX];

for (int i = 0; i < Z_ORDER_MAX; ++i)
{
    float minD = i * 0.2f;
    float maxD = (i + 1)*0.2f;
    float A = maxD * (f / (f - 1)) - minD * (n / (f - 1));
    float B = n * (minD - A);
 // i can guess, after multiplication and perspective division, z value would be 'A+B/z'.  and then instead ranging them between 0~1, i does 0~0.2/0.2~0.4 so on.

    projMats[i] =
        XMMATRIX(
            1.0f / (aspectRatio*tan(verticalViewAngle*0.5f)), 0, 0, 0,
            0, 1.0f / tan(verticalViewAngle*0.5f), 0, 0,
            0, 0, A, 1,
            0, 0, B, 0);
}

and when you render any object, you choose and use the projMatrix corresponds to z order index that you want to set.

[Alternative Solution] Thanks for help guys. i just found out with your helps that my idea won't work since the depth in pipeline will be restricted only between 0~1.

Here is my another solution that i figured out. i post it here just in case for someone who need z order system. i came to modify projection matrix calculation. and have multiple of it, so that i have 5 hierarchy for rendering in my framework. you can set as many as you want btw.

// in class of application, not shader of GPU
#define Z_ORDER_MAX         5

#define Z_ORDER_UI          0
#define Z_ORDER_HIGHER      1
#define Z_ORDER_STANDARD    2
#define Z_ORDER_LOWER       3
#define Z_ORDER_BACKGROUND  4  
  
projMats = new XMMATRIX[Z_ORDER_MAX];

for (int i = 0; i < Z_ORDER_MAX; ++i)
{
    float minD = i * 0.2f;
    float maxD = (i + 1)*0.2f;
    float A = (maxD * f - minD * n) / (f - 1));
    float B = n * (minD - A);
 // i can guess, after multiplication and perspective division, z value would be 'A+B/z'.  and then instead ranging them between 0~1, i does 0~0.2/0.2~0.4 so on.

    projMats[i] =
        XMMATRIX(
            1.0f / (aspectRatio*tan(verticalViewAngle*0.5f)), 0, 0, 0,
            0, 1.0f / tan(verticalViewAngle*0.5f), 0, 0,
            0, 0, A, 1,
            0, 0, B, 0);
}

and when you render any object, you choose and use the projMatrix corresponds to z order index that you want to set.

added 10 characters in body
Source Link

[Alternative Solution] Thanks for help guys. i just found out with your helps that my idea won't work since the depth in pipeline will be restricted only between 0~1.

Here is my another solution that i figured out. i post it here just in case for someone who need z order system. i came to modify projection matrix calculation. and have multiple of it, so that i have 5 hierarchy for rendering in my framework. you can set as many as you want btw.

// in class of application, not shader of GPU
#define Z_ORDER_MAX         5

#define Z_ORDER_UI          0
#define Z_ORDER_HIGHER      1
#define Z_ORDER_STANDARD    2
#define Z_ORDER_LOWER       3
#define Z_ORDER_BACKGROUND  4  
  
projMats = new XMMATRIX[5];XMMATRIX[Z_ORDER_MAX];

for (int i = 0; i < Z_ORDER_MAX; ++i)
{
    float minD = i * 0.2f;
    float maxD = (i + 1)*0.2f;
    float A = maxD * (f / (f - 1)) - minD * (n / (f - 1));
    float B = n * (minD - A);
 // i can guess, after multiplication and perspective division, z value would be 'A+B/z'.  and then instead ranging them between 0~1, i does 0~0.2/0.2~0.4 so on.

    projMats[i] =
        XMMATRIX(
            1.0f / (aspectRatio*tan(verticalViewAngle*0.5f)), 0, 0, 0,
            0, 1.0f / tan(verticalViewAngle*0.5f), 0, 0,
            0, 0, A, 1,
            0, 0, B, 0);
}

and when you render any object, you choose and use the projMatrix corresponds to z order index that you want to set.

[Alternative Solution] Thanks for help guys. i just found out with your helps that my idea won't work since the depth in pipeline will be restricted only between 0~1.

Here is my another solution that i figured out. i post it here just in case for someone who need z order system. i came to modify projection matrix calculation. and have multiple of it, so that i have 5 hierarchy for rendering in my framework. you can set as many as you want btw.

// in class of application, not shader of GPU
#define Z_ORDER_MAX         5

#define Z_ORDER_UI          0
#define Z_ORDER_HIGHER      1
#define Z_ORDER_STANDARD    2
#define Z_ORDER_LOWER       3
#define Z_ORDER_BACKGROUND  4  
  
projMats = new XMMATRIX[5];

for (int i = 0; i < Z_ORDER_MAX; ++i)
{
    float minD = i * 0.2f;
    float maxD = (i + 1)*0.2f;
    float A = maxD * (f / (f - 1)) - minD * (n / (f - 1));
    float B = n * (minD - A);
 // i can guess, after multiplication and perspective division, z value would be 'A+B/z'.  and then instead ranging them between 0~1, i does 0~0.2/0.2~0.4 so on.

    projMats[i] =
        XMMATRIX(
            1.0f / (aspectRatio*tan(verticalViewAngle*0.5f)), 0, 0, 0,
            0, 1.0f / tan(verticalViewAngle*0.5f), 0, 0,
            0, 0, A, 1,
            0, 0, B, 0);
}

and when you render any object, you choose and use the projMatrix corresponds to z order index that you want to set.

[Alternative Solution] Thanks for help guys. i just found out with your helps that my idea won't work since the depth in pipeline will be restricted only between 0~1.

Here is my another solution that i figured out. i post it here just in case for someone who need z order system. i came to modify projection matrix calculation. and have multiple of it, so that i have 5 hierarchy for rendering in my framework. you can set as many as you want btw.

// in class of application, not shader of GPU
#define Z_ORDER_MAX         5

#define Z_ORDER_UI          0
#define Z_ORDER_HIGHER      1
#define Z_ORDER_STANDARD    2
#define Z_ORDER_LOWER       3
#define Z_ORDER_BACKGROUND  4  
  
projMats = new XMMATRIX[Z_ORDER_MAX];

for (int i = 0; i < Z_ORDER_MAX; ++i)
{
    float minD = i * 0.2f;
    float maxD = (i + 1)*0.2f;
    float A = maxD * (f / (f - 1)) - minD * (n / (f - 1));
    float B = n * (minD - A);
 // i can guess, after multiplication and perspective division, z value would be 'A+B/z'.  and then instead ranging them between 0~1, i does 0~0.2/0.2~0.4 so on.

    projMats[i] =
        XMMATRIX(
            1.0f / (aspectRatio*tan(verticalViewAngle*0.5f)), 0, 0, 0,
            0, 1.0f / tan(verticalViewAngle*0.5f), 0, 0,
            0, 0, A, 1,
            0, 0, B, 0);
}

and when you render any object, you choose and use the projMatrix corresponds to z order index that you want to set.

Source Link

[Alternative Solution] Thanks for help guys. i just found out with your helps that my idea won't work since the depth in pipeline will be restricted only between 0~1.

Here is my another solution that i figured out. i post it here just in case for someone who need z order system. i came to modify projection matrix calculation. and have multiple of it, so that i have 5 hierarchy for rendering in my framework. you can set as many as you want btw.

// in class of application, not shader of GPU
#define Z_ORDER_MAX         5

#define Z_ORDER_UI          0
#define Z_ORDER_HIGHER      1
#define Z_ORDER_STANDARD    2
#define Z_ORDER_LOWER       3
#define Z_ORDER_BACKGROUND  4  
  
projMats = new XMMATRIX[5];

for (int i = 0; i < Z_ORDER_MAX; ++i)
{
    float minD = i * 0.2f;
    float maxD = (i + 1)*0.2f;
    float A = maxD * (f / (f - 1)) - minD * (n / (f - 1));
    float B = n * (minD - A);
 // i can guess, after multiplication and perspective division, z value would be 'A+B/z'.  and then instead ranging them between 0~1, i does 0~0.2/0.2~0.4 so on.

    projMats[i] =
        XMMATRIX(
            1.0f / (aspectRatio*tan(verticalViewAngle*0.5f)), 0, 0, 0,
            0, 1.0f / tan(verticalViewAngle*0.5f), 0, 0,
            0, 0, A, 1,
            0, 0, B, 0);
}

and when you render any object, you choose and use the projMatrix corresponds to z order index that you want to set.