Skip to content

Instantly share code, notes, and snippets.

View papalqi's full-sized avatar
🎯
Focusing

黄琦 papalqi

🎯
Focusing
View GitHub Profile
@papalqi
papalqi / ResetImageDataToNewSize.cpp
Last active May 10, 2023 07:02
ResetImageDataToNewSize
void Heightmap::GetHeightMapMipmapData(dynamic_array<SInt16>& heights, int mipLevel) const
{
float skipScale = 1 << mipLevel;
int VertexNum = (GetResolution()-1);
int MipmapVertexNum=VertexNum/skipScale;
float scaleFactor = static_cast<float>(GetHeight() - 1) / (MipmapVertexNum - 1);
heights.reserve(MipmapVertexNum*MipmapVertexNum);
for (int y = 0; y < MipmapVertexNum; y++)
{
for (int x = 0; x < MipmapVertexNum; x++)
@papalqi
papalqi / GetBuildData.cpp
Last active March 9, 2022 02:16
GetBuildData
const FMeshMapBuildData* GetMeshMapBuildData() const
{
AActor* Owner = GetOwner();
if (Owner)
{
ULevel* OwnerLevel = Owner->GetLevel();
if (OwnerLevel && OwnerLevel->OwningWorld)
{
@papalqi
papalqi / GeneratePlatformVertexData.cpp
Last active January 30, 2024 19:09
GeneratePlatformVertexData.cpp
void ULandscapeComponent::GeneratePlatformVertexData(const ITargetPlatform* TargetPlatform)
{
if (IsTemplate())
{
return;
}
check(GetHeightmap());
check(GetHeightmap()->Source.GetFormat() == TSF_BGRA8);
TArray<uint8> NewPlatformData;
@papalqi
papalqi / VSDF
Last active December 28, 2021 14:03
ShaderToy
#define M void mainImage(out vec4 r,vec2 u){vec2 i=u-u;r-=r
#define A texelFetch(iChannel0,ivec2(i+u),0)
M;for(int k=0;++k<289;r+=A*(.3-.03*dot(i,i))*exp(-.1*dot(i,i)))i=vec2(k%17,k/17)-8.;r=iFrame<2?-u.xyxy:clamp(r,0.,1.);}
M-A;}
@papalqi
papalqi / Graphics Programmers Tips.md
Last active December 28, 2021 06:33
Graphics Programmers Tips

当我们遇到图形问题时,需要一个清单列表来帮助我们逐个归类到底是那种问题类型。此清单将不停更新,以备日后参考。

1.1浮点问题

如果你观察条纹或摩尔纹,这表明可能是浮点精度问题。

1.2 管道状态问题

有时候结果是完全错误的,而且远远超出了你的预期。在这种情况下,有必要仔细检查整个管道状态。

@papalqi
papalqi / SSAO.hlsl
Last active December 13, 2021 02:05
ssao
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
PostprocessAmbientOcclusion.usf: To generate ambient occlusion as a postprocess
=============================================================================*/
#include "Common.usf"
#include "PostProcessCommon.usf"
#include "DeferredShadingCommon.usf"
We couldn’t find that file to show.
@papalqi
papalqi / GetUE4EnginePath.bat
Last active November 29, 2021 09:26
Get UE4 Engine Path
@echo off
setlocal EnableDelayedExpansion
rem Get the Unreal Engine used by this project by querying the registry for the engine association found in the .uproject.
set UNREAL_ENGINE=""
set UPROJECT=""
rem First find the .uproject
for /f "delims=" %%A in (' powershell -Command "Get-ChildItem %~dp0../ -Depth 1 -Filter *.uproject -File | %% {$_.FullName}" ') do set UPROJECT="%%A"