raj Posted July 18, 2015 Share Posted July 18, 2015 Hi, I was wondering if there are any examples of programmatically creating a shader, and more specifically, passing in a custom 4x4 matrix array to a shader? I see examples of vec4s throughout material examples, e.g. <parameter name="normal_transform" type="expression" shared="1">vec4(1.0f,1.0f,0.0f,time)</parameter> Are there any tips or examples that you can point me to do this? I have a 4x4 custom matrices (projection, rotation & translation) that I would like to pass into a shader that are generated only at runtime. Thanks! Link to comment
raj Posted July 18, 2015 Author Share Posted July 18, 2015 And a similar question for passing in an image. How do I pass in an image (1920 x 1080) that is generated dynamically at runtime (e.g., from a web camera) into a shader with the C++ API? Link to comment
silent Posted July 20, 2015 Share Posted July 20, 2015 Hi Rajinder, Are there any tips or examples that you can point me to do this? I have a 4x4 custom matrices (projection, rotation & translation) that I would like to pass into a shader that are generated only at runtime. There is no mat4 structure inside material files, unfortuantely. You can pass matrix by splitting it by regular vec4 parameters (similar approach, but with 3x4 matrix you can find in core/shaders/default/mesh/vertex_base.shader). Also, you can use one of the available Shader::setParamterFloat() methods to pass up to 16 float variables directly to the shader. And a similar question for passing in an image. How do I pass in an image (1920 x 1080) that is generated dynamically at runtime (e.g., from a web camera) into a shader with the C++ API? For that purpose, I think one of the Material::setImageTexture() methods will be enough. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
raj Posted July 20, 2015 Author Share Posted July 20, 2015 Are you referring to setParameterFloatArray()? Can you give me an example of this or point me to a sample that uses this? I find it surprising that a mat4 structure isn't supported. Seems like a useful structure to include in a future release. Link to comment
Recommended Posts