Shaders take only float4?
Shaders take only float4?
I try to load parameters like just single number values etc but it seems like I can only ever load float4. Am I just doing something wrong? I’m new to shader code. I mean specifically loading and setting shader parameters in irrlicht.
Re: Shaders take only float4?
I don't know if it has anything to do with it, but I've noticed that some graphics cards support 16-bit floating-point, while others don't
Irrlicht is love, Irrlicht is life, long live to Irrlicht
Re: Shaders take only float4?
By load you mean passing parameters from CPU to GPU? Should work for float like for other types. I just did a quick test with d3d9.hlsl and example "10.Shaders" in Irrlicht. Added a float in the global variables section.
Used it later in the pixelMain to see something:
On c++ side I got the id for that shader variable in the shader callback like:
And then setting it each frame like this:
There are certainly other things you can mess up. But generally a good idea to test if something works in principle by modifying the Irrlicht example first. If it works there - then you know you have some bug in your code. If the Irrlicht example fails at well... then we have to start really hunting what's going on.
Code: Select all
float dummy;
Code: Select all
Output.RGBColor += dummy;
Code: Select all
DummyID = services->getPixelShaderConstantID("dummy"); // make sure you get the correct variable name here - check result for >= 0 to be sure it worked
Code: Select all
static float dummyCpu = 0.f;
dummyCpu += 0.01f; // just letting it flicker colors a bit
if ( dummyCpu> 1.0 )
dummyCpu = 0.0;
services->setPixelShaderConstant(DummyID, &dummyCpu, 1); // that's the line that passes the cpu value to the gpu
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm