Jump to content

klepto2

Developers
  • Posts

    854
  • Joined

  • Last visited

Posts posted by klepto2

  1. Just as reminder:

    You can do something like this in glsl:

     

    code with #pragma include:

     

    #version 400
    
    uniform sampler2D texture1;
    uniform sampler2D texture2;
    uniform bool isbackbuffer;
    uniform vec2 buffersize;
    uniform float currenttime;
    uniform float intensity = 2.0;
    
    out vec4 fragData0;
    
    #pragma include "functions.glsl"
    
    void main(void)
    {
     vec2 icoord = vec2(gl_FragCoord.xy/buffersize);
     if (isbackbuffer) icoord.y = 1.0 - icoord.y;
    
     vec4 scene = texture2D(texture1, icoord); // rendered scene
     vec4 blur = texture2D(texture2, icoord); // glowmap
     fragData0 = clamp(scene + (blur*intensity), 0.0, 1.0);
    }
    

     

    and the merged code:

     

     

    #version 400
    
    uniform sampler2D texture1;
    uniform sampler2D texture2;
    uniform bool isbackbuffer;
    uniform vec2 buffersize;
    uniform float currenttime;
    uniform float intensity = 2.0;
    
    out vec4 fragData0;
    
    #line 1 'functions.glsl'
    //code of functions.glsl
    #line 12 0
    
    void main(void)
    {
     vec2 icoord = vec2(gl_FragCoord.xy/buffersize);
     if (isbackbuffer) icoord.y = 1.0 - icoord.y;
    
     vec4 scene = texture2D(texture1, icoord); // rendered scene
     vec4 blur = texture2D(texture2, icoord); // glowmap
     fragData0 = clamp(scene + (blur*intensity), 0.0, 1.0);
    }
    

     

    An idea for the auto reloading: maybe you can only scan open shader files if they use the #include statement and reload only these.

  2. Well, i understand why you may focus on other things currently, but both of your points are not truely valid.

     

    1. not getting the correct error-line:

    Might be a bit harder to implement, but keeping the original and processed code (maybe even with some metadata) a simple diff should already work. You should be able to register if an errorline is in the included part or not and be able to jump into the correct file.

     

    2. impossible to reload?

    Definetly not impossible, but might be a bit tricky. Short solution: ignore includes for the reload, just track saves for the main shader. I could live with that.

     

  3. Most posteffects will only be available through the current "Workshop" or later through the real steam workshop.

    Currently only pure "*.shader" posteffects are supported via the in Editor option.

     

    Some advanced effects will need multiple passes. Bloom for instance needs blurred and downsampled buffers which are prepared in the lua script. So while it may work with the in editor settings there might be issues which will be only resolved when lua posteffects are officially supported in the editor.

  4. If i see it correctly (I don't have Le installed here at work) its missing the shadow-shader.

    Open the material editor and go to the shader tab.

    Go the shadow shader and select the "shaders/shadow/shadow+animated.shader" Shader-file.

    Save it and it should work.

  5. UDK makes the same as LE, but under the hood. UDK has a really advanced material-system which generates the shader on demand. Their material system is more or less a bunch of multiple scripts which are later compiled to the target shader language. (like the flowgraph in LE) Under the hood UDK as well has several (if not much much more ) predefined shader templates which are used depending if the model is animated, opaque or something completely different.

     

    Could Leadwerks do the same? Yes, theoretically. To be honest i believe such a system needs a lot of manpower and time to make it stable and usable. (the things needs to be optimized, optional compilation pathes based on gpu, etc. ) So currently Leadwerks is going the easy and stable way, instead of delivering something unfinished which might be more complicated than the system right now.

     

    PS: Leadwerks is not UDK and will never be.

    • Upvote 2
  6. Skinning is done in a shader because it is multiple times faster than on cpu.

    Nearly any modern engine uses seperate shaders for skinned animation.

    On most of them you might not notice it because they preparse shader code and use #define statements or other methods

    to branch one shader into multiple ones.

    This was the way LE2 did it. While it is easier for the enduser to just have one shader (sometimes called "ubershader" or "godshader") it is not that easy to implement the correct branching and parsing structure. Also you are mainly dependend from one shader and everything needs to be included in it. So just creating a eg. phong shader and share it with the community wouldn't be that easy.

    • Upvote 1
  7. Hi Josh,

     

    I have written my own alphatest shaders with correct transparent shadows.

     

    When i use a material with one of these shaders, apply it to a model and place this model above a terrain it looks like this:

     

    post-4-0-57278900-1391121516_thumb.png

     

    Now delete the terrain and recreate it and it will look correct:

     

    post-4-0-01124000-1391121614_thumb.png

     

    Now if you leave the editor and restart it, then the bug is again visible and you need to delete/recreate the terrain again, to have correct shadows.

     

    I have a small project prepared: just load bug.map and you should notice the bug.

     

     

  8. I just get a crash, no hint about an error.

     

    [Edit]

    I just debugged it with gDebugger and got a bit more info:

     

    Leadwerks::Camera::PostProcess - camera.cpp, line 177

    Leadwerks::OpenGL2Camera::Render - opengl2camera.cpp, line 269

    Leadwerks::World::Render - world.cpp, line 488

    tolua_luacommands_World_Render00 - lua-gluecode.cpp, line 29559

     

    Maybe this helps a bit more.

  9. Ok. Well I thought the sample might be enough to demonstrate the behaviour, but i will try to explain it more detailed:

     

    Expected:

    All files in a project template with a extension which could be found in the .werk files section "ScanAndReplaceFiles" should be scanned and all occurances of variables like $PROJECT_TITLE, etc should be replaced in these files.

     

    Actual Behaviour:

    This only works for some predefined files (mainly the cpp project and source file). In the current version if i add a new file extension to the "ScanAndReplaceFiles" section, the content of files with the new extension is left unmodified, but the filename is still correclty scanned and replaced.

     

     

    Sample "ScaneAndReplaceFiles" section:

    ScanAndReplaceFiles="werk,cpp,resc"

     

    Sample File located somewhere in the templatefolder:

     

    Filename = "$PROJECT_TITLE.resc"
    
    Content:
    Title ="$PROJECT_TITLE"
    

     

    After creating a project based on this template the result is something like this:

    Projectname = myproject

    Filename: myproject.resc
    Content:
    Title ="$PROJECT_TITLE"
    

     

    I hope this explains the behaviour a bit better.

  10. You don't need the callback, its optional. You can access all entities in a world after your map is loaded like this:

     

    for(std::list<Entity*>::iterator it = world->entities.begin(); it != world->entities.end(); it++)
    {
    	Entity* entity = *it;
    	Leadwerks::System::Print(entity->GetKeyValue("name"));
    }
    

     

    The script workaround is just for CSG objects, which are normally collapsed and optimized while the map is loaded and so they are no real entities anymore. Everything else is loaded out of the box.

  11. For me it worked with static and animated entities, will check it again later, but it worked 5 minutes ago.

     

    The callback thing was long awaited feature since LE2. You can not only make (in my opinion) cleaner code to handle special entites, but you can also integrate some kind of progress indicator. The callback itself has nearly no penaltiy on speed, as a maploader always needs to lpad an entity one by one and it doesn't hurt calling a small function providing such info.

     

    Well, for me the callback can be extended to provide some progress info as well beside sthe loaded entity. Like number of entiy and total entity count. Mybe some kind of mapinfo class might be suitable. These infos could be sotred in the header and don't need much space.

     

  12. Hi,

     

    I have a couple of custom project templates based on the c++ one, but with small added files like basic config etc. Before the everything worked like a charm, but now if i want to have the project variables replaced in 3rd party files it didn't work anymore.

     

    I have added the required extension to the ScanAndReplace section in the werk file andpreviously this worked, but now all my new created projects are useless.

     

    I have attached a small modified c++ template which has a modified werk file ( extension 'resc' added to the scan and replace option) and a 'resc' file under the source folder.

     

    C++(modified).zip

  13. Hi,

     

    this is the usage i found out to help our glsl god "shadmar" ;)

     

    
    #include "App.h"
    using namespace Leadwerks;
    App::App() : window(NULL), context(NULL), world(NULL), camera(NULL), buffer(NULL) {}
    App::~App() { delete world; delete window; }
    Vec3 camerarotation;
    #if defined (PLATFORM_WINDOWS) || defined (PLATFORM_MACOS)
    bool freelookmode=true;
    #else
    bool freelookmode=false;
    #endif
    bool App::Start()
    {
    //Create a window
    window = Window::Create("ShadmarTest");
    //Create a context
    context = Context::Create(window);
    //Create a world
    world = World::Create();
    //Create a camera
    camera = Camera::Create();
    camera->Move(0,2,-5);
    //Hide the mouse cursor
    window->HideMouse();
    std::string mapname = System::GetProperty("map","Maps/start.map");
    Map::Load(mapname);
    //Move the mouse to the center of the screen
    window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2);
    //Create Buffer & Texture
    buffer = Buffer::Create(256,256,1,0,0);
    buffer->SetColorTexture(Texture::Create(256,256));
    return true;
    }
    bool App::Loop()
    {
    //Close the window to end the program
    if (window->Closed()) return false;
    
    //Press escape to end freelook mode
    if (window->KeyHit(Key::Escape))
    {
     if (!freelookmode) return false;
     freelookmode=false;
     window->ShowMouse();
    }
    if (freelookmode)
    {
     //Keyboard movement
     float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Time::GetSpeed() * 0.05;
     float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Time::GetSpeed() * 0.05;
     camera->Move(strafe,0,move);
     //Get the mouse movement
     float sx = context->GetWidth()/2;
     float sy = context->GetHeight()/2;
     Vec3 mouseposition = window->GetMousePosition();
     float dx = mouseposition.x - sx;
     float dy = mouseposition.y - sy;
     //Adjust and set the camera rotation
     camerarotation.x += dy / 10.0;
     camerarotation.y += dx / 10.0;
     camera->SetRotation(camerarotation);
     //Move the mouse to the center of the screen
     window->SetMousePosition(sx,sy);
    }
    //Update world and Time
    Time::Update();
    world->Update();
    //Render to Buffer (CLS Color set to red)
    camera->SetClearColor(1.0f,0.0f,0.0f);
    buffer->Enable();
    buffer->Clear();
    world->Render();
    buffer->Disable();
    //Render to Backbuffer (normal Context) (CLS Color set to black)
    camera->SetClearColor(0.0f,0.0f,0.0f);
    Context::SetCurrent(context);
    world->Render();
    //Draw Buffer
    context->DrawImage(buffer->GetColorTexture(),0,0,256,256);
    context->Sync(false);
    return true;
    }
    
    

     

    I hope this will help you.

    • Upvote 1
×
×
  • Create New...