Wallpaper Engine

Wallpaper Engine

Voir les stats:
Wallpaper engine Modifying effects through a script
I was messing around with the effects in wallpaper engine and I wanted to create an effect which allowed you to fade from one image to another using only one layer. I got to work and now I want to use a script to change the fade with user input.

To do this I need to modify the uniform float variable in the shader. I've gotten it to pick up the shader in the script and what it reads is accurate. However, when I modify the varible it doesn't update even though when logged it has updated.

This is the Shader
uniform float u_alpha; // {"material":"u_alpha","default":1,"range":[0,1], "hidden": false} uniform sampler2D g_Texture0; // { "material": "tex1", "label": "Texture 1", "hidden": true} uniform sampler2D g_Texture1; // { "material": "tex2", "label": "Texture 2"} varying vec2 v_TexCoord; void main() { vec4 col1 = texSample2D(g_Texture0, v_TexCoord.xy); vec4 col2 = texSample2D(g_Texture1, v_TexCoord.xy); gl_FragColor = mix(col1, col2, u_alpha); }

This is the Script, it is attached to the u_alpha property of the effect
'use strict'; /** * @param {Number} value - for property 'alpha' * @return {Number} - update current property value */ export function init(value) { console.log(Object.getOwnPropertyNames(thisObject)); console.log(thisObject.u_alpha); thisObject.u_alpha = 0.01; console.log(thisObject.u_alpha); return value; }

The output looks like this
Log: u_alpha,depthwrite,depthtest,cullmode,alphawriting,blending,getAnimation Log: 1 Log: 0.009999999776482582

As you can see the output is correct (I set the variable to 1 in the inspector before running the wallpaper) as it picks up and updates the u_alpha variable.

I'm mainly doing this out of curiosity and am not super knowledgeable about how all this works so if anyone can clarify what is happening here this would be Great.
Dernière modification de MagnusWOAH; 9 juil. 2024 à 22h45
Écrit par Gariam:
You are returning "value"

Also, you don't need to make a new shader for this, there's the blend effect that does exactly this.
< >
Affichage des commentaires 1 à 6 sur 6
tremendo
L'auteur(e) de ce sujet a indiqué que ce message répond à sa question.
You are returning "value"

Also, you don't need to make a new shader for this, there's the blend effect that does exactly this.
Dernière modification de Gariam; 10 juil. 2024 à 2h03
Gariam a écrit :
You are returning "value"

Also, you don't need to make a new shader for this, there's the blend effect that does exactly this.
Yeah this worked thanks. I didn't realise returning the value would block the shader variable from being updated.
MagnusWOAH a écrit :
Yeah this worked thanks. I didn't realise returning the value would block the shader variable from being updated.
It was being updated, just with the same value it had before, overwriting your change.
WARNING! Carry on reading! Or you will die, even if you only looked at the word warning! Once there was a little boy called Joey, he was ten-years-old and he lived in a mental hospital because he posted a ♥♥♥♥♥♥ copypasta onto a People Playground mod's comment section . He got so bad he went to kill all the staff in the hospital so the Feds decided that best idea was to get rid of him so they set up a special room to kill him, as inhumane as possible. And he sat there in agony for hours until he died. Now every week on the day of his death he returns to the person that reads this letter, on a monday night at 12:00 a.m. He creeps into your room and kills you slowly, by pegging you and watching you bleed to death. Now send this to ten other profiles on this one site, and he will haunt someone else who doesn't. This isn't fake. apparently if u copy and paste this to ten comments in the next ten minutes nothing will happen: sorry man i am not taking the risk
< >
Affichage des commentaires 1 à 6 sur 6
Par page : 1530 50

Posté le 9 juil. 2024 à 22h31
Messages : 6