Roberto14 Posted November 10, 2016 Share Posted November 10, 2016 Hi all, as title say, i can't figure out how can i take control of some uniforms, inside a file.shader, but loaded by a .lua file. An example is : in file PostProcess/Bloom/Bloom.shader, ( loaded by PostProcess/bloom.lua ) How can i control uniform "cutoff" by c++ side? When i load it int index = pCamera->AddPostEffect( "Shaders/PostProcess/bloom.lua" ); i try Leadwerks::Shader *pShader = (Leadwerks::Shader*)pCamera->posteffects[ index ]; and pShader is not NULL, but program crash if i use pShader->SetFloat( "cutoff", fMycutoff); Quote I'm not english, so please sorry for my grammatical errors I'm using Leadwerks and can programm in C++ and LUA Link to comment Share on other sites More sharing options...
macklebee Posted November 10, 2016 Share Posted November 10, 2016 Try loading the shader in question via C++ and then adjust its uniforms. It should affect all the bloom shaders loaded in the scene. http://www.leadwerks.com/werkspace/topic/14230-global-uniform/#entry97586 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Roberto14 Posted November 10, 2016 Author Share Posted November 10, 2016 Try loading the shader in question via C++ and then adjust its uniforms. It should affect all the bloom shaders loaded in the scene. http://www.leadwerks.com/werkspace/topic/14230-global-uniform/#entry97586 Well, i already doing that, i'm not? I say, i'm already using c++, lo "load" it. I load bloom.lua file directly, because is really hard to create a cpp file equivalent. Quote I'm not english, so please sorry for my grammatical errors I'm using Leadwerks and can programm in C++ and LUA Link to comment Share on other sites More sharing options...
macklebee Posted November 10, 2016 Share Posted November 10, 2016 Well, i already doing that, i'm not? I say, i'm already using c++, lo "load" it. I load bloom.lua file directly, because is really hard to create a cpp file equivalent. Well you are loading the lua script via c++ then lua is loading the shader. I am suggesting you load the script as you showed above but also try loading the shader in c++ so you have access to the shader in question. So instead of doing: int index = pCamera->AddPostEffect( "Shaders/PostProcess/bloom.lua" ); Leadwerks::Shader *pShader = (Leadwerks::Shader*)pCamera->posteffects[ index ]; pShader->SetFloat( "cutoff", fMycutoff); try doing (psuedo-code): int index = pCamera->AddPostEffect( "Shaders/PostProcess/bloom.lua" ); Leadwerks::Shader *pShader = Shader::Load("shaderpath.shader"); pShader->SetFloat( "cutoff", fMycutoff); --Note that i'm saying "try" since I do not have a way to attempt it - but it has worked for the previous attempt as shown in the link above. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Roberto14 Posted November 13, 2016 Author Share Posted November 13, 2016 Well you are loading the lua script via c++ then lua is loading the shader. I am suggesting you load the script as you showed above but also try loading the shader in c++ so you have access to the shader in question. So instead of doing: int index = pCamera->AddPostEffect( "Shaders/PostProcess/bloom.lua" ); Leadwerks::Shader *pShader = (Leadwerks::Shader*)pCamera->posteffects[ index ]; pShader->SetFloat( "cutoff", fMycutoff); try doing (psuedo-code): int index = pCamera->AddPostEffect( "Shaders/PostProcess/bloom.lua" ); Leadwerks::Shader *pShader = Shader::Load("shaderpath.shader"); pShader->SetFloat( "cutoff", fMycutoff); --Note that i'm saying "try" since I do not have a way to attempt it - but it has worked for the previous attempt as shown in the link above. Seems to work, i need more test but i think u solved my problem, really thank you Quote I'm not english, so please sorry for my grammatical errors I'm using Leadwerks and can programm in C++ and LUA Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.