About Store Forum Documentation Contact
Donations:
289$/mo



Post Reply 
CustomShader Path in 2.0
Author Message
kevindekever Offline
Member

Post: #1
CustomShader Path in 2.0
Hello,
i can not find out why it fails on compile in project dir , but working in customdir
(both directories got same datafiles)

Code:
not working:
(Str)EE_PROJECT_PATH + "/Shader/Shader.cpp"
"C:/Users/Kever/Desktop/Esenthel 2.0/Projects/oo13o9e566w54in4t1qjix2b/Game/Shader/Shader.cpp"

working:
"C:/esenthel/Shader/Shader.cpp"

   
   
03-02-2013 10:18 AM
Find all posts by this user Quote this message in a reply
gwald Offline
Member

Post: #2
RE: CustomShader Path in 2.0
Do the original demos also work?
I'm guess it could be the longer path name?
I install under C:\ root
I think the wiki suggests it.

My Blog
http://www.esenthel.com/community/showthread.php?tid=6043

I hang out at Esenthel IRC Channel
http://webchat.freenode.net/?channels=#Esenthel
03-02-2013 10:57 AM
Visit this user's website Find all posts by this user Quote this message in a reply
kevindekever Offline
Member

Post: #3
RE: CustomShader Path in 2.0
longer pathname ...after cut and paste to root, it is working!
Code:
ShaderCompile((Str)EE_PROJECT_PATH + "/Shader/Shader.cpp",(Str)EE_PROJECT_PATH + "/Shader/2/User/Custom Shader", SM_2);  
     ShaderCompile((Str)EE_PROJECT_PATH + "/Shader/Shader.cpp", (Str)EE_PROJECT_PATH + "/Shader/3/User/Custom Shader", SM_3);

Thanks grin
03-02-2013 11:19 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: CustomShader Path in 2.0
Just tried a really long path:
ShaderCompile(
"C:/Projects/Esenthel 2.0 testrt path aklhsd oiyas iajsdk/EsenthelEngineSDK81237618273t8123tr1872358123571623r5716523716523761527361r23761​r27361r23/Data/Shader/Shader.cpp",
S+"C:/Projects/Esenthel 2.0 testrt path aklhsd oiyas iajsdk/EsenthelEngineSDK81237618273t8123tr1872358123571623r5716523716523761527361r23761​r27361r23/Data/Shader/4/User/Custom Shader", SM_4);

(tried this for both DX9 and DX10, SM_2/SM_3 for DX9 and SM_4 for DX10)

And it worked. Perhaps you're not using latest version of EE? Couple releases ago there was a problem with compiling shader paths in DX9 build, but it was fixed.
03-02-2013 01:43 PM
Find all posts by this user Quote this message in a reply
kevindekever Offline
Member

Post: #5
RE: CustomShader Path in 2.0
mhh downloaded all store files this morning ^^ so i got latest version...perhaps security reasons, i don't know. After relocating the EE 2.0 folder from desktop to root it is working. Relocating back to desktop ends in error.

another strange error same to path....in root i dont need EE_PROJECT_PATH, the given/original method "void CompileShaders()" works, in desktop slashes changed
   
   

you can see the paths in the console
(This post was last modified: 03-02-2013 02:47 PM by kevindekever.)
03-02-2013 02:25 PM
Find all posts by this user Quote this message in a reply
kevindekever Offline
Member

Post: #6
RE: CustomShader Path in 2.0
I like the "Flow Effect" added physics and rolling on a textured plate looks nice
03-02-2013 11:17 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: CustomShader Path in 2.0
Hi,

Just tried moving the EE 2.0 folder onto desktop with this code

Code:
/******************************************************************************

   I. Making Shader Creation Available

      Using custom shaders is available only if you have purchased the "Shader Headers" from Esenthel Store - http://www.esenthel.com/?id=store
         Download the Shader Headers from Esenthel Store
         Extract the archive to your hard disk.
         Please edit the file "EsenthelEngineSDK\Data\Shader\Main.h",
            and change the path to the place where you have extracted the shader archive.

   II. Compiling Shaders

      Shaders need to be stored in following folders in your GameData location:
         "Shader/2/User/"  - here "2"  specifies shaders for Shader Model 2.0
         "Shader/3/User/"  - here "3"  specifies shaders for Shader Model 3.0
         "Shader/4/User/"  - here "4"  specifies shaders for Shader Model 4.0+
         "Shader/GL/User/" - here "GL" specifies shaders for OpenGL

      You must use the "User" subfolder to avoid accidental names collisions with already available engine shaders.
         For example if the engine has a shader "sample shader" located in "Shader/3/sample shader"
         Then if you create your own "sample shader" and store it in "Shader/3/sample shader"
         The engine will get confused which shader to use.
         So for avoiding names collisions, please store all your shaders in "User" subfolder, like this "Shader/3/User/sample shader"

   III. Using Compiled Shaders

      When accessing shaders in the game, do not specify the full path
         for example don't specify    - "Shader/3/User/custom shader"
         but specify only shader name - "User/custom shader"
         The engine will automatically add "Shader/2/", "Shader/3/", ... prefixes depending on which Shader Model is available.

      In order to specify custom shaders usage you must use a global function which will override default shader assignment.
         To do that we'll create a 'GetShader' function which will return manually selected shaders according to mesh parameters.

/******************************************************************************/
Mesh box,
     ball;

