Hello. I’m trying to get a BasicEffect-ed model to reflect a TextureCube. However, when I import the effect and try to manually override the models effect, it just makes it transparent and show the game’s clear color:
The model in question is the knife on the right. I’m using this shader (because I know little about shaders to write my own): Reflection.fx, and the code I use to set my model’s effect is like so:
/* Earlier in the code */
Effect test = Global.Content.Load<Effect>("Reflection");
....
foreach (ModelMesh e in meshes)
{
foreach (ModelMeshPart mmp in e.MeshParts)
{
mmp.Effect = test;
test.Parameters["Projection"].SetValue(MainGame.drawEffect.Projection);
test.Parameters["World"].SetValue(transform);
test.Parameters["View"].SetValue(MainGame.camera.View);
test.Parameters["CameraPosition"].SetValue(MainGame.camera.Pos);
test.Parameters["WorldInverseTranspose"].SetValue(Matrix.Transpose(Matrix.Invert(transform)));
test.Parameters["SkyboxTexture"].SetValue(MainGame.texCube);
foreach (EffectPass pass in test.CurrentTechnique.Passes)
{
pass.Apply();
}
}
e.Draw();
}
If I don’t set the “SkyboxTexture” parameter, I get the exact same result as I am now, so I can’t tell if it’s the Skybox being broken, or the shader. However, I did try to use other shaders to achieve my goal too (ones that didn’t use a TextureCube), and this was always the same result. Even a generic Ambient shader yielded this same transparency.
Many thanks in advance, I’m really terrible with shaders