Aller au contenu

Photo

NWShader


  • Veuillez vous connecter pour répondre
123 réponses à ce sujet

#76
Nostrebor

Nostrebor
  • Members
  • 32 messages
I looked in your source code (very nice that you make it public, by the way) and found this in class_nwshader_settings.


  • const char * index = level->Attribute("index");
  • const char * shadername = level->Attribute("file");
So I changed the config file to:

  •     <Shader index="1" file="shaders\\bloom.cgfx" />
  •     <Shader index="2" file="shaders\\depthoffield.cgfx" />
  •     <Shader index="3" file="shaders\\avatar.cgfx" />


The config file seems to be read ok, but now I get the following in the log file (and no differences to what is on the screen):


  • 0:3:6 :: NWShader: Compiling per-pixel lighting shader...
  • 0:3:6 :: Per-pixel lighting is suffering an overhaul and has been disabled.
  • 0:3:6 :: NWShader: Compiling shaders...
  • 0:3:6 :: Shader Manager FS: Some shaders failed to load.


#77
Nostrebor

Nostrebor
  • Members
  • 32 messages
Note: The double backslashs in "file="shaders\\\\..." seem to be an artifact of appending to this forum. There is only one backslash in the actual config file.


#78
Jez_fr

Jez_fr
  • Members
  • 302 messages

Jez_fr: Well, my biggest goal was a success if it doesn't crash. ;)
To test if it's running, delete the file nwshader.log and run the game. If the log is recreated, NWShader ran. you can see the settings and what exactly happened in the log file.

As for no shaders, again, I'll take a look at it. Not sure why, I based the code very closely after the last version (223).

As far as requiring the camera hack, no, NWShader does not require the camera hack. In fact, if you use NWShader, there's no need to use the camera hack: NWShader includes an improved version as an option.


First, thanks for your time =)

I deleted the log file, ran the game, and a new log was created. here it is:

17:46:58 ::    Logger created.
17:46:58 ::    NWShader: Starting...
17:46:58 ::    NWShader Chronepsis (v0.2.2.2)
17:46:58 ::            Copyright © 2010 Sean Sube
        http://nwshader.sourceforge.net
   
    All original elements of the NWShader project are licensed under
    the terms of the GNU General Public License. Under no circumstances
    may any element of NWShader be used in any proprietary project.

    Please refer to the copy of the GPL distributed with NWShader for
    further information, or, if you did not receive a copy, write to
    the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
    Boston, MA  02110-1301 USA.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    For help, support, questions, comments, or complaints, please
    send emails to Sean Sube (pkpeachykeen) at cx029a@live.com, or
    use the message boards on the NWShader SourceForge page.



