I'm developing a game for ittlicht, using the Chield example located here http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=38544
Now, i've a little problem.
Seen that my game will be in direct3d9/11 when i'll finish my d3d11driver,
i'm converting the shader glsl in hlsl.
It's not hard, i've already done this, but i've a strange problem now.
When i'm going to set the hlsl variable, irrlicht say me "i can't found the variable to set".
Now, here is the shader
Code: Select all
float Time;
float Radius;
float Intensity;
float4x4 View;
float4x4 World;
float4x4 Projection;
float3 HitPoint;
float3 Position;
texture ModelTexture;
texture GradientTexture;
sampler2D ModelSampler : register(s0);
sampler2D GradientSampler : register(s1);
struct VertexShaderInput
{
float4 Position : POSITION0;
float3 Normal : NORMAL0;
float2 TexCoord : TEXCOORD0;
};
struct VertexShaderOutput
{
float4 Position : POSITION0;
float3 Normal : TEXCOORD0;
float2 TexCoord : TEXCOORD1;
};
struct PixelShaderOutput
{
float4 RGBAColor : COLOR0;
};
VertexShaderOutput VertexMain(VertexShaderInput Input)
{
VertexShaderOutput Output = (VertexShaderOutput)0;
float4 worldPos = mul(Input.Position, World);
float4 viewPos = mul(worldPos, View);
Output.Position = mul(viewPos, Projection);
Output.Normal = mul(Input.Normal, World);
Output.TexCoord = Input.TexCoord;
return Output;
}
PixelShaderOutput PixelMain(VertexShaderOutput Input)
{
Input.TexCoord.x += cos(Time);
Input.TexCoord.y += sin(Time);
float4 ColorModel = tex2D(ModelSampler, Input.TexCoord);
float Factor = 0.0f;
float Distance = length(Position - HitPoint);
Factor = max( Intensity / (Distance * Distance), 0.0f);
ColorModel.w *= Factor;
PixelShaderOutput Output;
Output.RGBAColor = ColorModel;
return Output;
}
Code: Select all
video::IVideoDriver* driver = services->getVideoDriver();
core::matrix4 world = driver->getTransform(video::ETS_WORLD);
core::matrix4 view = driver->getTransform(video::ETS_VIEW);
core::matrix4 projection = driver->getTransform(video::ETS_PROJECTION);
services->setVertexShaderConstant("Time", /*(f32*)*/&TimeMs, 1);
services->setVertexShaderConstant("Radius", /*(f32*)*/&Radius, 1);
/*services->setVertexShaderConstant("ModelTexture", (f32*)&texture0, 1);
services->setVertexShaderConstant("GradientTexture", (f32*)&texture1, 1);*/
services->setVertexShaderConstant("Intensity", /*(f32*)*/&Intensity, 1);
services->setVertexShaderConstant("HitPoint", /*(f32*)*/&HitPoint.X, 3);
services->setVertexShaderConstant("World", world.pointer(), 16);
services->setVertexShaderConstant("View", view.pointer(), 16);
services->setVertexShaderConstant("Projection", projection.pointer(), 16);
the error sent by irrlicht is this :
Code: Select all
HLSL Variable to set not found: 'HitPoint'. Available variables are:
'Projection' Registers:[begin:8, count:4]
'View' Registers:[begin:0, count:4]
'World' Registers:[begin:4, count:4]
Thanks for any help, and sorry for my bad english ^^