I have a problem with 2D sprite in 3D game

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
User avatar
NITROYUASH
Verified
Serious PSXDEV User
Serious PSXDEV User
Posts: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » November 19th, 2019, 4:32 am

Oh, i have a small question about the 3D sorting now. It’s not worth it to create another topic here :>

What's the best type of sorting the polygons for my game scene?

Some pseudo-code:

Version 1:
Main:

Code: Select all

int main(void) {

	SetDispMask(1);

	while (1) {
		PrepDisp();

		SortStuff();

		Display();
	}
}
return(0);
Func:

Code: Select all

void SortStuff() {
    // INIT SOME STUFF
    if ((smooth)) {
        if (textured) {
            if (poly != quad) {
                // DO GT3 CODE
            } else {
                // DO GT4 CODE
            }
        } else {
            if (poly != quad) {
                // DO G3 CODE
            } else {
                // DO G4 CODE
            }
        }
    } else {
        if (textured) {
            if (poly != quad) {
                // DO FT3 CODE
            } else {
                // DO FT4 CODE
            }
        } else {
            if (poly != quad) {
                // DO F3 CODE
            } else {
                // DO F4 CODE
            }
        }
    }
    
    // DO UNIVERSAL CODE FOR ALL POLYGON TYPES
    
    if ((smooth)) {
        if (textured) {
            if (poly != quad) {
                // DO GT3 ADDPRIM
            } else {
                // DO GT4 ADDPRIM
            }
        } else {
            if (poly != quad) {
                // DO G3 ADDPRIM
            } else {
                // DO G4 ADDPRIM
            }
        }
    } else {
        if (textured) {
            if (poly != quad) {
                // DO FT3 ADDPRIM
            } else {
                // DO FT4 ADDPRIM
            }
        } else {
            if (poly != quad) {
                // DO F3 ADDPRIM
            } else {
                // DO F4 ADDPRIM
            }
        }
    }
}
Version 2:
Main:

Code: Select all

int main(void) {

	SetDispMask(1);

	while (1) {
		PrepDisp();

		SortStuff();

		Display();
	}
}
return(0);
Func:

Code: Select all

void SortStuff() {
    // INIT SOME STUFF
    if ((smooth)) {
        if (textured) {
            if (poly != quad) {
                // DO GT3 CODE
                // DO UNIVERSAL CODE FOR ALL POLYGON TYPES
                // DO ADDPRIM FOR THIS POLYGON TYPE
            } else {
                // DO GT4 CODE
                // DO UNIVERSAL CODE FOR ALL POLYGON TYPES
                // DO ADDPRIM FOR THIS POLYGON TYPE
            }
        } else {
            if (poly != quad) {
                // DO G3 CODE
                // DO UNIVERSAL CODE FOR ALL POLYGON TYPES
                // DO ADDPRIM FOR THIS POLYGON TYPE
            } else {
                // DO G4 CODE
                // DO UNIVERSAL CODE FOR ALL POLYGON TYPES
                // DO ADDPRIM FOR THIS POLYGON TYPE
            }
        }
    } else {
        if (textured) {
            if (poly != quad) {
                // DO FT3 CODE
                // DO UNIVERSAL CODE FOR ALL POLYGON TYPES
                // DO ADDPRIM FOR THIS POLYGON TYPE
            } else {
                // DO FT4 CODE
                // DO UNIVERSAL CODE FOR ALL POLYGON TYPES
                // DO ADDPRIM FOR THIS POLYGON TYPE
            }
        } else {
            if (poly != quad) {
                // DO F3 CODE
                // DO UNIVERSAL CODE FOR ALL POLYGON TYPES
                // DO ADDPRIM FOR THIS POLYGON TYPE
            } else {
                // DO F4 CODE
                // DO UNIVERSAL CODE FOR ALL POLYGON TYPES
                // DO ADDPRIM FOR THIS POLYGON TYPE
            }
        }
    }
}
Version 3:
Main:

Code: Select all

int main(void) {

	SetDispMask(1);

	while (1) {
		PrepDisp();

		SortG3();   SortG4();
		SortGT3(); SortGT4();
		SortF3();    SortF4();
		SortFT3();  SortFT4();

		Display();
	}
}
return(0);
Func:

Code: Select all

void SortG3() {
    if (smooth && poly != quad && !textured) {
        // DO G3 CODE
        // DO UNIVERSAL CODE HERE
        // DO ADDPRIM FOR THIS POLYGON TYPE
    }
}
void SortG4() {
    if (smooth && poly == quad && !textured) {
        // DO G4 CODE
        // DO UNIVERSAL CODE HERE
        // DO ADDPRIM FOR THIS POLYGON TYPE
    }
}
void SortGT3() {
    if (smooth && poly != quad && textured) {
        // DO GT3 CODE
        // DO UNIVERSAL CODE HERE
        // DO ADDPRIM FOR THIS POLYGON TYPE
    }
}
void SortGT4() {
    if (smooth && poly == quad && textured) {
        // DO GT4 CODE
        // DO UNIVERSAL CODE HERE
        // DO ADDPRIM FOR THIS POLYGON TYPE
    }
}
void SortF3() {
    if (!smooth && poly != quad && !textured) {
        // DO F3 CODE
        // DO UNIVERSAL CODE HERE
        // DO ADDPRIM FOR THIS POLYGON TYPE
    }
}
void SortF4() {
    if (!smooth && poly == quad && !textured) {
        // DO F4 CODE
        // DO UNIVERSAL CODE HERE
        // DO ADDPRIM FOR THIS POLYGON TYPE
    }
}
void SortFT3() {
    if (!smooth && poly != quad && textured) {
        // DO FT3 CODE
        // DO UNIVERSAL CODE HERE
        // DO ADDPRIM FOR THIS POLYGON TYPE
    }
}
void SortFT4() {
    if (!smooth && poly == quad && textured) {
        // DO FT4 CODE
        // DO UNIVERSAL CODE HERE
        // DO ADDPRIM FOR THIS POLYGON TYPE
    }
}

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests