diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture')
6 files changed, 295 insertions, 0 deletions
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 <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <spu_intrinsics.h> +#include <cell/spurs.h> +#include <spu_printf.h> +#include <cell/dma.h> +#include <cell/spurs/job_queue.h> + +#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 @@ +<?xml version="1.0" encoding="us-ascii"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|PS3"> + <Configuration>Debug</Configuration> + <Platform>PS3</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|PS3"> + <Configuration>Release</Configuration> + <Platform>PS3</Platform> + </ProjectConfiguration> + </ItemGroup> + <ItemGroup> + <ClInclude Include="GameRenderer_updateLightTexture.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="GameRenderer_updateLightTexture.cpp" /> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{1F6ECBFE-3089-457D-8A11-5CFDC0392439}</ProjectGuid> + <ProjectName>GameRenderer_updateLightTexture</ProjectName> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>SPU</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>SPU</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">PS3_Debug\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">PS3_Debug\</IntDir> + <ExtensionsToDeleteOnClean Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean)</ExtensionsToDeleteOnClean> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'" /> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">false</GenerateManifest> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">PS3_Release\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">PS3_Release\</IntDir> + <ExtensionsToDeleteOnClean Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean)</ExtensionsToDeleteOnClean> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|PS3'" /> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">false</GenerateManifest> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">$(ProjectName)</TargetName> + <SpursUsage>SpursInit</SpursUsage> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">$(ProjectName)</TargetName> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'"> + <ClCompile> + <AdditionalOptions>-ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions)</AdditionalOptions> + <AdditionalIncludeDirectories>$(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <GenerateDebugInformation>true</GenerateDebugInformation> + <PreprocessorDefinitions>SN_TARGET_PS3_SPU;_DEBUG;__GCC__;SPU;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <ProjectReference> + <LinkLibraryDependencies>true</LinkLibraryDependencies> + </ProjectReference> + <Link> + <AdditionalOptions>-Wl,--gc-sections -g %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>-ldma;-lspurs_jq;%(AdditionalDependencies)</AdditionalDependencies> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + </Link> + <SpuElfConversion> + <EmbedFormat>JobBin2</EmbedFormat> + </SpuElfConversion> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'"> + <ClCompile> + <AdditionalOptions>-ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions)</AdditionalOptions> + <AdditionalIncludeDirectories>$(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <GenerateDebugInformation>true</GenerateDebugInformation> + <OptimizationLevel>Level3</OptimizationLevel> + <PreprocessorDefinitions>SN_TARGET_PS3_SPU;NDEBUG;__GCC__;SPU;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <ProjectReference> + <LinkLibraryDependencies>true</LinkLibraryDependencies> + </ProjectReference> + <Link> + <AdditionalOptions>-Wl,--gc-sections -g %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>-ldma;-lspurs_jq;%(AdditionalDependencies)</AdditionalDependencies> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + </Link> + <SpuElfConversion> + <EmbedFormat>JobBin2</EmbedFormat> + <OutputFile>..\$(TargetName).ppu$(ObjectExt)</OutputFile> + </SpuElfConversion> + </ItemDefinitionGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{881f28ee-ca74-4afc-94a6-2346cb88f86d}</UniqueIdentifier> + <Extensions>cpp;c;cxx;cc;s;asm</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClInclude Include="GameRenderer_updateLightTexture.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="GameRenderer_updateLightTexture.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> +</Project>
\ 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 --- /dev/null +++ b/Minecraft.Client/PS3/SPU_Tasks/GameRenderer_updateLightTexture/stdafx.h |