17:46:58 ::    Config: Config file read.
17:46:58 ::    Config: Reading shaders list.
17:46:58 ::    Config: Done parsing config file.
17:46:58 ::    NWShader was unable to load the language file for e.
17:46:58 ::    NWShader: Started by process E:\\\\NeverwinterNights\\\\NWN\\\\nwmain.exe.
17:46:58 ::    NWShader: Attached to NWMain. NWShader will hook itself.
17:46:58 ::    NWShader: Hooking into OpenGL...
17:46:58 ::    NWShader: Hooked compressed texture creation.
17:46:58 ::    NWShader: OpenGL hooked.
17:46:58 ::    NWShader: Starting to load plugins...
17:46:58 ::    NWShader: Error searching for plugins.
17:46:58 ::    Set up DirectInput interface.
17:46:59 ::    NWShader: Creating sys check context. Not cached.
17:47:0 ::    NWShader: Making syscheck context current.
17:47:0 ::    NWShader: Deleting syscheck context.
17:47:0 ::    NWShader: Creating context.
17:47:0 ::    NWShader: does not have cached device/context. Grabbing...
17:47:0 ::    NWShader: Initializing system...
17:47:0 ::    NWShader: Hooking into engine...
17:47:1 ::    NWShader: Hooked engine functions.
17:47:1 ::    Viewport info: 0; 0; 1680; 1050
17:47:1 ::    GLEW: Started successfully.
17:47:1 ::    DevIL: Started successfully.
17:47:1 ::    Shader Factory: Starting Cg...
17:47:1 ::    Cg: Using version 2.2.0010
17:47:1 ::    Cg: Profile VP20 is not supported.
17:47:1 ::    Cg: Profile FP20 is not supported.
17:47:1 ::    Cg: Profile VP30 is not supported.
17:47:1 ::    Cg: Profile FP30 is not supported.
17:47:1 ::    Cg: Profile VP40 is not supported.
17:47:1 ::    Cg: Profile FP40 is not supported.
17:47:1 ::    Cg: Profile GPU_VP is not supported.
17:47:1 ::    Cg: Profile GPU_FP is not supported.
17:47:1 ::    Cg: Profile GP4VP is not supported.
17:47:1 ::    Cg: Profile GP4FP is not supported.
17:47:1 ::    NWShader: Creating textures...
17:47:1 ::    NWShader: Framebuffers disabled in config.
17:47:1 ::    Shader Factory: Texture format accepted.
17:47:1 ::    Shader Factory: Created texture thisframe on 1.
17:47:1 ::    Shader Factory: Texture format accepted.
17:47:1 ::    Shader Factory: Created texture lastframe on 2.
17:47:1 ::    Shader Factory: Texture format accepted.
17:47:1 ::    Shader Factory: Created texture lastshader on 3.
17:47:1 ::    Shader Factory: Texture format accepted.
17:47:1 ::    Shader Factory: Created texture lastpass on 4.
17:47:1 ::    Shader Factory: Texture format accepted.
17:47:1 ::    Shader Factory: Created texture error.png on 5.
17:47:1 ::    Shader Factory: Loaded texture error.png on 07A27FD8.
17:47:1 ::    Shader Factory: Setup complete.
17:47:1 ::    NWShader: Compiling shaders...
17:47:1 ::    Shader Manager FS: Loaded shaders.
17:47:1 ::    Set up DirectInput interface.
17:47:4 ::    NWShader: Making null context current.
17:47:4 ::    NWShader: Process deleting cached context.
17:47:4 ::    NWShader: Creating context.
17:47:4 ::    NWShader: does not have cached device/context. Grabbing...
17:47:4 ::    NWShader: Initializing system...
17:47:4 ::    NWShader: The double-start bug has struck. Attempting to reinit...
17:47:4 ::    Config: Config file read.
17:47:4 ::    Config: Reading shaders list.
17:47:4 ::    Config: Done parsing config file.
17:47:4 ::    NWShader was unable to load the language file for e.
17:47:4 ::    NWShader: Hooking into engine...
17:47:4 ::    NWShader: Hooked engine functions.
17:47:4 ::    Viewport info: 0; 0; 1680; 1050
17:47:4 ::    GLEW: Started successfully.
17:47:4 ::    DevIL: Started successfully.
17:47:4 ::    Shader Factory: Starting Cg...
17:47:4 ::    Cg: Using version 2.2.0010
17:47:4 ::    Cg: Profile VP20 is not supported.
17:47:4 ::    Cg: Profile FP20 is not supported.
17:47:4 ::    Cg: Profile VP30 is not supported.
17:47:4 ::    Cg: Profile FP30 is not supported.
17:47:4 ::    Cg: Profile VP40 is not supported.
17:47:4 ::    Cg: Profile FP40 is not supported.
17:47:4 ::    Cg: Profile GPU_VP is not supported.
17:47:4 ::    Cg: Profile GPU_FP is not supported.
17:47:4 ::    Cg: Profile GP4VP is not supported.
17:47:4 ::    Cg: Profile GP4FP is not supported.
17:47:4 ::    NWShader: Creating textures...
17:47:4 ::    NWShader: Framebuffers disabled in config.
17:47:4 ::    Shader Factory: Texture format accepted.
17:47:4 ::    Shader Factory: Created texture thisframe on 1.
17:47:4 ::    Shader Factory: Texture format accepted.
17:47:4 ::    Shader Factory: Created texture lastframe on 2.
17:47:4 ::    Shader Factory: Texture format accepted.
17:47:4 ::    Shader Factory: Created texture lastshader on 3.
17:47:4 ::    Shader Factory: Texture format accepted.
17:47:4 ::    Shader Factory: Created texture lastpass on 4.
17:47:4 ::    Shader Factory: Texture format accepted.
17:47:4 ::    Shader Factory: Created texture error.png on 5.
17:47:4 ::    Shader Factory: Loaded texture error.png on 07A2E5E0.
17:47:4 ::    Shader Factory: Setup complete.
17:47:4 ::    NWShader: Compiling shaders...
17:47:4 ::    Shader Manager FS: Loaded shaders.
17:47:4 ::    Set up DirectInput interface.
18:7:43 ::    NWShader: Making null context current.
18:7:43 ::    NWShader: Process deleting cached context.
18:7:43 ::    NWShader: Stopping...
- Closing log file (dtor)


