mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-06-03 17:12:54 +00:00
Merge pull request #175 from realffqq/dev
fix: restore and fix entity, block and hand lighting
This commit is contained in:
commit
2c3a816e4b
|
|
@ -569,7 +569,7 @@ void C4JRender::TextureBind(int idx)
|
|||
}
|
||||
}
|
||||
|
||||
void C4JRender::TextureBindVertex(int idx)
|
||||
void C4JRender::TextureBindVertex(int idx, bool scaleLight)
|
||||
{
|
||||
// Unit 1 used for lightmapping in fixed-function or standard shaders
|
||||
::glActiveTexture(GL_TEXTURE1);
|
||||
|
|
@ -583,7 +583,20 @@ void C4JRender::TextureBindVertex(int idx)
|
|||
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
|
||||
// 4jcraft: jank workaround for entities
|
||||
// referenced from the disabled code in GameRenderer::turnOnLightLayer
|
||||
if (scaleLight)
|
||||
{
|
||||
::glMatrixMode(GL_TEXTURE);
|
||||
::glLoadIdentity();
|
||||
float s = 1 / 16.0f / 15.0f * 15 / 16;
|
||||
::glScalef(s, s, s);
|
||||
::glTranslatef(8.0f, 8.0f, 8.0f);
|
||||
::glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
}
|
||||
|
||||
::glActiveTexture(GL_TEXTURE0);
|
||||
::glFlush();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ public:
|
|||
int TextureCreate();
|
||||
void TextureFree(int idx);
|
||||
void TextureBind(int idx);
|
||||
void TextureBindVertex(int idx);
|
||||
void TextureBindVertex(int idx, bool scaleLight = false);
|
||||
void TextureSetTextureLevels(int levels);
|
||||
int TextureGetTextureLevels();
|
||||
void TextureData(int width, int height, void *data, int level, eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw);
|
||||
|
|
|
|||
|
|
@ -777,14 +777,14 @@ void GameRenderer::renderItemInHand(float a, int eye)
|
|||
{
|
||||
if (!mc->options->hideGui && !mc->gameMode->isCutScene())
|
||||
{
|
||||
//turnOnLightLayer(a); // 4jcraft: disable light layer on handrenderer similarly to how it was done on the chunk render (this makes the hand look proper)
|
||||
turnOnLightLayer(a, true);
|
||||
PIXBeginNamedEvent(0,"Item in hand render");
|
||||
// 4jcraft: add null pointer check to itemInHandRenderer to prevent a occasional seg fault
|
||||
if (itemInHandRenderer != nullptr) {
|
||||
itemInHandRenderer->render(a);
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
//turnOffLightLayer(a); // 4jcraft: disable light layer on handrenderer similarly to how it was done on the chunk render (this makes the hand look proper)
|
||||
turnOffLightLayer(a);
|
||||
}
|
||||
}
|
||||
glPopMatrix();
|
||||
|
|
@ -806,21 +806,26 @@ void GameRenderer::renderItemInHand(float a, int eye)
|
|||
// 4J - change brought forward from 1.8.2
|
||||
void GameRenderer::turnOffLightLayer(double alpha)
|
||||
{ // 4J - TODO
|
||||
#if 0
|
||||
// 4jcraft: manually handle this in order to ensure that the light layer is turned off correctly
|
||||
#if 1
|
||||
if (SharedConstants::TEXTURE_LIGHTING)
|
||||
{
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
#endif
|
||||
RenderManager.TextureBindVertex(-1);
|
||||
//RenderManager.TextureBindVertex(-1);
|
||||
}
|
||||
|
||||
// 4J - change brought forward from 1.8.2
|
||||
void GameRenderer::turnOnLightLayer(double alpha)
|
||||
void GameRenderer::turnOnLightLayer(double alpha, bool scaleLight)
|
||||
{ // 4J - TODO
|
||||
#if 0
|
||||
if (SharedConstants::TEXTURE_LIGHTING)
|
||||
|
|
@ -851,7 +856,7 @@ void GameRenderer::turnOnLightLayer(double alpha)
|
|||
#endif
|
||||
// update light texture
|
||||
// todo: check implementation of getLightTexture.
|
||||
RenderManager.TextureBindVertex(getLightTexture(mc->player->GetXboxPad(), mc->level));
|
||||
RenderManager.TextureBindVertex(getLightTexture(mc->player->GetXboxPad(), mc->level), scaleLight);
|
||||
#if 0
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
|
@ -971,7 +976,7 @@ void GameRenderer::updateLightTexture(float a)
|
|||
int g = (int) (_g * 255);
|
||||
int b = (int) (_b * 255);
|
||||
|
||||
#if ( defined _DURANGO || defined _WIN64 || __PSVITA__ )
|
||||
#if ( defined _DURANGO || defined _WIN64 || __PSVITA__ || __linux__ )
|
||||
lightPixels[j][i] = a << 24 | b << 16 | g << 8 | r;
|
||||
#elif ( defined _XBOX || defined __ORBIS__ )
|
||||
lightPixels[j][i] = a << 24 | r << 16 | g << 8 | b;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public:
|
|||
float blg;
|
||||
float blgt;
|
||||
void turnOffLightLayer(double alpha);
|
||||
void turnOnLightLayer(double alpha);
|
||||
void turnOnLightLayer(double alpha, bool scaleLight = false);
|
||||
private:
|
||||
void tickLightTexture();
|
||||
void updateLightTexture(float a);
|
||||
|
|
|
|||
|
|
@ -518,7 +518,7 @@ void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a)
|
|||
TileEntityRenderDispatcher::yOff = (player->yOld + (player->y - player->yOld) * a);
|
||||
TileEntityRenderDispatcher::zOff = (player->zOld + (player->z - player->zOld) * a);
|
||||
|
||||
// mc->gameRenderer->turnOnLightLayer(a); // 4J - brought forward from 1.8.2
|
||||
mc->gameRenderer->turnOnLightLayer(a, true); // 4J - brought forward from 1.8.2
|
||||
|
||||
std::vector<std::shared_ptr<Entity> > entities = level[playerIndex]->getAllEntities();
|
||||
totalEntities = (int)entities.size();
|
||||
|
|
@ -600,7 +600,7 @@ void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a)
|
|||
|
||||
LeaveCriticalSection(&m_csRenderableTileEntities);
|
||||
|
||||
// mc->gameRenderer->turnOffLightLayer(a); // 4J - brought forward from 1.8.2
|
||||
mc->gameRenderer->turnOffLightLayer(a); // 4J - brought forward from 1.8.2
|
||||
}
|
||||
|
||||
std::wstring LevelRenderer::gatherStats1()
|
||||
|
|
@ -742,7 +742,7 @@ int LevelRenderer::renderChunks(int from, int to, int layer, double alpha)
|
|||
|
||||
#if 1
|
||||
// 4J - cut down version, we're not using offsetted render lists, or a sorted chunk list, anymore
|
||||
// mc->gameRenderer->turnOnLightLayer(alpha); // 4J - brought forward from 1.8.2
|
||||
mc->gameRenderer->turnOnLightLayer(alpha); // 4J - brought forward from 1.8.2
|
||||
shared_ptr<Mob> player = mc->cameraTargetPlayer;
|
||||
double xOff = player->xOld + (player->x - player->xOld) * alpha;
|
||||
double yOff = player->yOld + (player->y - player->yOld) * alpha;
|
||||
|
|
@ -838,7 +838,7 @@ int LevelRenderer::renderChunks(int from, int to, int layer, double alpha)
|
|||
#endif // __PS3__
|
||||
|
||||
glPopMatrix();
|
||||
// mc->gameRenderer->turnOffLightLayer(alpha); // 4J - brought forward from 1.8.2
|
||||
mc->gameRenderer->turnOffLightLayer(alpha); // 4J - brought forward from 1.8.2
|
||||
|
||||
#else
|
||||
_renderChunks.clear();
|
||||
|
|
|
|||
|
|
@ -942,9 +942,15 @@ void Tesselator::vertex(float x, float y, float z)
|
|||
#ifdef _XBOX
|
||||
_array->data[p + 7] = ( ( _tex2 >> 16 ) & 0xffff ) | ( _tex2 << 16 );
|
||||
#else
|
||||
#ifdef __PS3__
|
||||
// 4jcraft: we will be lighting the blocks right in here
|
||||
#if defined(__PS3__) || defined (__linux__)
|
||||
#ifdef __PS3__
|
||||
int16_t tex2U = ((int16_t*)&_tex2)[1] + 8;
|
||||
int16_t tex2V = ((int16_t*)&_tex2)[0] + 8;
|
||||
#else
|
||||
int16_t tex2U = ((int16_t*)&_tex2)[0] + 8;
|
||||
int16_t tex2V = ((int16_t*)&_tex2)[1] + 8;
|
||||
#endif
|
||||
int16_t* pShortArray = (int16_t*)&_array->data[p + 7];
|
||||
pShortArray[0] = tex2U;
|
||||
pShortArray[1] = tex2V;
|
||||
|
|
|
|||
Loading…
Reference in a new issue