enum X
{
   MUS_DEF,
   MUS_CUSTOM
}

MaterialPtr brick;
Material    brick_with_custom_shader; // use a separate material to make an easy detection wheter to use custom or default shader
/******************************************************************************/
void CompileShaders()
{
   // typically shaders will be compiled in a separate tool, so the game will only load compiled data
   // but for simplicity we'll compile the shaders here

   if(D.shaderModel()==SM_GL)
   {
      ShaderCompile(S+EE_PROJECT_PATH+"/Shader/Shader.cpp", S+EE_PROJECT_PATH+"/Shader/GL/User/Custom Shader", SM_GL); // compile using OpenGL and store output file in "Shader/GL/User"
   }else
   if(D.shaderModel()>=SM_4)
   {
      ShaderCompile(S+EE_PROJECT_PATH+"/Shader/Shader.cpp", S+EE_PROJECT_PATH+"/Shader/4/User/Custom Shader", SM_4); // compile using shader model 4.0 and store output file in "Shader/4/User"
   }else
   {
      ShaderCompile(S+EE_PROJECT_PATH+"/Shader/Shader.cpp", S+EE_PROJECT_PATH+"/Shader/2/User/Custom Shader", SM_2); // compile using shader model 2.0 and store output file in "Shader/2/User"
      ShaderCompile(S+EE_PROJECT_PATH+"/Shader/Shader.cpp", S+EE_PROJECT_PATH+"/Shader/3/User/Custom Shader", SM_3); // compile using shader model 3.0 and store output file in "Shader/3/User"
   }
}
/******************************************************************************/
ShaderTech* GetShader(RENDER_MODE mode, Material *material[4], UInt mesh_base_flag, Int lod_index, Bool allow_tesselation) // this is the function which will manually choose shaders for the meshes when needed
{
   if(material[0])switch(material[0]->user_shader) // test if the first material has 'user_shader' specified
   {
      case MUS_CUSTOM: // if it's set to custom
      {
         // set shader only for RM_BLEND mode, because this is the simplest mode to make shaders for
         if(mode==RM_BLEND)
         {
            return Shaders("User/Custom Shader")->firstTech(); // load the custom shader from shaders cache
         }else
         {
            return NULL; // return NULL so the mesh won't be displayed in any other rendering mode
         }
      }break;
   }

   // in other case
   return GetDefaultShader(mode, material, mesh_base_flag, lod_index, allow_tesselation); // return the default shader
}
/******************************************************************************/
void InitPre()
{
   EE_INIT();
   D.ambientPower(0.1f);

   D.setGetShaderFunc(GetShader); // specify manual shader selection, by setting custom 'GetShader' function, which will manually choose which shader to use for the meshes
}
Bool Init()
{
   Cam.dist=3;

   // compile shader
   CompileShaders();

   // load materials
   brick=UID(2123216029, 1141820639, 615850919, 3316401700);
   brick_with_custom_shader=*brick                ; // copy all parameters from 'brick' to 'brick_with_custom_shader'
   brick_with_custom_shader.user_shader=MUS_CUSTOM; // change this materials 'user_shader' enum value to 'MUS_CUSTOM'
   brick_with_custom_shader.validate();             // changing parameters requires validation

   // create meshes
   box .parts.New().base.create( Box(5), VTX_TEX0|VTX_NRM|VTX_TAN).reverse();
   ball.parts.New().base.create(Ball(1), VTX_TEX0|VTX_NRM|VTX_TAN)          ;

   // set materials
   box .setMaterial( brick                   ).setRender().setBox(); // set 'brick                   ' for box  mesh
   ball.setMaterial(&brick_with_custom_shader).setRender().setBox(); // set 'brick_with_custom_shader' for ball mesh, this will make the ball mesh to use the custom shader

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   CamHandle(0.1f, 1000, CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));

   return true;
}
/******************************************************************************/
void Render()
{
   switch(Renderer())
   {
      case RM_PREPARE:
      {
         box .draw(MatrixIdentity);
         ball.draw(MatrixIdentity);

         LightPoint(20, Vec(0,3,3)).add();
      }break;
   }
}
void Draw()
{
   Renderer(Render);
}
/******************************************************************************/
And Full success.

Project full path:
C:\Users\Grzesiek\Desktop\Esenthel 2.0\Projects\541oob6a_h_5el6-6!zan_50\Game

I have UAC enabled in Windows.

Maybe you don't have enough room on disk? (although shader files are small)
Or some folders "Game/Shader/2" are not created?
Or maybe this is some permission issue.

You can try DX9/DX10 versions.
You can try manually creating a file in where the target shader file should be, and see if you can create it.
File f; f.write("....");
03-03-2013 03:01 PM
Find all posts by this user Quote this message in a reply
kevindekever Offline
Member

Post: #8
RE: CustomShader Path in 2.0
Don't know, i think it was a permission issue to Windows, because 400gb schould be enough. I just moved too, so Folders/Files can not be the problem. Desktop was only a temporary solution, until i got my external drive back and i could continue my project. Thanks anyway!
(This post was last modified: 03-03-2013 03:59 PM by kevindekever.)
03-03-2013 03:53 PM
Find all posts by this user Quote this message in a reply
Post Reply