Does it look right?
I have no clue about what it says, but there's several errors indicated, so i'm wondering XD

Thanks for helping!

Modifié par Jez_fr, 03 octobre 2010 - 04:16 .


#79
pkpeachykeen

pkpeachykeen
  • Members
  • 77 messages
Nostrebor: I'm not entirely sure yet why the shaders wouldn't be loading. I'll be watching it in a debugger later and see what I can see there. The XML settings you added are in the correct format. I have a few ideas what I broke, but watching it run will let me know for sure. :)



Jez_fr: There are no problems with that log. The "Profile xx is not supported." just report what shader profiles are available and which aren't, which helps me diagnose if its a hardware or software issue. Your system doesn't support many profiles (what card are you running, by the way?), but it was able to detect at least one vertex and fragment profile, so things should work.

#80
Nostrebor

Nostrebor
  • Members
  • 32 messages
When I checkout you code from sourceforge I noticed that ConfigWriter.cs is missing.

Is there another Forum that you would prefer these "guts of the system" posts to go?

Modifié par Nostrebor, 03 octobre 2010 - 09:44 .


#81
pkpeachykeen

pkpeachykeen
  • Members
  • 77 messages
Oops, missed that file. It's uploaded in the SVN now, rev41 should have it included. It's a very basic wrapper for an XmlWriter that simplifies <Setting name="" value="" /> tags.



As for this forum vs another, feel free to post here or the official NWShader forums. I get email notifications on this thread and should on the other forums, so I'll try to reply ASAP. There's some info on the other forum that might interest you, if you've been looking into the code. Any suggestions for bug-fixes and such I'll try to implement, or you can submit patches (so long as any contribution is under the GPL).

#82
Jez_fr

Jez_fr
  • Members
  • 302 messages

pkpeachykeen wrote...
Jez_fr: There are no problems with that log. The "Profile xx is not supported." just report what shader profiles are available and which aren't, which helps me diagnose if its a hardware or software issue. Your system doesn't support many profiles (what card are you running, by the way?), but it was able to detect at least one vertex and fragment profile, so things should work.


I have an ATI Radeon HD5770.

Maybe that's just the setting I'm not choosing correctly. When I launch the config tool, everything is unchecked. Is there a recommended setting? I must admit most are totally obscure to me XD

Thanks!

#83
pkpeachykeen

pkpeachykeen
  • Members
  • 77 messages
If you check off a box (any random box), close the config tool and open it again, is anything checked? Does it lose the check-marks, or is it just blank?



The new config tool will not work with old config files, so they will appear blank. I'll distribute a default config file with the next patch. The usual ones to check are "fullscreen shaders", "calculate depth/focus" (if you want SSAO or depth of field), the script interface if you want that, and the camera hack if you want to use that.

#84
nwn_martin

nwn_martin
  • Members
  • 11 messages
the problem lies somewhere in the logic of saving the shader section to the xml. it saves only the last selected shader (regardless if its checked or unchecked, selecting the item in the list is enough to decide it as the option to be saved) to the config.xml, but the particular shader does not seem to be active in game anyway. it looks like it is saving current selection or last item selected and does not add up any checkboxed items in the output.



ps: tooltips in the lower bar of the gui window dont show up for me anymore when hovering over the gui items, on the other hand the description text shows just fine.

#85
Nostrebor

