Last active
June 17, 2016 17:21
-
-
Save byteandahalf/cc64b41a8d3110cd8a32991e4aceb97e to your computer and use it in GitHub Desktop.
Some LevelRenderer functions that I decompiled by hand.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void LevelRenderer::_buildSkyMesh() | |
{ | |
Tessellator& tessellator = Tessellator::instance; | |
tessellator.begin(mce::PrimitiveMode::MODE_2, 12); | |
tessellator.color(Color::BLACK); | |
tessellator.vertex(0.0F, 128.0F, 0.0F); | |
double x = 1.0; | |
double z = 0.0; | |
double f = Math::TAU * 0.1; | |
for(int i = 0; i < 11; ++i) | |
{ | |
tessellator.color(Color::WHITE); | |
tessellator.vertex(x * 2000.0F, 128.0F, -(z * 2000.0F)); | |
x = cos(-(i * f)); | |
z = sin(-(i * f)); | |
} | |
tessellator.beginIndices(0); | |
for(int i = 0; i < 11; ++i) | |
{ | |
unsigned int j = i * 0x402e161e; | |
j = (i >> 31) >> (j >> 2); | |
j += (j << 2); | |
tessellator.triangle(0, i, (i - (j << 1)) + 1); | |
} | |
this->field_16E0.Mesh_4 = tessellator.end(NULL, false); | |
} | |
void LevelRenderer::renderSky(Entity& cameraEntity, float partialTicks) | |
{ | |
mce::RenderContextImmediate::get().setDepthRange(0.0F, 1.0F); | |
MatrixStack::Ref projection = MatrixStack::Projection.push(); | |
float fov = tanf(this->getFov(partialTicks, true) * 0.0087266F); | |
float asp = fov * this->_getProjectionAspectRatio(); | |
float f1 = this->field_1620.field_20 * 5120.0F; | |
Matrix matrix; | |
matrix.f84 = 1.0F; | |
matrix.f96 = (f1 * 4.0F) / (2.0F - f1); | |
matrix.f60 = 1.0F / fov; | |
matrix.f80 = (f1 + 2.0F) / (2.0F - f1); | |
matrix.f40 = 1.0F / asp; | |
projection = matrix; | |
f1 = this->field_1620.field_20 * 1.28F; | |
MatrixStack::Ref view = MatrixStack::View.push(); | |
view.stack.field_C = 1; | |
view.matrix.scale({f1, f1, f1}); | |
Color skyColor = this->dimension.getSkyColor(cameraEntity, partialTicks); | |
float ambientBrightness = this->getAmbientBrightness(); | |
float darkness = this->_skyDarkeningFactor(); | |
float r = (skyColor.r * ambientBrightness) - darkness; | |
float g = (skyColor.g * ambientBrightness) - darkness; | |
float b = (skyColor.b * ambientBrightness) - darkness; | |
float a = 1.0F; | |
currentShaderColor.setColor({r, g, b, a}); | |
this->skyMesh.render(this->skyMaterial, 0, 0); | |
this->_renderSunOrMoon(partialTicks, true); | |
this->_renderSunOrMoon(partialTicks, false); | |
this->_renderStars(partialTicks); | |
mce::RenderContextImmediate::get().setDepthRange(0.0F, 0.7F); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
21/10