I’ve created a minimal repro project case. I’m trying to learn how to create my own shaders to add more effects to my game. However, I’m seeing an error: “ERROR:SCRIPT: /main/halo.script:18: ‘#sprite’ does not have any property called ‘time’”. However, if I modify the fp for the custom sprite material, the error goes away (I have to access and use some component of the time user uniform.) I have the project setup with the error reproducing and some comments showing which line to toggle to fix the error. I’m confused about this. Do I have to use every user variable in the shader code for the compiler to leave the user variable on the material?
To add to this, I’m trying to do a simple y-stretching vertex shader. I’m using the following code:
uniform highp mat4 view_proj;
// positions are in world space
attribute highp vec4 position;
attribute mediump vec2 texcoord0;
uniform lowp vec4 vars;
varying mediump vec2 var_texcoord0;
void main()
{
float y = position.y * 2.0 + vars.w;
gl_Position = view_proj * vec4(position.x, y, position.z, 1.0);
var_texcoord0 = texcoord0;
}
vars is set to vec4(0,0,0,0) as a user uniform value in the material.
When I use this shader, my calls to set the euler.z property are ignored without error. The sprite just remains still. If I use the default sprite shader it animates properly.
The problem in this project is that the shader code does optimize to remove things which are not actually used. In this case, even though you have references to time, those lines are not actually used to generate anything and so are likely ignored, which produces the error in the script.
For the second issue I’m not sure what the situation/problem is atm. If it’s clarified / isolated it would be helpful.
That seems like the case from what I can tell, I’ll have to see if I can find the related code. I’ll probably just handle the vertex rotation in the shader manually in order to overcome this limitation.
Which made me realize that the reason you could not see updates to the euler.z is because the top two sprites were being moved above the view. Moving them down made them visible again and did show them rotating.
Thanks! I hadn’t realized shader effects can be visible even from the collection viewer, that’s great to know while I’m trying to learn how to use these! Makes me appreciate Defold even more