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

Passing an array to a custom function #211

Open
sheuvi21 opened this issue Oct 23, 2017 · 4 comments
Open

Passing an array to a custom function #211

sheuvi21 opened this issue Oct 23, 2017 · 4 comments
Milestone

Comments

@sheuvi21
Copy link

Can I pass an array to the function that I added to the gpu instance?
I added it like this:
gpu.addFunction(simpson, ["Number", "Number", "Array"]);
I got it in the shader's code:
float simpson(float user_myh, float user_nn, sampler2D user_arr) {
But when I try to access an array element:
get(user_arr, vec2(user_arrSize[0],user_arrSize[1]), vec3(user_arrDim[0],user_arrDim[1],user_arrDim[2]), 1.0)
user_arrSize and user_arrDim are not defined.
How to fix this problem?

Earlier I fixed addFunction, replaced:
this.addFunctionNode(new this.Node(functionName, jsFunction, paramTypes, returnType).setAddFunction(this.addFunction.bind(this)));
with
this.addFunctionNode(new this.Node(functionName, jsFunction, null, paramTypes, returnType).setAddFunction(this.addFunction.bind(this)));
in the file gpu.js line 1057.
Because of the BaseFunctionNode signature is:
function BaseFunctionNode(functionName, jsFunction, options, paramTypes, returnType) {
I think it was a bug.

@sheuvi21
Copy link
Author

Maybe I used the wrong English expressions, please let me know so that I can clarify the incomprehensible moments.

@robertleeplummerjr
Copy link
Member

Can you share the source of simpson? That may help to better know how to help.

@sheuvi21
Copy link
Author

This is the source of the simpson function: simpson.txt

The source of this function in the shader: shader_simpson.txt

This error occurs:
An error occurred compiling the shaders: ERROR: 0:134: 'user_arrSize' : undeclared identifier

@sheuvi21
Copy link
Author

sheuvi21 commented Jan 24, 2018

I went back to this code and found that the error occurs with multidimensional arrays. I wrote a simple code that demonstrates this error.
-> simple.txt

Here's an error:

An error occurred compiling the shaders: ERROR: 0:130: 'get' : no matching overloaded function found

@robertleeplummerjr robertleeplummerjr added this to the v2.0.0 milestone May 22, 2019
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

2 participants