Weiter an den Dialogen gearbeitet
This commit is contained in:
@@ -5,6 +5,7 @@ uniform mat4 g_WorldMatrix;
|
||||
uniform float g_Time;
|
||||
uniform float m_WindStrength;
|
||||
uniform float m_WindSpeed;
|
||||
uniform vec2 m_WindDir;
|
||||
|
||||
in vec3 inPosition;
|
||||
in vec3 inNormal;
|
||||
@@ -21,10 +22,21 @@ void main() {
|
||||
float windW = inColor.r;
|
||||
float t = g_Time * m_WindSpeed;
|
||||
vec4 wp = g_WorldMatrix * vec4(inPosition, 1.0);
|
||||
float phase = wp.x * 0.08 + wp.z * 0.06;
|
||||
float swayX = sin(t + phase) * windW * m_WindStrength;
|
||||
float swayZ = cos(t*0.73 + phase) * windW * m_WindStrength * 0.55;
|
||||
vec3 anim = inPosition + vec3(swayX, 0.0, swayZ);
|
||||
vec2 worldXZ = wp.xz;
|
||||
|
||||
vec2 windN = (dot(m_WindDir, m_WindDir) > 0.001) ? normalize(m_WindDir) : vec2(0.0, 1.0);
|
||||
vec2 perpN = vec2(-windN.y, windN.x);
|
||||
float wavePhase = dot(worldXZ, windN);
|
||||
float randPhase = fract(sin(dot(worldXZ, vec2(127.1, 311.7))) * 43758.5453) * 6.2832;
|
||||
|
||||
float mainSway = sin(t + wavePhase * 0.08 + randPhase) * windW * m_WindStrength;
|
||||
float crossSway = cos(t * 0.73 + wavePhase * 0.06 + randPhase) * windW * m_WindStrength * 0.25;
|
||||
|
||||
vec3 anim = inPosition + vec3(
|
||||
windN.x * mainSway + perpN.x * crossSway,
|
||||
0.0,
|
||||
windN.y * mainSway + perpN.y * crossSway
|
||||
);
|
||||
|
||||
gl_Position = g_WorldViewProjectionMatrix * vec4(anim, 1.0);
|
||||
texCoord = inTexCoord;
|
||||
|
||||
19
blight-assets/src/main/resources/Shaders/GrassSeed.frag
Normal file
19
blight-assets/src/main/resources/Shaders/GrassSeed.frag
Normal file
@@ -0,0 +1,19 @@
|
||||
uniform sampler2D m_ColorMap;
|
||||
uniform vec4 g_AmbientLightColor;
|
||||
uniform vec3 m_SunDir;
|
||||
uniform vec4 m_SunColor;
|
||||
|
||||
in vec2 varUV;
|
||||
|
||||
out vec4 outFragColor;
|
||||
|
||||
void main() {
|
||||
vec4 c = texture(m_ColorMap, varUV);
|
||||
if (c.a < 0.15) discard;
|
||||
|
||||
// Wrapped diffuse – kein Normalvektor nötig für Billboard-Quads
|
||||
float light = 0.5 + 0.5 * max(dot(m_SunDir, vec3(0.0, 1.0, 0.0)), 0.0);
|
||||
vec3 ambient = g_AmbientLightColor.rgb * c.rgb;
|
||||
vec3 diffuse = m_SunColor.rgb * c.rgb * light;
|
||||
outFragColor = vec4(min(ambient + diffuse, c.rgb * 1.5), c.a);
|
||||
}
|
||||
34
blight-assets/src/main/resources/Shaders/GrassSeed.vert
Normal file
34
blight-assets/src/main/resources/Shaders/GrassSeed.vert
Normal file
@@ -0,0 +1,34 @@
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
uniform mat4 g_WorldMatrix;
|
||||
uniform float g_Time;
|
||||
|
||||
uniform float m_WindSpeed;
|
||||
uniform float m_WindStrength;
|
||||
uniform vec2 m_WindDir;
|
||||
|
||||
in vec3 inPosition;
|
||||
in vec2 inTexCoord; // echte UV-Koordinaten der Samen-Textur
|
||||
|
||||
out vec2 varUV;
|
||||
|
||||
void main() {
|
||||
vec4 pos = vec4(inPosition, 1.0);
|
||||
|
||||
vec2 worldXZ = (g_WorldMatrix * pos).xz;
|
||||
float t = g_Time * m_WindSpeed;
|
||||
|
||||
vec2 windN = (dot(m_WindDir, m_WindDir) > 0.001) ? normalize(m_WindDir) : vec2(0.0, 1.0);
|
||||
float wavePhase = dot(worldXZ, windN);
|
||||
float randPhase = fract(sin(dot(worldXZ, vec2(127.1, 311.7))) * 43758.5453) * 6.2832;
|
||||
|
||||
float sway = sin(t * 2.1 + wavePhase * 0.10 + randPhase) * 0.6
|
||||
+ sin(t * 1.4 + wavePhase * 0.06 + randPhase * 0.73) * 0.4;
|
||||
|
||||
// Samen sitzen immer an der Spitze → voller Windfaktor (wf = 1.0)
|
||||
float bend = sway * m_WindStrength;
|
||||
pos.x += windN.x * bend;
|
||||
pos.z += windN.y * bend;
|
||||
|
||||
varUV = inTexCoord;
|
||||
gl_Position = g_WorldViewProjectionMatrix * pos;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ uniform float g_Time;
|
||||
|
||||
uniform float m_WindSpeed;
|
||||
uniform float m_WindStrength;
|
||||
uniform vec2 m_WindDir; // normierter XZ-Windvektor
|
||||
|
||||
in vec3 inPosition;
|
||||
in vec3 inNormal;
|
||||
@@ -18,22 +19,28 @@ void main() {
|
||||
float wf = inTexCoord.x;
|
||||
|
||||
if (wf > 0.001) {
|
||||
// Weltposition als Phasenbasis → jeder Halm schwingt anders
|
||||
vec2 worldXZ = (g_WorldMatrix * pos).xz;
|
||||
float t = g_Time * m_WindSpeed;
|
||||
|
||||
float sway = sin(t * 2.1 + worldXZ.x * 0.08 + worldXZ.y * 0.06) * 0.6
|
||||
+ sin(t * 1.4 - worldXZ.x * 0.05 + worldXZ.y * 0.09) * 0.4;
|
||||
// Windrichtung (Fallback: Süd)
|
||||
vec2 windN = (dot(m_WindDir, m_WindDir) > 0.001) ? normalize(m_WindDir) : vec2(0.0, 1.0);
|
||||
|
||||
// Wellenfront: Position entlang der Windachse → Halme in Windrichtung erreicht der Impuls später
|
||||
float wavePhase = dot(worldXZ, windN);
|
||||
|
||||
// Zufälliger Phasenversatz pro Halm (Spatial-Hash → kein synchrones Schwingen)
|
||||
float randPhase = fract(sin(dot(worldXZ, vec2(127.1, 311.7))) * 43758.5453) * 6.2832;
|
||||
|
||||
float sway = sin(t * 2.1 + wavePhase * 0.10 + randPhase) * 0.6
|
||||
+ sin(t * 1.4 + wavePhase * 0.06 + randPhase * 0.73) * 0.4;
|
||||
|
||||
// Quadratische Gewichtung: Spitze biegt sich mehr als Basis
|
||||
float bend = sway * m_WindStrength * wf * wf;
|
||||
pos.x += bend;
|
||||
pos.z += bend * 0.3;
|
||||
pos.x += windN.x * bend;
|
||||
pos.z += windN.y * bend;
|
||||
}
|
||||
|
||||
varColor = inColor;
|
||||
// Normal in Weltkoordinaten (WorldMatrix ist für Gras typischerweise Identität)
|
||||
varNormal = normalize(mat3(g_WorldMatrix) * inNormal);
|
||||
|
||||
gl_Position = g_WorldViewProjectionMatrix * pos;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
uniform mat4 g_WorldMatrix;
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
uniform mat4 g_WorldMatrix;
|
||||
uniform float g_Time;
|
||||
uniform float m_WindStrength;
|
||||
uniform float m_WindSpeed;
|
||||
uniform vec2 m_WindDir;
|
||||
|
||||
in vec3 inPosition;
|
||||
in vec3 inNormal;
|
||||
@@ -16,18 +16,27 @@ out vec2 texCoord;
|
||||
out vec3 worldNormal;
|
||||
|
||||
void main() {
|
||||
float windW = inColor.r;
|
||||
float t = g_Time * m_WindSpeed;
|
||||
float windW = inColor.r;
|
||||
float t = g_Time * m_WindSpeed;
|
||||
|
||||
// Welt-Position für orts-abhängige Phase (verhindert synchrones Schwingen)
|
||||
vec4 worldPos = g_WorldMatrix * vec4(inPosition, 1.0);
|
||||
float phase = worldPos.x * 0.08 + worldPos.z * 0.06;
|
||||
float swayX = sin(t + phase) * windW * m_WindStrength;
|
||||
float swayZ = cos(t * 0.73 + phase) * windW * m_WindStrength * 0.55;
|
||||
vec4 worldPos = g_WorldMatrix * vec4(inPosition, 1.0);
|
||||
vec2 worldXZ = worldPos.xz;
|
||||
|
||||
vec3 animPos = inPosition + vec3(swayX, 0.0, swayZ);
|
||||
vec2 windN = (dot(m_WindDir, m_WindDir) > 0.001) ? normalize(m_WindDir) : vec2(0.0, 1.0);
|
||||
vec2 perpN = vec2(-windN.y, windN.x);
|
||||
float wavePhase = dot(worldXZ, windN);
|
||||
float randPhase = fract(sin(dot(worldXZ, vec2(127.1, 311.7))) * 43758.5453) * 6.2832;
|
||||
|
||||
gl_Position = g_WorldViewProjectionMatrix * vec4(animPos, 1.0);
|
||||
texCoord = inTexCoord;
|
||||
worldNormal = normalize((g_WorldMatrix * vec4(inNormal, 0.0)).xyz);
|
||||
}
|
||||
float mainSway = sin(t + wavePhase * 0.08 + randPhase) * windW * m_WindStrength;
|
||||
float crossSway = cos(t * 0.73 + wavePhase * 0.06 + randPhase) * windW * m_WindStrength * 0.25;
|
||||
|
||||
vec3 animPos = inPosition + vec3(
|
||||
windN.x * mainSway + perpN.x * crossSway,
|
||||
0.0,
|
||||
windN.y * mainSway + perpN.y * crossSway
|
||||
);
|
||||
|
||||
gl_Position = g_WorldViewProjectionMatrix * vec4(animPos, 1.0);
|
||||
texCoord = inTexCoord;
|
||||
worldNormal = normalize((g_WorldMatrix * vec4(inNormal, 0.0)).xyz);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user