implement morph_target.glsl

This commit is contained in:
QuantumCoderQC 2021-10-18 19:49:25 +02:00
parent 6f9b51a57a
commit 8c034655be
1 changed files with 25 additions and 4 deletions

View File

@ -1,6 +1,27 @@
#version 450
uniform sampler2D morphDataPos;
uniform sampler2D morphDataNor;
uniform vec2 morphScaleOffset;
uniform float morphWeights[32];
uniform sampler2D morphData;
uniform float morphWeights[maxMorphTargets];
void getMorphedVertex(vec2 uvCoord, inout vec3 A){
for(int i = 0; i<32; i++ )
{
vec2 tempCoord = uvCoord;
tempCoord.y *= i;
vec3 morph = texture(morphDataPos, tempCoord).rgb * morphScaleOffset.x + morphScaleOffset.y;
A += morphWeights[i] * morph;
}
}
in vec2 texCoord;
void getMorphedNormal(vec2 uvCoord, vec3 oldNor, inout vec3 morphNor){
for(int i = 0; i<32; i++ )
{
vec2 tempCoord = uvCoord;
tempCoord.y *= i;
vec3 norm = morphWeights[i] + (texture(morphDataNor, tempCoord).rgb * 2.0 - 1.0);
morphNor += norm;
}
morphNor += oldNor;
morphNor = normalize(morphNor);
}