Improve RBMK render CPU performance by switching to VBOs

This commit is contained in:
George Paton 2024-05-07 16:16:46 +10:00
parent f7dc67eef8
commit d3e7a9b857
3 changed files with 16 additions and 12 deletions

View File

@ -1465,12 +1465,15 @@ public class ResourceManager {
public static final IModelCustom deco_computer = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/puter.obj"));
// Some RBMK elements are loaded twice due to VBOs not supporting tessellation
public static final IModelCustom rbmk_element = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_element.obj"));
public static final IModelCustom rbmk_element_vbo = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_element.obj")).asVBO();
public static final IModelCustom rbmk_reflector = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_reflector.obj"));
public static final IModelCustom rbmk_rods = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_rods.obj"));
public static final IModelCustom rbmk_crane_console = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/crane_console.obj"));
public static final IModelCustom rbmk_crane = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/crane.obj"));
public static final IModelCustom rbmk_console = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_console.obj"));
public static final IModelCustom rbmk_rods_vbo = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_rods.obj")).asVBO();
public static final IModelCustom rbmk_crane_console = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/crane_console.obj")).asVBO();
public static final IModelCustom rbmk_crane = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/crane.obj")).asVBO();
public static final IModelCustom rbmk_console = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_console.obj")).asVBO();
public static final IModelCustom rbmk_debris = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/rbmk/debris.obj"));
public static final ResourceLocation rbmk_crane_console_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/crane_console.png");
public static final ResourceLocation rbmk_crane_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/rbmk_crane.png");

View File

@ -48,7 +48,7 @@ public class RenderRBMKControlRod extends TileEntitySpecialRenderer {
double level = control.lastLevel + (control.level - control.lastLevel) * i;
GL11.glTranslated(0, level, 0);
ResourceManager.rbmk_rods.renderPart("Lid");
ResourceManager.rbmk_rods_vbo.renderPart("Lid");
GL11.glPopMatrix();
}

View File

@ -71,36 +71,37 @@ public class RenderRBMKLid extends TileEntitySpecialRenderer {
if(meta == RBMKBase.DIR_GLASS_LID.ordinal()) {
bindTexture(texture_glass);
} else {
if(control.getBlockType() instanceof RBMKBase) {
bindTexture(((RBMKBase)control.getBlockType()).coverTexture);
} else {
bindTexture(texture);
}
cherenkov = false;
}
if((control instanceof TileEntityRBMKBoiler || control instanceof TileEntityRBMKHeater) && meta != RBMKBase.DIR_GLASS_LID.ordinal())
ResourceManager.rbmk_rods.renderPart("Lid");
ResourceManager.rbmk_element.renderPart("Lid");
if((control instanceof TileEntityRBMKBoiler || control instanceof TileEntityRBMKHeater) && meta != RBMKBase.DIR_GLASS_LID.ordinal()) {
ResourceManager.rbmk_rods_vbo.renderPart("Lid");
} else {
ResourceManager.rbmk_element_vbo.renderPart("Lid");
}
GL11.glPopMatrix();
}
if(hasRod) {
GL11.glPushMatrix();
bindTexture(texture_rods);
for(int j = 0; j <= offset; j++) {
ResourceManager.rbmk_element.renderPart("Rods");
ResourceManager.rbmk_element_vbo.renderPart("Rods");
GL11.glTranslated(0, 1, 0);
}
GL11.glPopMatrix();
}
if(cherenkov) {
GL11.glTranslated(0, 0.75, 0);
GL11.glDisable(GL11.GL_CULL_FACE);