This commit is contained in:
LZX committed 2026-08-16 00:26:14 +08:00
1 parent 175afc643c
commit dbae22ab4c
5 files changed
+531 -96

No files matched your search

@@ -17,6 +17,7 @@ public class ShaderRegistry {
private static ShaderInstance composite; private static ShaderInstance composite;
private static ShaderInstance outline; private static ShaderInstance outline;
private static ShaderInstance particleBloom; private static ShaderInstance particleBloom;
private static ShaderInstance devilsDevastationEnergy;
public static ShaderInstance getBlur() { public static ShaderInstance getBlur() {
return blur; return blur;
@@ -34,6 +35,10 @@ public class ShaderRegistry {
return particleBloom; return particleBloom;
} }
public static ShaderInstance getDevilsDevastationEnergy() {
return devilsDevastationEnergy;
}
@SubscribeEvent @SubscribeEvent
public static void registerShaders(RegisterShadersEvent event) { public static void registerShaders(RegisterShadersEvent event) {
try { try {
@@ -69,6 +74,14 @@ public class ShaderRegistry {
), ),
shader -> particleBloom = shader shader -> particleBloom = shader
); );
event.registerShader(
new ShaderInstance(
event.getResourceProvider(),
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "devils_devastation_energy"),
DefaultVertexFormat.NEW_ENTITY
),
shader -> devilsDevastationEnergy = shader
);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("Shader load error", e); throw new RuntimeException("Shader load error", e);
} }
@@ -3,13 +3,23 @@ package com.lzxnone.terraria.client.item.melee;
import com.lzxnone.terraria.entity.ModRenderTypes; import com.lzxnone.terraria.entity.ModRenderTypes;
import com.lzxnone.terraria.entity.projectile.StaticProjectile; import com.lzxnone.terraria.entity.projectile.StaticProjectile;
import com.lzxnone.terraria.entity.summon.StaticSummon; import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.client.event.ShaderRegistry;
import com.lzxnone.terraria.utils.*; import com.lzxnone.terraria.utils.*;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.shaders.Uniform;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferUploader;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.MeshData;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.math.Axis; import com.mojang.math.Axis;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@@ -20,6 +30,7 @@ import org.joml.Matrix4f;
import org.joml.Quaternionf; import org.joml.Quaternionf;
import org.joml.Vector3f; import org.joml.Vector3f;
import net.minecraft.client.Camera; import net.minecraft.client.Camera;
import net.neoforged.neoforge.client.GlStateBackup;
import java.util.*; import java.util.*;
import com.lzxnone.terraria.client.entity.projectile.IStaticProjectileRenderBehavior; import com.lzxnone.terraria.client.entity.projectile.IStaticProjectileRenderBehavior;
@@ -423,58 +434,6 @@ public class ClientDevilsDevastation {
} }
} }
public static void renderTubeSegmented(VertexConsumer buffer, Matrix4f matrix, Vec3 entityWorldPos,
List<Vec3> points, float[] radii,
Vector3f[] colors, float alpha,
float uvOffsetU, float uvOffsetV, float uvScaleU, float uvScaleV) {
int n = points.size();
if(n < 2 || radii.length < n || colors.length < n) return;
Vector3f[][] oriDirs = new Vector3f[n][3];
Vec3[] up = new Vec3[n], right = new Vec3[n];
for(int i = 0;i < n;i++) {
if(i == n - 1) oriDirs[i] = MathUtil.computeCoordinateSystem(points.get(n - 1).subtract(points.get(n - 2)).toVector3f(), 0);
else oriDirs[i] = MathUtil.computeCoordinateSystem(points.get(i + 1).subtract(points.get(i)).toVector3f(), 0);
up[i] = MathUtil.toVec3(oriDirs[i][1]);
right[i] = MathUtil.toVec3(oriDirs[i][2]);
}
for(int i = 0;i < n - 1;i++) {
float r0 = radii[i];
float r1 = radii[i + 1];
if(r0 <= 0.001F && r1 <= 0.001F) continue;
Vec3 N = right[i], B = up[i], N1 = right[i + 1], B1 = up[i + 1];
Vec3 P = points.get(i), P1 = points.get(i + 1);
Vector3f c0 = colors[i], c1 = colors[i + 1];
float u0 = uvOffsetU + uvScaleU * ((float)i / (float)(n - 1));
float u1 = uvOffsetU + uvScaleU * ((float)(i + 1) / (float)(n - 1));
for(int j = 0;j < RING;j++) {
float a0 = (float) (2.0 * Math.PI * j / RING);
float a1 = (float) (2.0 * Math.PI * (j + 1) / RING);
float v0 = (float) j / (float)RING + uvOffsetV;
float v1 = (float) (j + 1) / (float)RING + uvOffsetV;
Vec3 d0 = computeRingDir(N, B, a0);
Vec3 d1 = computeRingDir(N1, B1, a0);
Vec3 d0b = computeRingDir(N, B, a1);
Vec3 d1b = computeRingDir(N1, B1, a1);
Vec3 v00 = P.add(d0.scale(r0));
Vec3 v01 = P1.add(d1.scale(r1));
Vec3 v02 = P1.add(d1b.scale(r1));
Vec3 v03 = P.add(d0b.scale(r0));
for(int k = 0;k < 10;k++) {
writeVert(buffer, matrix, entityWorldPos, v00, u0, v0, alpha, c0.x(), c0.y(), c0.z());
writeVert(buffer, matrix, entityWorldPos, v01, u1, v0, alpha, c1.x(), c1.y(), c1.z());
writeVert(buffer, matrix, entityWorldPos, v02, u1, v1, alpha, c1.x(), c1.y(), c1.z());
writeVert(buffer, matrix, entityWorldPos, v03, u0, v1, alpha, c0.x(), c0.y(), c0.z());
}
}
}
}
public static Vec3 computeRingDir(Vec3 n, Vec3 b, float ang) { public static Vec3 computeRingDir(Vec3 n, Vec3 b, float ang) {
return n.scale(Math.cos(ang)).add(b.scale(Math.sin(ang))); return n.scale(Math.cos(ang)).add(b.scale(Math.sin(ang)));
} }
@@ -493,61 +452,163 @@ public class ClientDevilsDevastation {
.setNormal(0.0F, 1.0F, 0.0F); .setNormal(0.0F, 1.0F, 0.0F);
} }
//采样空间(光线步进长方体):x 厚度 ±0.25、y 长 0→32、z 宽 ±1
private static final float BLADE_MIN_X = -0.25f;
private static final float BLADE_MAX_X = 0.25f;
private static final float BLADE_MIN_Y = 0.0f;
private static final float BLADE_MAX_Y = 32.0f;
private static final float BLADE_MIN_Z = -1.0f;
private static final float BLADE_MAX_Z = 1.0f;
public static void renderEnergyWave(MultiBufferSource buffer, PoseStack poseStack, Entity entity) { public static void renderEnergyWave(MultiBufferSource buffer, PoseStack poseStack, Entity entity) {
Matrix4f matrix = poseStack.last().pose(); ShaderInstance shader = ShaderRegistry.getDevilsDevastationEnergy();
int time = entity.tickCount; if (shader == null) return;
poseStack.translate(0, 1.4, 0.6); poseStack.pushPose();
float baseRadius = 1.0f; GlStateBackup backup = new GlStateBackup();
float speed = 0.25f; RenderSystem.backupGlState(backup);
ShaderInstance prevShader = RenderSystem.getShader();
Vector3f colorA = new Vector3f(0.729f, 0.396f, 0.345f); try {
Vector3f colorB = new Vector3f(0.8f, 0.176f, 0.78f); if (buffer instanceof MultiBufferSource.BufferSource source) {
source.endBatch();
}
List<Vec3> points = new ArrayList<>(); poseStack.translate(0.0, 1.4, 0.2);
float[] outRadius = new float[ENERGY_WAVE_SEG + 1]; Matrix4f modelMatrix = new Matrix4f(poseStack.last().pose());
Vector3f[] outColors = new Vector3f[ENERGY_WAVE_SEG + 1];
for(int i = 0; i <= ENERGY_WAVE_SEG; i++) { //注入 uniform
float t = (float) i / ENERGY_WAVE_SEG; Uniform modelMat = shader.getUniform("ModelMat");
float y = t * ENERGY_WAVE_LENGTH; if (modelMat != null) modelMat.set(modelMatrix);
Uniform gameTime = shader.getUniform("EffectTime");
if (gameTime != null) gameTime.set((float) entity.tickCount);
Uniform colorA = shader.getUniform("ColorA");
if (colorA != null) colorA.set(0.729f, 0.396f, 0.345f, 1.0f);
Uniform colorB = shader.getUniform("ColorB");
if (colorB != null) colorB.set(0.8f, 0.176f, 0.78f, 1.0f);
float phase = time * speed * 6f - t * (float) Math.PI * 5; //GL 状态:加法混合 + 深度测试 + 背面剔除(代理盒只需朝向相机的面)
float wave = (float) Math.sin(phase); RenderSystem.setShader(() -> shader);
RenderSystem.enableBlend();
points.add(new Vec3(0, y, 0)); RenderSystem.blendFunc(
GlStateManager.SourceFactor.SRC_ALPHA,
float taper = (float) Math.cos(t * Math.PI * 0.5f); GlStateManager.DestFactor.ONE
float pulse = 0.7f + 0.3f * (0.5f + 0.5f * wave);
outRadius[i] = baseRadius * taper * pulse;
float blend = 0.5f + 0.5f * (float) Math.sin(time * 0.3f * speed - t * (float) Math.PI * 2);
outColors[i] = new Vector3f(
colorA.x + (colorB.x - colorA.x) * blend,
colorA.y + (colorB.y - colorA.y) * blend,
colorA.z + (colorB.z - colorA.z) * blend
); );
RenderSystem.enableDepthTest();
RenderSystem.depthMask(true);
RenderSystem.enableCull();
//加法混合下重复绘制 3 次 = 亮度叠加,补偿 LDR 无 bloom 时的亮度损失
for (int pass = 0; pass < 3; pass++) {
BufferBuilder bb = RenderSystem.renderThreadTesselator().begin(
VertexFormat.Mode.QUADS,
DefaultVertexFormat.NEW_ENTITY
);
addBox(
bb,
BLADE_MIN_X, BLADE_MIN_Y, BLADE_MIN_Z,
BLADE_MAX_X, BLADE_MAX_Y, BLADE_MAX_Z
);
BufferUploader.drawWithShader(Objects.requireNonNull(bb.build()));
}
} finally {
poseStack.popPose();
RenderSystem.depthMask(true);
RenderSystem.enableDepthTest();
RenderSystem.enableCull();
RenderSystem.defaultBlendFunc();
if (prevShader != null) {
RenderSystem.setShader(() -> prevShader);
}
RenderSystem.restoreGlState(backup);
}
} }
float[] inRadius = new float[ENERGY_WAVE_SEG + 1]; private static void addBox(
Vector3f[] inColors = new Vector3f[ENERGY_WAVE_SEG + 1]; BufferBuilder bb,
for(int i = 0; i <= ENERGY_WAVE_SEG; i++) { float minX, float minY, float minZ,
inRadius[i] = outRadius[i] * 0.1f; float maxX, float maxY, float maxZ
inColors[i] = new Vector3f(1.0f, 1.0f, 1.0f); ) {
} // +X
VertexConsumer consumer2 = buffer.getBuffer(ModRenderTypes.entityAdditiveEmissive(RES)); addQuad(bb,
renderTubeSegmented(consumer2, matrix, new Vec3(0, 0, 0), points, inRadius, inColors, 1.0f, maxX, minY, minZ,
0, 0, 1.0f, 0.0f); maxX, maxY, minZ,
maxX, maxY, maxZ,
maxX, minY, maxZ,
1, 0, 0
);
float uOffset = time * 0.125f; // -X
float vOffset = time * 0.125f; addQuad(bb,
VertexConsumer consumer = buffer.getBuffer(ModRenderTypes.entityAdditiveEmissive(RES4)); minX, minY, maxZ,
for(int i = 0;i < 1;i++) { minX, maxY, maxZ,
renderTubeSegmented(consumer, matrix, new Vec3(0, 0, 0), points, outRadius, outColors, 1.0f, minX, maxY, minZ,
uOffset, 0 + vOffset, 2.0f, 0.0f); minX, minY, minZ,
renderTubeSegmented(consumer, matrix, new Vec3(0, 0, 0), points, outRadius, outColors, 1.0f, -1, 0, 0
uOffset, 0.5f + vOffset, 2.0f, 0.0f); );
// +Y
addQuad(bb,
minX, maxY, maxZ,
maxX, maxY, maxZ,
maxX, maxY, minZ,
minX, maxY, minZ,
0, 1, 0
);
// -Y
addQuad(bb,
minX, minY, minZ,
maxX, minY, minZ,
maxX, minY, maxZ,
minX, minY, maxZ,
0, -1, 0
);
// +Z
addQuad(bb,
minX, minY, maxZ,
maxX, minY, maxZ,
maxX, maxY, maxZ,
minX, maxY, maxZ,
0, 0, 1
);
// -Z
addQuad(bb,
maxX, minY, minZ,
minX, minY, minZ,
minX, maxY, minZ,
maxX, maxY, minZ,
0, 0, -1
);
}
private static void addQuad(
BufferBuilder bb,
float x0, float y0, float z0,
float x1, float y1, float z1,
float x2, float y2, float z2,
float x3, float y3, float z3,
float nx, float ny, float nz
) {
addVertex(bb, x0, y0, z0, nx, ny, nz);
addVertex(bb, x1, y1, z1, nx, ny, nz);
addVertex(bb, x2, y2, z2, nx, ny, nz);
addVertex(bb, x3, y3, z3, nx, ny, nz);
} }
private static void addVertex(
BufferBuilder bb,
float x, float y, float z,
float nx, float ny, float nz
) {
bb.addVertex(x, y, z)
.setColor(255, 255, 255, 255)
.setUv(0, 0)
.setUv1(0, 0)
.setUv2(0, 0)
.setNormal(nx, ny, nz);
} }
} }
@@ -0,0 +1,263 @@
#version 150
in vec3 vLocalPos;
flat in vec3 vCameraLocal;
in vec4 vColor;
out vec4 fragColor;
uniform float EffectTime;
uniform vec4 ColorA;
uniform vec4 ColorB;
const vec3 BOX_MIN = vec3(-0.25, 0.0, -1.0);
const vec3 BOX_MAX = vec3( 0.25, 32.0, 1.0);
// ---------- Ashima Arts simplex noise(GLSL 事实标准,无网格感、无方向偏差)----------
vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec4 permute(vec4 x) { return mod289(((x * 34.0) + 1.0) * x); }
vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }
float snoise(vec3 v) {
const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
vec3 i = floor(v + dot(v, C.yyy));
vec3 x0 = v - i + dot(i, C.xxx);
vec3 g = step(x0.yzx, x0.xyz);
vec3 l = 1.0 - g;
vec3 i1 = min(g.xyz, l.zxy);
vec3 i2 = max(g.xyz, l.zxy);
vec3 x1 = x0 - i1 + C.xxx;
vec3 x2 = x0 - i2 + C.yyy;
vec3 x3 = x0 - D.yyy;
i = mod289(i);
vec4 p = permute(permute(permute(
i.z + vec4(0.0, i1.z, i2.z, 1.0))
+ i.y + vec4(0.0, i1.y, i2.y, 1.0))
+ i.x + vec4(0.0, i1.x, i2.x, 1.0));
float n_ = 0.142857142857;
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor(p * ns.z * ns.z);
vec4 x_ = floor(j * ns.z);
vec4 y_ = floor(j - 7.0 * x_);
vec4 x = x_ * ns.x + ns.yyyy;
vec4 y = y_ * ns.x + ns.yyyy;
vec4 h = 1.0 - abs(x) - abs(y);
vec4 b0 = vec4(x.xy, y.xy);
vec4 b1 = vec4(x.zw, y.zw);
vec4 s0 = floor(b0) * 2.0 + 1.0;
vec4 s1 = floor(b1) * 2.0 + 1.0;
vec4 sh = -step(h, vec4(0.0));
vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;
vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;
vec3 p0 = vec3(a0.xy, h.x);
vec3 p1 = vec3(a0.zw, h.y);
vec3 p2 = vec3(a1.xy, h.z);
vec3 p3 = vec3(a1.zw, h.w);
vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));
p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w;
vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);
m = m * m;
return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));
}
float fbm3(vec3 p) {
float value = 0.0;
float amplitude = 0.5;
// 每层旋转坐标,打破各八度格点对齐(消除 tile 拼接感)
mat3 rot = mat3(
0.866, -0.5, 0.0,
0.5, 0.866, 0.0,
0.0, 0.0, 1.0
);
for (int i = 0; i < 3; i++) {
value += snoise(p) * amplitude;
p = rot * p * 2.03 + vec3(17.1, 9.2, 13.7);
amplitude *= 0.5;
}
return value;
}
float safeComponent(float x) {
if (abs(x) > 0.00001) return x;
return x < 0.0 ? -0.00001 : 0.00001;
}
vec2 intersectBox(vec3 ro, vec3 rd) {
vec3 safeRd = vec3(
safeComponent(rd.x),
safeComponent(rd.y),
safeComponent(rd.z)
);
vec3 inv = 1.0 / safeRd;
vec3 t0 = (BOX_MIN - ro) * inv;
vec3 t1 = (BOX_MAX - ro) * inv;
vec3 nearT = min(t0, t1);
vec3 farT = max(t0, t1);
float tEnter = max(max(nearT.x, nearT.y), nearT.z);
float tExit = min(min(farT.x, farT.y), farT.z);
return vec2(tEnter, tExit);
}
float densityField(vec3 p, float time) {
// 转换成统一的归一化 Sword Space。
float nx = p.x / 0.25;
float ny = p.y / 32.0;
float nz = p.z;
// 顶部收窄:z 宽度随 ny 减小到接近 0(剑尖锥形)
float tip = smoothstep(1.0, 0.5, ny);
float zHalf = 0.06 + 0.94 * tip;
nz = p.z / zHalf;
// 横截面中心更亮,靠近 X/Z 边界逐渐减弱。
float edgeX = 1.0 - smoothstep(0.65, 1.0, abs(nx));
float edgeZ = 1.0 - smoothstep(0.65, 1.0, abs(nz));
float volumeMask = edgeX * edgeZ;
// 根部与剑尖稍微渐隐。
volumeMask *= smoothstep(0.0, 0.02, ny);
volumeMask *= 1.0 - smoothstep(0.96, 1.0, ny);
// 三维噪声沿 Y 轴流动(加快速度)。
vec3 flowPos = vec3(
nx * 3.5,
ny * 18.0 - time * 4.0,
nz * 3.5
);
// domain warping:单次 fbm 驱动三个轴向,减少噪声采样开销(原来是 3 次独立 fbm)
float warp = fbm3(flowPos + vec3(0.0, 0.0, time * 0.4)) - 0.5;
flowPos += vec3(warp, warp * 0.7, warp * 0.5) * 0.65;
// snoise 输出范围 -1~1,重映射到 0~1 再参与密度(与旧 value noise 语义一致)
float n1 = fbm3(flowPos) * 0.5 + 0.5;
float n2 = fbm3(vec3(
nx * 6.0 + 7.3,
ny * 11.0 - time * 2.6,
nz * 6.0 - 4.7
)) * 0.5 + 0.5;
// 明显的纵向能量束。
float stream1 = 0.5 + 0.5 * sin(
ny * 95.0 - time * 16.0 + n1 * 10.0 + nz * 5.0
);
float stream2 = 0.5 + 0.5 * sin(
ny * 143.0 - time * 22.0 - n2 * 13.0 + nx * 6.0
);
stream1 = pow(stream1, 7.0);
stream2 = pow(stream2, 10.0);
// 中央能量核。
float radial = length(vec2(nx, nz));
float core = 1.0 - smoothstep(0.05, 0.75, radial);
float density =
n1 * 0.30 +
stream1 * 0.85 +
stream2 * 0.55 +
core * 0.65;
density = smoothstep(0.30, 1.15, density);
return density * volumeMask;
}
vec3 densityColor(vec3 p, float density) {
float alongBlade = clamp(p.y / 32.0, 0.0, 1.0);
vec3 base = mix(ColorA.rgb, ColorB.rgb, alongBlade);
float nx = p.x / 0.25;
float nz = p.z;
float core = 1.0 - smoothstep(0.0, 0.65, length(vec2(nx, nz)));
// 核心更白热:平方增强 + 高权重,中间不再是淡色
vec3 hot = mix(base, vec3(1.0, 0.85, 1.0), pow(core, 1.5) * 0.85);
// 整体提亮 + 核心区额外增益(加法混合下超 1 的亮度会喂给 bloom)
float brighten = 1.0 + core * 0.9;
return hot * (1.1 + density * 2.4) * brighten;
}
void main() {
float time = EffectTime * 0.2;
vec3 ro = vCameraLocal;
vec3 rd = normalize(vLocalPos - ro);
vec2 hit = intersectBox(ro, rd);
float tStart = max(hit.x, 0.0);
float tEnd = hit.y;
if (tEnd <= tStart) {
discard;
}
const int STEPS = 20;
float stepSize = (tEnd - tStart) / float(STEPS);
float t = tStart + stepSize * 0.5;
vec3 accumulatedColor = vec3(0.0);
float accumulatedAlpha = 0.0;
for (int i = 0; i < STEPS; i++) {
vec3 p = ro + rd * t;
float density = densityField(p, time);
if (density > 0.001) {
float opticalDepth = density * stepSize * 5.0;
float sampleAlpha = 1.0 - exp(-opticalDepth);
vec3 sampleColor = densityColor(p, density);
float remain = 1.0 - accumulatedAlpha;
accumulatedColor += remain * sampleColor * sampleAlpha;
accumulatedAlpha += remain * sampleAlpha;
if (accumulatedAlpha > 0.98) {
break;
}
}
t += stepSize;
}
if (accumulatedAlpha < 0.005) {
discard;
}
float pulse = 0.9 + 0.1 * sin(time * 8.0);
accumulatedColor *= pulse;
vec3 color = accumulatedColor / max(accumulatedAlpha, 0.0001);
fragColor = vec4(color, accumulatedAlpha * vColor.a);
}
@@ -0,0 +1,71 @@
{
"blend": {
"func": "add",
"srcrgb": "srcalpha",
"dstrgb": "1"
},
"vertex": "lzxnoneterraria:devils_devastation_energy",
"fragment": "lzxnoneterraria:devils_devastation_energy",
"attributes": [
"Position",
"Color",
"UV0",
"UV1",
"UV2",
"Normal"
],
"samplers": [],
"uniforms": [
{
"name": "ModelViewMat",
"type": "matrix4x4",
"count": 16,
"values": [
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
]
},
{
"name": "ProjMat",
"type": "matrix4x4",
"count": 16,
"values": [
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
]
},
{
"name": "ModelMat",
"type": "matrix4x4",
"count": 16,
"values": [
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
]
},
{
"name": "EffectTime",
"type": "float",
"count": 1,
"values": [0.0]
},
{
"name": "ColorA",
"type": "float",
"count": 4,
"values": [0.729, 0.396, 0.345, 1.0]
},
{
"name": "ColorB",
"type": "float",
"count": 4,
"values": [0.8, 0.176, 0.78, 1.0]
}
]
}
@@ -0,0 +1,27 @@
#version 150
in vec3 Position;
in vec4 Color;
uniform mat4 ModelMat;
uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
out vec3 vLocalPos;
flat out vec3 vCameraLocal;
out vec4 vColor;
void main() {
vec4 posedPos = ModelMat * vec4(Position, 1.0);
vec4 viewPos = ModelViewMat * posedPos;
gl_Position = ProjMat * viewPos;
vLocalPos = Position;
vColor = Color;
mat4 localToView = ModelViewMat * ModelMat;
vec4 cameraLocal = inverse(localToView) * vec4(0.0, 0.0, 0.0, 1.0);
vCameraLocal = cameraLocal.xyz / cameraLocal.w;
}