A source of inspiration for me has been Frank Luna's popular book "Introduction to 3D Game Programming with DirectX11"
http://www.amazon.com/Introduction-3D-Ga...1936420228
For me to learn a new engine, it has always been easier to port over applications that I know and have built in previous engines. So with this in mind, and to enable me to use custom shaders within EE, I've decided to modify the examples in Frank's book for use with EE. I'm going to take it slowly, chapter by chapter, until I've understood and mastered the more advanced shaders. This exercise is important to me for the continuation of my "Surfing Simulation Project".
I've thought that at the same time as I proceed with this exercise I could enlighten the newer members of this community, who maybe experiencing the same learning difficulties as myself, with my efforts. I will provide the whole project (source and all) as I proceed through the book. Bare in mind that my code is probably a little outdated and 'simple' compared to all the latest OOP techniques, but it gets the job done and I try to keep it easy to follow. Note that it is not a tutorial on the use of EE (there are many here who are so much more accomplished and experienced in EE than myself to produce tutorials), but by following my code I feel sure you will find it easier to start getting to grips with the use of custom shaders in Esenthel.
So if you do not have Frank's book already, do purchase it and follow along.
The first example is a "Shapes Demo" which produces a simple scene using procedurally drawn shapes. This scene will be enhanced upon as I proceed through each chapter of the book. At the moment it is just produced in wireframe or flat color.
I use my own form of camera control which uses only the keyboard and not the mouse. The movement instructions are available on holding down [F1].
ShapeDemo_executable
The next example is called "Light Demo" and again produces a simple scene depicting some procedurally drawn 'hilly land' with a flat plane of 'disturbed water' which is lit by three light types (directional, point, and spotlight). This is the first use of a custom shader which contains the HLSL code for these lights, and will be used as a lighting template for use in further shaders. I've enhanced the example by providing an EE GUI for controlling the lighting shader parameters.
LightDemo_executable
I've really had fun playing with this, and have already learnt a lot about the different effects that colored lighting can have on a scene. I guarantee that you will also find it fun and beneficial! You'll notice that I've marked the point light and spotlight
sliders as "INACTIVE". This is because the light translation and orientation is controlled via code. The point light circles above the scene, and the spotlight is attached to the camera and points in the camera direction.
Just a few notes on the project requirements:
1) Only Windows 32bit
2) Only DirectX 10+
3) For the shaders to compile you must duplicate my particular setup (or change to suit your own)
a) A folder called "Shader HLSL" must be added to your Esenthel "Editor/Projects" folder. This folder will contain all the custom shaders.
b) at the top of each shader code there is a #include "Main.h". This "Main.h" contains a reference to the folder containing the Esenthel-specific shader headers.
In my case:
Quote:/******************************************************************************/
// here you need to set the path to your "EsenthelEngineShader" folder
#include "C:/EsenthelEngine_DX10plus/Editor/Projects/EsenthelEngineShader/Main.h"
/******************************************************************************/
[/code]
c) The "EsenthelEngineShader" folder contains the Esenthel shader headers included in the "Main.h" file, which looks as follows:
#include "Defines.h"
#include "Engine Defines.h"
#include "2D Constants.h"
#include "Constants.h"
#include "Functions.h"
#include "Render Functions.h"
#include "Structs.h"
#include "2D Functions.h"
#include "Light.h"
#include "Engine Constants.h"
#include "Engine Functions.h"
#include "Ambient Occlusion.h"
#include "Water.h"
#include "Sky.h"
d) At the top of my Esenthel project Application "Main" code file there is the include:
#include"C:/EsenthelEngine_DX10plus/Editor/Projects/material_user_shader.enum.h"
This "material_user_shader.enum.h" file contains the following:
/******************************************************************************/
enum MATERIAL_USER_SHADER
{
MUS_DEFAULT,
MUS_CUSTOM ,
MUS_CUSTOM2,
MUS_CUSTOM3,
};
/******************************************************************************/
which reference the custom shader names used in the code.
e) And, finally, the code used to compile the shaders places the compiled shaders in a specific set of folders which must be manually added to your specific project folder(the one with the encrypted name).
I've supplied a folder called "Copy contents of this folder to your Project folder"...just copy and paste its contents for each new project you start.
Hopefully, that's it... good luck!
CustomShaderLearningProject_latest project files 09-12-2014