Шейдеры на лампочки (#655)
* +light shader * fixed * toggling logic * nice * add option to settings --------- Co-authored-by: CaYpeN1 <artem7771art@gmail.com>
This commit is contained in:
@@ -33,8 +33,8 @@
|
||||
state: base
|
||||
- type: PointLight
|
||||
color: "#FFE4CE" # 5000K color temp
|
||||
energy: 0.8
|
||||
radius: 10
|
||||
energy: 0.65
|
||||
radius: 6
|
||||
softness: 1
|
||||
offset: "0, -0.5"
|
||||
- type: Damageable
|
||||
@@ -70,6 +70,7 @@
|
||||
- !type:PlaySoundBehavior
|
||||
sound:
|
||||
collection: GlassBreak
|
||||
- type: LightingOverlay # WD
|
||||
- type: LightMark
|
||||
placement:
|
||||
mode: SnapgridCenter
|
||||
@@ -154,9 +155,9 @@
|
||||
types:
|
||||
Heat: 5
|
||||
- type: PointLight
|
||||
radius: 15
|
||||
energy: 1
|
||||
softness: 0.9
|
||||
radius: 10
|
||||
energy: 0.7
|
||||
softness: 1
|
||||
color: "#EEEEFF"
|
||||
|
||||
- type: entity
|
||||
@@ -166,8 +167,8 @@
|
||||
components:
|
||||
- type: PointLight
|
||||
radius: 10
|
||||
energy: 2.5
|
||||
softness: 0.9
|
||||
energy: 0.7
|
||||
softness: 1
|
||||
color: "#EEEEFF"
|
||||
|
||||
#Exterior lights
|
||||
@@ -189,9 +190,9 @@
|
||||
suffix: Always Powered, Blue
|
||||
components:
|
||||
- type: PointLight
|
||||
radius: 12
|
||||
energy: 4.5
|
||||
softness: 0.5
|
||||
radius: 10
|
||||
energy: 0.7
|
||||
softness: 1
|
||||
color: "#B4FCF0"
|
||||
|
||||
#Sodium lights
|
||||
@@ -208,8 +209,8 @@
|
||||
Heat: 5
|
||||
- type: PointLight
|
||||
radius: 10
|
||||
energy: 2.5
|
||||
softness: 0.9
|
||||
energy: 0.7
|
||||
softness: 1
|
||||
color: "#FFAF38"
|
||||
|
||||
- type: entity
|
||||
@@ -219,8 +220,8 @@
|
||||
components:
|
||||
- type: PointLight
|
||||
radius: 10
|
||||
energy: 4
|
||||
softness: 0.5
|
||||
energy: 0.7
|
||||
softness: 1
|
||||
color: "#FFAF38"
|
||||
|
||||
#Small lights
|
||||
@@ -240,9 +241,9 @@
|
||||
sprite: Structures/Wallmounts/Lighting/light_small.rsi
|
||||
state: base
|
||||
- type: PointLight
|
||||
energy: 1.0
|
||||
radius: 6
|
||||
softness: 1.1
|
||||
radius: 4
|
||||
energy: 0.7
|
||||
softness: 1
|
||||
enabled: true
|
||||
- type: Damageable
|
||||
damageContainer: StructuralInorganic
|
||||
@@ -324,7 +325,7 @@
|
||||
- type: PointLight
|
||||
enabled: true
|
||||
radius: 8
|
||||
energy: 1
|
||||
energy: 0.7
|
||||
softness: 1
|
||||
color: "#EEEEFF"
|
||||
- type: PoweredLight
|
||||
|
||||
@@ -2,3 +2,8 @@
|
||||
id: ShockWave
|
||||
kind: source
|
||||
path: "/Textures/White/Shaders/shock_wave.swsl"
|
||||
|
||||
- type: shader
|
||||
id: LightingOverlay
|
||||
kind: source
|
||||
path: "/Textures/White/Shaders/light.swsl"
|
||||
BIN
Resources/Textures/Effects/LightMasks/lightmask_lamp.png
Normal file
BIN
Resources/Textures/Effects/LightMasks/lightmask_lamp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
85
Resources/Textures/White/Shaders/light.swsl
Normal file
85
Resources/Textures/White/Shaders/light.swsl
Normal file
@@ -0,0 +1,85 @@
|
||||
uniform sampler2D SCREEN_TEXTURE;
|
||||
|
||||
const highp float[3] weights = float[](0.2, 0.0625, 0.0375);
|
||||
|
||||
// Function to adjust alpha
|
||||
highp float adjustAlpha(highp vec4 background) {
|
||||
highp float avgColor = dot(background.rgb, vec3(0.3333));
|
||||
highp float boost = (1.0 - (1.0 - avgColor) / 1.25);
|
||||
highp float transition = clamp((avgColor - 0.035) / 0.125, 0.0, 2.0);
|
||||
return boost * (1.0 - transition) + transition;
|
||||
}
|
||||
|
||||
// Function to warm up the color
|
||||
highp vec3 warmColor(highp vec3 color) {
|
||||
highp vec3 warmTint = vec3(1.0, 0.8, 0.6);
|
||||
return color * warmTint;
|
||||
}
|
||||
|
||||
// Function to adjust saturation
|
||||
highp vec3 adjustSaturation(highp vec3 color, highp float saturation) {
|
||||
highp float luminance = dot(color, vec3(0.299, 0.587, 0.114));
|
||||
return mix(vec3(luminance), color, saturation);
|
||||
}
|
||||
|
||||
// Function to add haze effect
|
||||
highp vec4 addHaze(highp vec4 color, highp float intensity) {
|
||||
highp vec3 haze = vec3(0.9, 0.85, 0.8);
|
||||
return vec4(mix(color.rgb, haze, intensity), color.a);
|
||||
}
|
||||
|
||||
// Function to perform enhanced blur calculation
|
||||
highp vec4 enhancedBlur(highp vec2 offset, highp vec2 uv, highp vec2 frag, lowp int step) {
|
||||
highp vec4 bsample = texture2D(TEXTURE, uv + offset * TEXTURE_PIXEL_SIZE) * weights[step];
|
||||
bsample.rgb = warmColor(bsample.rgb);
|
||||
bsample.rgb = adjustSaturation(bsample.rgb, 1.2);
|
||||
bsample = addHaze(bsample, 0.1);
|
||||
bsample.a *= adjustAlpha(zTextureSpec(SCREEN_TEXTURE, (frag + offset) * SCREEN_PIXEL_SIZE));
|
||||
return bsample;
|
||||
}
|
||||
|
||||
// Function to calculate offset based on index
|
||||
highp vec2 calculateOffset(highp int index, highp float step) {
|
||||
highp vec3 offsetBase = vec3(1.0, 0.0, -1.0);
|
||||
highp vec2 offsets[8];
|
||||
offsets[0] = offsetBase.xy;
|
||||
offsets[1] = -offsetBase.xy;
|
||||
offsets[2] = offsetBase.yx;
|
||||
offsets[3] = -offsetBase.yx;
|
||||
offsets[4] = offsetBase.xx;
|
||||
offsets[5] = offsetBase.xz;
|
||||
offsets[6] = offsetBase.zx;
|
||||
offsets[7] = offsetBase.zz;
|
||||
|
||||
return offsets[index % 8] * step;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
highp vec4 sprite = zTexture(UV);
|
||||
|
||||
if (sprite.a == 0.0) {
|
||||
discard;
|
||||
}
|
||||
|
||||
highp vec3 offsetBase = vec3(1.0, 0.0, -1.0);
|
||||
highp vec4 sum = enhancedBlur(vec2(0), UV.xy, FRAGCOORD.xy, 0);
|
||||
|
||||
highp vec4 bsample;
|
||||
highp float floatstep = 0.0;
|
||||
|
||||
for (lowp int i = 0; i < 2; i++) {
|
||||
floatstep += 1.0;
|
||||
|
||||
for (lowp int j = 0; j < 8; j++) {
|
||||
highp vec2 offset = calculateOffset(j, floatstep);
|
||||
bsample = enhancedBlur(offset, UV.xy, FRAGCOORD.xy, i + 1);
|
||||
sum += bsample;
|
||||
}
|
||||
}
|
||||
|
||||
sum.rgb = warmColor(sum.rgb);
|
||||
sum.rgb = adjustSaturation(sum.rgb, 1.1);
|
||||
sum = addHaze(sum, 0.05);
|
||||
|
||||
COLOR = sum;
|
||||
}
|
||||
Reference in New Issue
Block a user