From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- .../GameRenderer_updateLightTexture.cpp | 143 +++++++++++++++++++++ .../GameRenderer_updateLightTexture.h | 20 +++ .../GameRenderer_updateLightTexture.spu.vcxproj | 105 +++++++++++++++ ...Renderer_updateLightTexture.spu.vcxproj.filters | 17 +++ ...eRenderer_updateLightTexture.spu.vcxproj.vspscc | 10 ++ .../GameRenderer_updateLightTexture/stdafx.h | 0 6 files changed, 295 insertions(+) create mode 100644 Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.cpp create mode 100644 Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.h create mode 100644 Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj create mode 100644 Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj.filters create mode 100644 Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj.vspscc create mode 100644 Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/stdafx.h (limited to 'Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture') diff --git a/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.cpp b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.cpp new file mode 100644 index 00000000..7199b8fc --- /dev/null +++ b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.cpp @@ -0,0 +1,143 @@ +/* SCE CONFIDENTIAL +PlayStation(R)3 Programmer Tool Runtime Library 430.001 +* Copyright (C) 2007 Sony Computer Entertainment Inc. +* All Rights Reserved. +*/ + +/* common headers */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "..\Common\DmaData.h" + +#include "GameRenderer_updateLightTexture.h" + +static const bool sc_verbose = false; + +CellSpursJobContext2* g_pSpursJobContext; + + + + +void updateLightTexture(GameRenderer_updateLightTexture_dataIn& dataIn) +{ + // 4J - we've added separate light textures for all dimensions, and this loop to update them all here + for(int j = 0; j < 3; j++ ) + { + int lightPixels[16*16]; + GameRenderer_updateLightTexture_dataIn::LevelData& levelDataIn = dataIn.m_levelData[j]; + if (levelDataIn.m_valid == false) continue; + for (int i = 0; i < 256; i++) + { + float darken = levelDataIn.m_skyDarken * 0.95f + 0.05f; + float sky = levelDataIn.m_brightnessRamp[i / 16] * darken; + float block = levelDataIn.m_brightnessRamp[i % 16] * (dataIn.blr * 0.1f + 1.5f); + + if (levelDataIn.m_lightningBoltTime > 0) + { + sky = levelDataIn.m_brightnessRamp[i / 16]; + } + + float rs = sky * (levelDataIn.m_skyDarken * 0.65f + 0.35f); + float gs = sky * (levelDataIn.m_skyDarken * 0.65f + 0.35f); + float bs = sky; + + /* + * float dr = darken; dr = dr - dr * dr; System.out.println(dr); if (dr > 0) { + * gs += dr * 0.5f; rs += dr; } + */ + + // rs = gs = bs; + + float rb = block; + float gb = block * ((block * 0.6f + 0.4f) * 0.6f + 0.4f); + float bb = block * ((block * block) * 0.6f + 0.4f); + + float _r = (rs + rb); + float _g = (gs + gb); + float _b = (bs + bb); + + _r = _r * 0.96f + 0.03f; + _g = _g * 0.96f + 0.03f; + _b = _b * 0.96f + 0.03f; + + if (levelDataIn.m_dimensionID == 1) + { + _r = (0.22f + rb * 0.75f); + _g = (0.28f + gb * 0.75f); + _b = (0.25f + bb * 0.75f); + } + + float brightness = 0.0f; // 4J - TODO - was mc->options->gamma; + if (_r > 1) _r = 1; + if (_g > 1) _g = 1; + if (_b > 1) _b = 1; + + float ir = 1 - _r; + float ig = 1 - _g; + float ib = 1 - _b; + ir = 1 - (ir * ir * ir * ir); + ig = 1 - (ig * ig * ig * ig); + ib = 1 - (ib * ib * ib * ib); + _r = _r * (1 - brightness) + ir * brightness; + _g = _g * (1 - brightness) + ig * brightness; + _b = _b * (1 - brightness) + ib * brightness; + + + _r = _r * 0.96f + 0.03f; + _g = _g * 0.96f + 0.03f; + _b = _b * 0.96f + 0.03f; + + + if (_r > 1) _r = 1; + if (_g > 1) _g = 1; + if (_b > 1) _b = 1; + if (_r < 0) _r = 0; + if (_g < 0) _g = 0; + if (_b < 0) _b = 0; + + int a = 255; + int r = (int) (_r * 255); + int g = (int) (_g * 255); + int b = (int) (_b * 255); + + lightPixels[i] = r << 24 | g << 16 | b << 8 | a; + } + DmaData_SPU::putAndWait(lightPixels, (uintptr_t)levelDataIn.m_lightPixelsOutput, 16*16*sizeof(int)); + } +} + + + + + + + + + +void cellSpursJobQueueMain(CellSpursJobContext2 *pContext, CellSpursJob256 *pJob) +{ +// CellSpursTaskId idTask = cellSpursGetTaskId(); + unsigned int idSpu = cellSpursGetCurrentSpuId(); + + if(sc_verbose) + spu_printf("GameRenderer_updateLightTexture [SPU#%u] start\n", idSpu); + + g_pSpursJobContext = pContext; + + uint32_t eaDataIn = pJob->workArea.userData[0]; + + GameRenderer_updateLightTexture_dataIn dataIn; + DmaData_SPU::getAndWait(&dataIn, eaDataIn, sizeof(GameRenderer_updateLightTexture_dataIn)); + updateLightTexture(dataIn); + + if(sc_verbose) + spu_printf("GameRenderer_updateLightTexture [SPU#%u] exit\n", idSpu); +} + diff --git a/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.h b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.h new file mode 100644 index 00000000..3dfcc3d5 --- /dev/null +++ b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.h @@ -0,0 +1,20 @@ +#pragma once + +static const int LEVEL_MAX_BRIGHTNESS = 15; +class GameRenderer_updateLightTexture_dataIn +{ +public: + class LevelData + { + public: + bool m_valid; + float m_skyDarken; + float m_brightnessRamp[LEVEL_MAX_BRIGHTNESS + 1]; + int m_lightningBoltTime; + int m_dimensionID; + int* m_lightPixelsOutput; + }; + + LevelData m_levelData[3]; + float blr; +}; diff --git a/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj new file mode 100644 index 00000000..8cb7966e --- /dev/null +++ b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj @@ -0,0 +1,105 @@ + + + + + Debug + PS3 + + + Release + PS3 + + + + + + + + + + {1F6ECBFE-3089-457D-8A11-5CFDC0392439} + GameRenderer_updateLightTexture + + + + Application + SPU + + + Application + SPU + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + PS3_Debug\ + PS3_Debug\ + *.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean) + + false + PS3_Release\ + PS3_Release\ + *.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean) + + false + $(ProjectName) + SpursInit + $(ProjectName) + + + + -ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions) + $(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories) + true + SN_TARGET_PS3_SPU;_DEBUG;__GCC__;SPU;%(PreprocessorDefinitions) + + + true + + + -Wl,--gc-sections -g %(AdditionalOptions) + -ldma;-lspurs_jq;%(AdditionalDependencies) + false + + + + + JobBin2 + + + + + -ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions) + $(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories) + true + Level3 + SN_TARGET_PS3_SPU;NDEBUG;__GCC__;SPU;%(PreprocessorDefinitions) + + + true + + + -Wl,--gc-sections -g %(AdditionalOptions) + -ldma;-lspurs_jq;%(AdditionalDependencies) + false + + + + + JobBin2 + ..\$(TargetName).ppu$(ObjectExt) + + + + + + \ No newline at end of file diff --git a/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj.filters b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj.filters new file mode 100644 index 00000000..4e9f4fee --- /dev/null +++ b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + {881f28ee-ca74-4afc-94a6-2346cb88f86d} + cpp;c;cxx;cc;s;asm + + + + + + + + Source Files + + + \ No newline at end of file diff --git a/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj.vspscc b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj.vspscc new file mode 100644 index 00000000..b6d32892 --- /dev/null +++ b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/GameRenderer_updateLightTexture.spu.vcxproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/stdafx.h b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/stdafx.h new file mode 100644 index 00000000..e69de29b -- cgit v1.2.3