功能更新
This commit is contained in:
20
Melskin/Shaders/BrightnessContrastEffect.hlsl
Normal file
20
Melskin/Shaders/BrightnessContrastEffect.hlsl
Normal file
@@ -0,0 +1,20 @@
|
||||
sampler2D inputTex : register(S0);
|
||||
//范围-1~1
|
||||
float brightness : register(C0);
|
||||
//范围-1~1
|
||||
float contrast : register(C1);
|
||||
|
||||
static const float PI = 3.14159265f;
|
||||
|
||||
float4 main(float2 uv : TEXCOORD) : COLOR
|
||||
{
|
||||
|
||||
//UI的源颜色
|
||||
float4 sourceColor = tex2D(inputTex, uv);
|
||||
//计算对比度系数
|
||||
float k = tan((45 + 44 * contrast) / 180 * PI);
|
||||
//计算亮度对比度
|
||||
float4 outColor = (sourceColor - 0.5 * (1 - brightness)) * k + 0.5 * (1 + brightness);
|
||||
|
||||
return outColor;
|
||||
}
|
||||
BIN
Melskin/Shaders/BrightnessContrastEffect.ps
Normal file
BIN
Melskin/Shaders/BrightnessContrastEffect.ps
Normal file
Binary file not shown.
10
Melskin/Shaders/CompileEffect.bat
Normal file
10
Melskin/Shaders/CompileEffect.bat
Normal file
@@ -0,0 +1,10 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set FXC_PATH="C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\fxc.exe"
|
||||
|
||||
%FXC_PATH% NeumorphismShadowEffect.fx /T ps_3_0 /Fo NeumorphismShadowEffect.ps
|
||||
|
||||
echo.
|
||||
echo press any key to finish.
|
||||
pause > nul
|
||||
28
Melskin/Shaders/LightedSurfaceEffect.hlsl
Normal file
28
Melskin/Shaders/LightedSurfaceEffect.hlsl
Normal file
@@ -0,0 +1,28 @@
|
||||
sampler2D inputTex : register(S0);
|
||||
float2 mousePos : register(C0);
|
||||
float2 uiSize : register(C1);
|
||||
float lightSize : register(C2);
|
||||
float intensity : register(C3);
|
||||
float4 lightColor : register(C4);
|
||||
|
||||
static const float PI = 3.14159265f;
|
||||
|
||||
float4 main(float2 uv : TEXCOORD) : COLOR
|
||||
{
|
||||
//UI的源颜色
|
||||
float4 sourceColor = tex2D(inputTex, uv);
|
||||
//计算当前UV值的实际尺寸坐标
|
||||
float xPos = uv.x * uiSize.x;
|
||||
float yPos = uv.y * uiSize.y;
|
||||
//计算当前片元和鼠标位置的实际距离
|
||||
float distanceMouseFrag = length(float2(xPos - mousePos.x, yPos - mousePos.y));
|
||||
//归一化距离(0~1)
|
||||
float uniformedDistance = min(distanceMouseFrag / lightSize,1);
|
||||
//距离转渐进强度(1~0)
|
||||
float intensityFrag = cos(uniformedDistance * PI) / 2.0f + 0.5f;
|
||||
//计算线性减淡
|
||||
float3 linearDodge = sourceColor.xyz + lightColor.xyz * intensityFrag * intensity * sourceColor.a;
|
||||
|
||||
return float4(linearDodge, sourceColor.a);
|
||||
|
||||
}
|
||||
BIN
Melskin/Shaders/LightedSurfaceEffect.ps
Normal file
BIN
Melskin/Shaders/LightedSurfaceEffect.ps
Normal file
Binary file not shown.
Reference in New Issue
Block a user