Nostrebor
  • Members
  • 32 messages

Nostrebor wrote...

I looked in your source code (very nice that you make it public, by the way) and found this in class_nwshader_settings.


  • const char * index = level->Attribute("index");
  • const char * shadername = level->Attribute("file");
So I changed the config file to:

  •   
  •   
  •     


The config file seems to be read ok, but now I get the following in the log file (and no differences to what is on the screen):


  • 0:3:6 :: NWShader: Compiling per-pixel lighting shader...
  • 0:3:6 :: Per-pixel lighting is suffering an overhaul and has been disabled.
  • 0:3:6 :: NWShader: Compiling shaders...
  • 0:3:6 :: Shader Manager FS: Some shaders failed to load.


I compile your code and got it running on a 64 bit windows 7 machine (in case you are keeping track).  I can start the dll in the debugger (after pointing the debug executable to nwmain.exe).  If I run in fullscreen mode nwmain.exe starts throwing exceptions that I cannot seem to ignore, but if I run it in window mode everything works fine.  (The exceptions are only when the debugger is attached, if I run nwmain by itself everything works fine).

Anyway I found why the shaders were not working.  My config file said:

<Shader index="1" file="shaders/bloom.cgfx" />

but your code put the shaders qualifier on the filename for me.  When I made it

<Shader index="1" file="bloom.cgfx" />

everything worked fine.  I found that cartoon.cgfx gave the most obvious effect (not one I particularly liked, but very noticable)

#86
Nostrebor

Nostrebor
  • Members
  • 32 messages
When I was building the development enviroment I downloaded the newest cg (version 3.0). There have apparently been some langauge changes. The "Sin City" shader does not compile. It gets the errors:



"error C1101: ambiguous overloaded function reference "tex2D(sampler, float2)"



apparently there use to be a data type called sampler that has been replaced with sampler1D, 2D, etc. I tried changing the variables that were sampler type sampler2D. That compiles, but no I get a mirror "You should not see this texture" image.

#87
pkpeachykeen

pkpeachykeen
  • Members
  • 77 messages
Nostrebor: The exceptions that are thrown appear, last I checked, to originate from NWMain. I'm not sure what causes them (I'd tracked it down partially at one point), but they pop up only when the debugger is present. I usually run NWN in windowed mode, or on my second monitor (with VS on the first) to get around that.



As for the config file issue, thanks for tracking that down. I'll implement that fix tonight and recompile, hopefully be able to upload it tomorrow, if all goes well.



Oh, and you compiled NWShader itself, or the GUI? If the former, that might be the first report of someone else actually getting it to compile, or trying. :P



nwn_martin: Yeah, I have a few ideas where it may be, and most of them are in two chunks of code I changed to add the filtering feature. It should be in the GUI, since previously it was stripping the shaders/ portion of the path.

#88
Nostrebor

Nostrebor
  • Members
  • 32 messages
I compiled nwShader (generates dinput.dll). There are a couple of other mains in the project that do not compile. I think the need GLUT. I could probably get them to compile, but have not tried.



As downloaded from soureforge the solution file (.sln) a bit incompatible with visual C++ 8.0 express. It seems to include other solutions (or something like that). Anyway I took them out, changed some include and lib paths and it worked fine. The only problem I have seen so far is that my build uses Cg 3.0 which seems to have change a bit. As a result "Sin City" has compile error (other may also).



I'm kind of curious. Why did you replace dinput.dll? I would have expected opengl.dll to be the dll you replaced.

#89
pkpeachykeen

pkpeachykeen
  • Members
  • 77 messages
The other projects need updated to match some changes to NWShader, I haven't fixed them yet, until NWshader is ready.



The issue with VC Express is that the GUI is a C# project, so C++ can't load it.



I haven't seen that error in the sin city shader, but it should be related to either the nws common library or the shader itself. Just an ambiguity is easy to fix.



As for replacing dinput.dll, because it was much easier and gives me a point to hook DirectInput when/if I need control over input. It has one export, compared to the 100+ that OpenGL.dll has. The simplest way to replace a DLL with a fake one is to use LoadLibrary on the real one and GetProcAddress for every function you need, so DInput was the fastest and easiest. Back when I was using Detours, inserting an opengl.dll also could cause infinite loops in the code and stack overflows, so...

