Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modifying 'uniform float u_Time' doesn't work. #1641

Open
Lykdraft opened this issue Oct 22, 2024 · 1 comment
Open

modifying 'uniform float u_Time' doesn't work. #1641

Lykdraft opened this issue Oct 22, 2024 · 1 comment

Comments

@Lykdraft
Copy link

Modifying 'uniform float u_Time' never works.

nothing.
this.shaderData.setNumber(Shader3D.propertyNameToID("u_Time"), timeValue);

also, nothing:

onUpdate(){
const currentTime = Laya.timer.currTimer * 0.001;
this.material.setShaderData("u_Time", Laya.ShaderDataType.Float, currentTime);
}

GLSL Fragment code:

precision highp float;
#else
precision mediump float;
#endif
#include "Color.glsl";

uniform float u_Time; // NEW
varying vec3 v_Normal;

void main()
{	
   // Example of using time to create a pulsing effect
    float pulseIntensity = (sin(u_Time * 2.0) + 1.0) * 0.5; // new
    vec3 color = mix(v_Normal, vec3(1.0), pulseIntensity * 0.3); 

    gl_FragColor = vec4(color, 1.0); 
  gl_FragColor = outputTransform(gl_FragColor);
}``` 
@Lykdraft
Copy link
Author

I tried it in the ShaderBlueprint, and the preview does what it should do, see below.
But when I put the ShaderBlueprint into a material and apply the material to a Sprite, it doesn't.
(Which means, that the u_time might work in the shaderBlueprint, but not in 'real-shaer-life')

Untitled.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant