Arbeiten aus dem URlaub
This commit is contained in:
33
ez-tree-jme/assets/Shaders/Tree.vert
Normal file
33
ez-tree-jme/assets/Shaders/Tree.vert
Normal file
@@ -0,0 +1,33 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
uniform mat4 g_WorldMatrix;
|
||||
uniform float g_Time;
|
||||
uniform float m_WindStrength;
|
||||
uniform float m_WindSpeed;
|
||||
|
||||
in vec3 inPosition;
|
||||
in vec3 inNormal;
|
||||
in vec2 inTexCoord;
|
||||
in vec4 inColor; // R = Wind-Gewicht (0 = Wurzel, 1 = Spitze)
|
||||
|
||||
out vec2 texCoord;
|
||||
out vec3 worldNormal;
|
||||
|
||||
void main() {
|
||||
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;
|
||||
|
||||
vec3 animPos = inPosition + vec3(swayX, 0.0, swayZ);
|
||||
|
||||
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