#90
Nostrebor

Nostrebor
  • Members
  • 32 messages
I tried the mithril golems and got a golem that looks like he has a black with silver crack T-Shirt on.

picasaweb.google.com/fileancabatica/Docs

I think the Sin City error is related to the newer Cg development enviroment I downloaded.

Modifié par Nostrebor, 10 octobre 2010 - 05:54 .


#91
pkpeachykeen

pkpeachykeen
  • Members
  • 77 messages
The golem is related to vertex colors, I think. I keep trying to fix it, but the broken shader slips back in. I have a working version, so I'll try to make sure that gets into the next update.



As for the Sin City error, it seems to be a minor language change that just makes two of my functions ambiguous. I've updated my Cg install and the error happens here as well, so I'll take care of it.

#92
Tarot Redhand

Tarot Redhand
  • Members
  • 2 674 messages
peachy, I was just wondering if it's easily possible to get shader to give the whole screen a pale tint. If so how would you go about it?



TR

#93
pkpeachykeen

pkpeachykeen
  • Members
  • 77 messages
Pale as in lighter, or desaturated, or both? Either way, yes.



In general, you'd want something like this:

sampler2D currentScene < string name="thisframe"; >;

float4 MakePale(in float2 screenPos) : COLOR0
{
    float4 originalColor = tex2D(currentScene, screenPos);
    float luminosity = ( originalColor.r * 0.3 ) + ( originalColor.g * 0.6 ) + ( originalColor.b * 0.1 );
    luminosity += 0.2;
    return float4(luminosity.rrr, 1.0);
}

technique main
{
    pass pale < string target="thisframe"; >
    {
        FragmentProgram = compile latest MakePale();
    }
}



That'll completely desaturate the screen and make it a bit brighter. You can lerp between the original color and the result to make it a bright/pale effect, or plenty of other things.

#94
Tarot Redhand

Tarot Redhand
  • Members
  • 2 674 messages
Thanks for that. What I actually meant was to give the whole screen say a pale red cast or maybe green. You get the idea? Not every planet in the multiverse has a yellow sun, so this could be useful for setting atmosphere.



TR

#95
pkpeachykeen

pkpeachykeen
  • Members
  • 77 messages
Ah, sure. Shaders make that sort of thing a breeze. ;) If you have any specifics, I can put something together and send over a .cgfx file for you to tweak, but here's the code to tint the screen:



float4 tintColor = { 1.1, 0.7, 1.0, 1.0 }; // format is red, green, blue, alpha. We'll multiply them, so things should be >1 to increase, <1 to decrease. 1 is white, 0 is black.
float4 sceneColor = tex2D(thisFrame, texCoord); // sample the backbuffer
sceneColor *= tintColor; // this changes the colors
return sceneColor; // send it back to the screen





In addition to that, here's a quick patch for the GUI:

http://www.mediafire...7jjrlt3tizjk7q3

It appears to be working correctly, if not, let me know. The mistakes were silly typos, but those always take forever to find (I had it saving the list of selected items, not the list of checked items, for example). It should save shaders properly, and the regex has been changed to strip the shaders/ subfolder off the names. You may need to open your config file by hand to correct that (it uses the built-in regex or whatever is in the config), it should be:

shaders\\\\(?'display'.*\\.cgfx)



(note: just looking at it, it may not be saving the regex properly. I need to test that after lunch, and I'll upload a fixed copy if it isn't. Until then, try this one)

#96
Nostrebor

Nostrebor
  • Members
  • 32 messages
 Hi,
I think I found a bug (and a fix!) in nwshader.cpp.

Background:
In order to get a better idea on how material shaders work I changed the miteral golem shader to make everything red.  I noticed that only the golem's torso was red, but the arms, legs head, etc were the original texture.

Looking in nwshader.cpp I noticed a check in "glBindTexture" that checks to see if the material should be unbound.  It looked like:

 
            if (        
                           nwshader->shaders != NULL
                   &&  nwshader->shaders->materials != NULL    )
              {
                     nwshader->shaders->materials->unbindMaterial(); 
              }



