Hi guys!
So lately I have been changing my engine design, and how things are created (user mode). So I ask you, if you have time, to review from a users perspective how things are, good, bad, terrible?
Creating a simple scene, 3 Meshes (SkyBox, Diamond, Plane) - 3 Textures (Noise, Diamond Tex, Cubemap) - 2 Materials (Gem, Skybox):
// Initialize materials and textures
CeMatParser<CeMatMesh> *gemMat = new CeMatParser<CeMatMesh>();
gemMat->Bootstrap(engine.dev, CeURL(CEToMedia("Materials\\Gems\\gem_dualpass.cs")));
CeMatParser<CeMatMesh> *skyMat = new CeMatParser<CeMatMesh>();
skyMat->Bootstrap(engine.dev, CeURL(CEToMedia("Materials\\Sky\\sky_01.cs")));
CESDK::Texture2D* noise = new CESDK::Texture2D();
CESDK::Texture2D* reflection = new CESDK::Texture2D();
CESDK::TextureCube* env = new CESDK::TextureCube();
noise->CreateTexture(engine.dev, CEToMedia("Textures\\noise.gif"));
reflection->CreateTexture(engine.dev, CEToMedia("Textures\\reflection.jpg"));
LPCSTR *all = new LPCSTR[6];
all[0] = CEToMedia("Textures\\Skybox\\01\\x+.bmp");
all[1] = CEToMedia("Textures\\Skybox\\01\\x-.bmp");
all[2] = CEToMedia("Textures\\Skybox\\01\\y+.bmp");
all[3] = CEToMedia("Textures\\Skybox\\01\\y-.bmp");
all[4] = CEToMedia("Textures\\Skybox\\01\\z+.bmp");
all[5] = CEToMedia("Textures\\Skybox\\01\\z-.bmp");
env->CreateTexture(engine.dev, all);
// Create all meshes
UMesh *plane = new UMesh();
plane->InitPlane(engine.devcon, engine.dev);
plane->SetMaterial(&engine.Materials.diffuse);
plane->Scale(100, 1, 100);
plane->Translate(-50, 0, -50);
UMesh *gem = new UMesh();
gem->AssimpLoad(CEToMedia("Mesh\\Shiny\\perfect_diamond.obj"), engine.devcon, engine.dev, false, false);
gem->CalculateBuffers(engine.devcon, engine.dev);
gem->Translate(0, 3, 0);
gem->SetMaterial(gemMat);
gem->passes.SetBlend(CEPHASE_BLEND_ADDITIVE);
gem->Parameters.SetTexture(noise, gemMat->getSlot("noise"));
gem->Parameters.SetTexture(reflection, gemMat->getSlot("reflection"));
gem->Parameters.SetTexture(env, gemMat->getSlot("environment"));
UMesh *skybox = new UMesh();
skybox->AssimpLoad("sphere.obj", engine.devcon, engine.dev);
skybox->CalculateBuffers(engine.devcon, engine.dev);
skybox->Scale(100, 100, 100);
skybox->SetMaterial(skyMat);
skybox->Parameters.SetTexture(env, skyMat->getSlot("skyBox"));
// Push all the meshes
engine.Meshes.push_back(plane);
engine.Meshes.push_back(gem);
engine.Meshes.push_back(skybox);
And the shaders are written as following (Shown: Gem shader, just a testing shader):
Any description or text can go here. The parser ignores it.
shader "Gem_Shader"
{
// Properties go here
info = "Gem shader showing the passes feature";
:input
:{
Texture2D noise;
Texture2D reflection;
TextureCube environment;
// To simplify
#define OUT output
#define lighting_intensity 0.7f
#define NOSHADOWS
:}
:pass
{
:properties {
Cull [Front];
}
:linkage
:{
float3 Reflect : REF;
:}
:vertex
:{
float3 ViewDir = normalize(mul(position, worldMatrix) - eyepos);
output.Reflect = reflect(viewvec, mul(normal, worldMatrix));
output.Reflect.y = -output.Reflect.y;
:}
:pixel
:{
float4 colors = reflection.Sample(ss, input.texcoord)/4.0f;
float4 cubeMap = environment.Sample(ss, input.Reflect);
output.Diffuse = float4( colors.rgb + (cubeMap.rgb / 2.0f) , 1.0f);
:}
}
:pass
{
:properties {
Cull [Back];
}
:linkage
:{
float3 Reflect : REF;
:}
:vertex
:{
float3 ViewDir = normalize(mul(position, worldMatrix) - eyepos);
output.Reflect = reflect(viewvec, mul(normalize(float4(normal.xyz, 0)), worldMatrix));
output.Reflect.y = -output.Reflect.y;
:}
:pixel
:{
float4 colors = reflection.Sample(ss, input.texcoord)/2.0f;
float4 cubeMap = environment.Sample(ss, input.Reflect);
output.Diffuse = float4( colors.rgb + (cubeMap.rgb) , 0.6f);
:}
}
}
PS. The wierd :x thing will be changed, just not now...
Thanks, as always!
-MIGI0027