gibts keinen der mir mehr helfen kann?
edit:: mhh kp wie das zustande kahm aber time musste auf 0 aber nun bewegt sich nix :/ hat wer ne idee?
edit2:: klappt alles hab dauerhaft time auf 0 gehabt deswegen
und hier der code vlt brauchts ja wer noch
shader.h:
Code:
class cShader
{
public:
sGamestruct* SD;
IGPUProgrammingServices* gpu;
void initLava(ISceneNode* Model);
};
class Shader_Lava_callback: public video::IShaderConstantSetCallBack
{
public:
float time;
bool initTime;
virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData);
};
shader.cpp
Code:
const stringc vertLavaShader =
"varying vec2 Texcoord;"
"varying vec4 Pos;"
"void main(void)"
"{"
" gl_Position = ftransform();"
" Pos = gl_Vertex;"
" Texcoord = gl_MultiTexCoord0.xy;"
"}"
;
const stringc fragLavaShader =
"uniform sampler2D Texture1;"
"uniform sampler2D Texture2;"
"uniform float time;"
""
"varying vec2 Texcoord;"
"varying vec4 Pos;"
"void main(void)"
"{"
"vec4 noise = texture2D(Texture1,Texcoord);"
"vec2 T1 = Texcoord+vec2(1.5, -1.5) * time * 0.02;"
"vec2 T2 = Texcoord+vec2(-0.5, 2.0) * time * 0.01;"
"float p = texture2D(Texture1, T1 * 2.0).a;"
"vec4 color = texture2D(Texture2, T2 * 2.0);"
"vec4 temp = color*(vec4(p, p, p, p) * 2.0) + (color * color - 0.1);"
""
"T1.x += (noise.x) * 2.0;"
"T1.y += (noise.y) * 2.0;"
"T2.x -= (noise.y) * 0.2;"
"T2.y += (noise.z) * 0.2;"
"if(temp.r > 1.0)"
"{"
"temp.bg += clamp(temp.r - 2.0, 0.0, 100.0);"
"}"
"if(temp.g > 1.0)"
"{"
"temp.rb += temp.g - 1.0;"
"}"
"if(temp.b > 1.0)"
"{"
"temp.rg += temp.b - 1.0;"
"}"
"gl_FragColor = temp;"
"}"
;
void Shader_Lava_callback::OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
{
int var0 = 0;
int var1 = 1;
if(initTime == false)
{
time = 0;
initTime = !initTime;
}
time = time + 0.05f;
IVideoDriver* driver = services->getVideoDriver();
services->setVertexShaderConstant("time", reinterpret_cast<f32*>(&time),1);
services->setPixelShaderConstant("Texture1", (float*)(&var0), 1);
services->setPixelShaderConstant("Texture2", (float*)(&var1), 1);
}
void cShader::initLava(irr::scene::ISceneNode* Model)
{
gpu = SD->Driver->getGPUProgrammingServices();
s32 mtlLavaShader = video::EMT_SOLID;
Shader_Lava_callback* callback = new Shader_Lava_callback;
callback->initTime = false;
mtlLavaShader = gpu->addHighLevelShaderMaterial( vertLavaShader.c_str(), "main", video::EVST_VS_1_1, fragLavaShader.c_str(), "main", video::EPST_PS_1_1, callback, video::EMT_SOLID);
Model->setMaterialFlag(EMF_LIGHTING, false);
Model->setMaterialTexture(0, SD->Driver->getTexture("..\\data\\cloud.tga"));
Model->setMaterialTexture(1, SD->Driver->getTexture("..\\data\\lavatile.jpg"));
Model->setMaterialType((video::E_MATERIAL_TYPE)mtlLavaShader);
}