• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Migi0027

Engine Design - Improvements

4 posts in this topic

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...

 

The result isn't really the focus here, just how badly my design is. happy.png
 
So.. What do you think? (Improvements, removal, new way of doing that... Basically anything)

 

Thanks, as always!

-MIGI0027

Edited by Migi0027
0

Share this post


Link to post
Share on other sites

CEToMedia - im not shure what that fuction does, but i think that the input parameter is transformed from local path to app global path. Wich is ugly.

 
//------------------------------------------------------------------
Possible leaks maybe?
CESDK::Texture2D* noise = new CESDK::Texture2D();


LPCSTR *all = new LPCSTR[6];
all[0] = CEToMedia("Textures\\Skybox\\01\\x+.bmp");
 
//------------------------------------------------------------------
That is really wrong.
 
// Push all the meshes
engine.Meshes.push_back(plane);
 
exposing direct access to containers that hold really important objects may cause you a big trouble. 
You need some kind of manager (scene manager, or separate manager for the meshes(the one I'm using)) that will take care only for the mesh object.
When using that method you can provide diffrent loading methods some data sorting, ect ect...
Try with something like this.



//RequestMesh Desc: if mesh already exist an instance pointer is returned
//otherwise the mesh is loaded and later returned 
//note: for different situations you can provide different loading methods(like in another thread, or force relod)
//keep in mind that the MeshManager doesnt know how to pare the mesh files. His job is to call right fuction at the right moment on the right thread


const UMesh* pMyMesh = pMeshManager->RequestMesh("file.bla", REQUEST_MESH_FLAG1 | ... );
if(pMyMesh) ....;


pMeshManager->RequestMeshAsync("file.bla", REQUEST_MESH_FLAG1 | ... , someLambdaOrFuncOrWeverToCallWhenLoadingIsDoneOrNothing);


//and later maybe


enum EMESH_STATE 
{
EMESH_STATE_UNKNOWN = 0,
EMESH_STATE_LOADED,
EMESH_STATE_LOADING,
EMESH_STATE_LOADING_ASYNC,
EMESH_STATE_A_MAGIC_THING
};
 
const EMESH_STATE state = pMeshManager->GetStateOf("file.bla");//think of better name here
 
THe same manager is good for any kind of resources.
 
I'm not going to speak about your shaders. It is OK to use that kind of a structure. I personally prefer to expose my effect description away from the actual shader code:
 
This is what im using :
 
some_shaders.xml
 
<root>
  <!-- Test shaders -->
  <shader name="DiffuseVS" fileName="Diffuse.vs" entryPoint="main" target="SHADER_TYPE_VS" targetMajor="5" targetMinor="0">
    <!-- VERTEX SHADER INPUT ATTRUBUTES DESC -->
    <vsin name="position" semantic="SGE_VERT_POSITION_XYZ"/>
    
    <!-- SHADER INPUT UNIFORMS DESC -->


  </shader>


  <shader name="DiffusePS" fileName="Diffuse.ps" entryPoint="main" target="SHADER_TYPE_PS" targetMajor="5" targetMinor="0">
    <variable name="color" semantic="SGE_SEMANTIC_COLOR"/>
    <variable name="colorPower" semantic="SEMANTIC_UNKNOWN"/>
  </shader> 
</root>
 
 
later:
 
some_effects.xml
 
<root>
  <effect name="BasicEffect">
    <technique name="tech0">
      <pass>
        <vertexShader name="DiffuseVS"/>
        <pixelShader name="DiffusePS"/>
      </pass>    
    </technique>
  </effect>
</root>
 
and in C++ code
pShaderManager->AddShadersLibrary("some_shaders.xml", ....);


pEffectManager->SetSHaderManager(pShaderManager);
pEffectManager->AddEffectsLibrary("some_effects.xml", .....);


EffectBase* pEffect = GetEffectManager()->GetEffect("BasicEffect");
 
But your approch is fine too.
 
 
Excuse me for my awful english.
Edited by imoogiBG
1

Share this post


Link to post
Share on other sites

Some thoughts:

 

- I'd rather add the ability to load most of this at least in form of a gfx resource loader on top of the current framework. Most of this code can be eliminated by loading all those resources from a file like this:

<Resources>
	<Textures path="Textures" >
		<Texture file="noise.gif" >Noise</Texture>
		<Texture file="reflection.gif" />Reflection</Texture>
	</Textures>
	<Materials path="Materials">
		<Material file="Gems\\gem_dualpass.cs" >GemMat</Material>
		<Material file="Sky\\sky_01.cs">SkyMat</Material>
	</Material>
</Resources

 

I double that. I did it on my last engine and I was really satisfied with the results.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0