I want to add an animated noise overlay on an existing texture for a model.
To achieve this, I’ve created a fragment shader for the CustomProceduralTexture.
The texture can be set with .setTexture(‘u_emissiveTexture’, textureObject)
Problem 1)
The position of the texture2d is wrong. The problem is, that vPosition is the wrong value because the texture2d needs the correct vTextureCoord, not the vPosition.
The output would be
gl_FragColor = texture2D(u_emissiveTexture, vTextureCoord) + vec4(color, 1.0);
Currently it is
gl_FragColor = texture2D(u_emissiveTexture, vPosition) + vec4(color, 1.0);
and use vTextureCoord it fails, because the vertex-shader that is used by CustomProceduralTexture does not declare vTextureCoord.
How can I solve this problem?
Problem 2)
I declared a glowLayer (Make Mesh Glow - Babylon.js Documentation) which works fine with emissive colors but i can’t get it to work with an emissiveTexture. It’s just not glowing.
And it doesn’t matter if it’s the CustomProceduralTexture or if i set the emissiveTexture directly with the right image.
Thank you all for the great support and piece of software you’ve provided
well - when i apply the texture directly as an albedoTexture or emissiveTexture, it is correct.
When i apply the texture with texture2d(u_emissiveTexture, vUV) it is flipped and wrong positioned.
When i apply the texture with texture2d(u_emissiveTexture, vPosition) it is not flipped, but wrong positioned.
(I’ve tried to apply texture.invertZ = true before setTexture(), this does not help)
I wish I could provide a fast example, I guess it will take one or two days (going on a workshop tomorrow)