Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17070

[Solved] Passing a Variable to a Shader

$
0
0

@grimfate wrote:

I have a shader working that I can use to manipulate the colors of a sprite, but I am struggling to pass values to variables within the shader. Whenever I call setUniformVec2, I get the error Uniform not found.

I load the shader through
GLProgram* prog = GLProgram::createWithFilenames("res/shader.vsh", "res/shader.fsh");

I create the GLProgramState through
auto progState = GLProgramState::getOrCreateWithGLProgram(prog);

I set the program state with the sprite through
sprite->setGLProgramState(progState);

This works fine without trying to pass a variable. But when I call progState->setUniformVec2("u_point", Vec2(0, 0)); I get the Uniform not found error.

The vertex shader file contains
uniform vec2 u_point;

Is there something I have to do for cocos2d-x to register the uniform for setting it?

Thanks.

Posts: 13

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 17070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>