This was unbinding the material even if the material being unbound was the same material which this call to bind was requesting (i.e. just drew the golem's torso, now drawing a leg).

I changed it to:

               if (
                            texture != lastTexture &&            //jer
                            nwshader->shaders != NULL && 
                            nwshader->shaders->materials != NULL     )
               {
                           nwshader->shaders->materials->unbindMaterial(); 
               }


Now the golum is all red.  Unfortuantly sometimes the shadows are red and other times really weird textures are mapped to the tiles, and information screens.  This occurs when the golem is just  off the bottom of the screen.  I fixed the shadow problem by modifing "glend"

At the end of "glend" I placed:

//
// JER
//    Unbinding the material keeps it from showing up in shadows.
//
{
    nwshader->shaders->materials->unbindMaterial();
    textureLock = false;    // this was already in the code JER
}


Now only the weird textures remain.  I fixed this back in "glBindTexture" by commenting out some code (the first fix mentioned above is included for context.

        // JER
       // This code caused a weird problem when the model
       // which contained the texture scrolled off the bottom of the
       // screen.  It caused the player portrait to be mapped
       // on several tiles and the caracter texture to be in
      // other locations.
      //
#if 0
    if ( textureLock && ( texture != 0 ) )  {   return; }
#endif

//
// JER Adding the condition 
//   texture != lastTexture
// keeps the texture active for all nodes in the model
// previously the texture was only active for the first node.
//
if ( 
                        texture != lastTexture &&            //jer
                        nwshader->shaders != NULL && 
                        nwshader->shaders->materials != NULL 
)
{
          nwshader->shaders->materials->unbindMaterial(); 
}


I could send you the modified source code, if there is a good way to do that.

Modifié par Nostrebor, 15 octobre 2010 - 09:09 .


#97
pkpeachykeen

pkpeachykeen
  • Members
  • 77 messages
Awesome! That actually explains an oddity the popped up. I noticed, and "fixed" the shadows/weird textures issue, which is what broke the application of the shader to all portions. If your fix fixes both problems, that's great then.



As far as the source-code, there are two options. Either way, I'll need an emailed note saying you have full copyright ownership over the code (if you go to a university or work for a programming-related company, they'll need to give you permission) and are willing to contribute this snippets to the project under the terms of the GPL. It's a bother, I know, but I'd rather not face the legal issues that could otherwise arise. :)



After that, I can add it or give you write-access to the SVN repository on SourceForge, where you could upload it yourself. I'm updating the repo right now with the GUI fix, so you'll need to merge your changes in (that file shouldn't be changed, so I doubt there will be any problems).



Once your changes get in, I'll build them into the next release and give you a line in the credits. :)

#98
Gonzo_og

Gonzo_og
  • Members
  • 2 messages
Just wanted to say I love NWShader! Thanks Peachy!

#99
Nostrebor

Nostrebor
  • Members
  • 32 messages

pkpeachykeen wrote...

Awesome! That actually explains an oddity the popped up. I noticed, and "fixed" the shadows/weird textures issue, which is what broke the application of the shader to all portions. If your fix fixes both problems, that's great then.

As far as the source-code, there are two options. Either way, I'll need an emailed note saying you have full copyright ownership over the code (if you go to a university or work for a programming-related company, they'll need to give you permission) and are willing to contribute this snippets to the project under the terms of the GPL. It's a bother, I know, but I'd rather not face the legal issues that could otherwise arise. :)

After that, I can add it or give you write-access to the SVN repository on SourceForge, where you could upload it yourself. I'm updating the repo right now with the GUI fix, so you'll need to merge your changes in (that file shouldn't be changed, so I doubt there will be any problems).

Once your changes get in, I'll build them into the next release and give you a line in the credits. :)



I sent a note via bioware social with my real email address and acknowledging the GPL license.

#100
Nostrebor

Nostrebor
  • Members
  • 32 messages
I emailed the updated source file to you.



Does openGL (and therefore nwn) automatically use the gpu for vertex skinning, or is all of the matrix multiplication done by the PC?