Home 3D Art Showcase & Critiques

Model Viewer (Programming Pimp)

13
Keg
polycounter lvl 18
Offline / Send Message
Keg polycounter lvl 18
Been working on this program for about a month and a half now. The program is DirectX and C#. So far albedo maps (aka diffuse to many), specular maps, and normal maps have been implemented along with obj file loading. A big thanks to Noel Cower for debugging some issues with the shader. Also thanks to arshevolon for allowing me to use his diablo model as an example. I am looking for feedback on what works, what doesn't and suggestions for the gui.

thumbnail-full.jpg

Executable Available Here (Updated September 24)
- Added parallax mapping support
- Added specular shinyness support
- Fixed per pixel lighting.

If you have not updated to the latest directx update please do so, or else the program will crash.
August DirectX update

Planned Additions:
- Glow Maps
- Sub Surface Scattering (General and possibly a dedicated skin)
- Self shadowing
- HDR lighting
- Image backgrounds
- Ground plane (with possible texture support also)
- Multiple objects
- Other model formats (suggestions on which formats to work on?)

Thanks in advance for any comments, critiques or suggestions.

Replies

  • roolie
    I exported an obj from max to you viewer and the smooth groups were all messed up. also it messed up the uvs so the textures werent layed out on it correctly. I tried it a couple of times with the same results.
  • jaalto
    Offline / Send Message
    jaalto polycounter lvl 13
    Nice one Keg. I'll try this as soon as I get back home.
  • Oleg Linkov
    it loads diablo model, looks cool, but when I'm trying to load one of my models, exported from max, I'm getting this

    <font class="small">Code:</font><hr /><pre>See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
    at System.ThrowHelper.ThrowArgumentOutOfRangeException()
    at System.Collections.Generic.List`1.get_Item(Int32 index)
    at ModelViewer.ObjectLoader.readObjectFile()
    at ModelViewer.ObjectLoader.LoadModel(String fileName)
    at ModelViewer.GUI.loadModelButton_Click(Object sender, EventArgs e)
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


    ************** Loaded Assemblies **************
    mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ModelViewer
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Documents%20and%20Settings/Oleg%20Linkov/&#1056;&#1072;&#1073;&#1086;&#1095;&#1080;&#1081;%20&#1089;&#1090;&#1086;&#1083;/Excutable/ModelViewer.exe
    System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    Microsoft.DirectX.Direct3D
    Assembly Version: 1.0.2902.0
    Win32 Version: 9.05.132.0000
    CodeBase: file:///C:/WINDOWS/assembly/GAC/Microsoft.DirectX.Direct3D/1.0.2902.0__31bf3856ad364e35/Microsoft.DirectX.Direct3D.dll
    Microsoft.DirectX
    Assembly Version: 1.0.2902.0
    Win32 Version: 5.04.00.2904
    CodeBase: file:///C:/WINDOWS/assembly/GAC/Microsoft.DirectX/1.0.2902.0__31bf3856ad364e35/Microsoft.DirectX.dll
    Microsoft.DirectX.Direct3DX
    Assembly Version: 1.0.2902.0
    Win32 Version: 5.04.00.3900
    CodeBase: file:///C:/WINDOWS/assembly/GAC/Microsoft.DirectX.Direct3DX/1.0.2902.0__31bf3856ad364e35/Microsoft.DirectX.Direct3DX.dll

    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.

    For example:

    <configuration>
    <system.windows.forms jitDebugging="true" />
    </configuration>

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.</pre><hr />

    mverror.gif
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Hmmm roolie, oleg: think you could email me a sample mesh from max?

    edit: email is craig.young.81 at gmail.com
  • Oleg Linkov
    just sent you teh letter
  • Vylaroth
    Doesn't load my .objs either, can't even open the examples (same error as above).
  • Whargoul
    Offline / Send Message
    Whargoul polycounter lvl 18
    Will it allow custom shaders? So it could be a shader editor/viewer and model viewer?
  • EarthQuake
    Viewport rotation is pretty bad, first off its backwards, and then rotating up and down dosent really work, it only lets you do it to a slight angle which is pretty annoying. Otherwise seems to work, you should have some basic things in there like spec value, and spec sharpness.

    Also reload and unload texture buttons.
  • monkeyscience
    Offline / Send Message
    monkeyscience polycounter lvl 12
    Nice work. Do you generate your own tangent space coords? Suggestions I would have:
    - object space normalmaps
    - an ambient occlusion term in the normalmap alpha or on a separate texture with it's own UV set
    - toggling mipmapping for individual textures
    - toggling texture compression (if you use it).
    - support for Targa or some other non-compressed format (jpg rapes normalmaps like you would not believe)

    Since you're using directx, .dds support would be cool. They have all sorts of built in mipmap and compression settings you could eventually allow editing and saving of.

    There does seem to be something funky happening with the camera rotation at the poles. "Backwards" rotation is totally subjective though, some people like it the way you have it.
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Thanks for the feedback. I am looking into the issues brought up.

    Roolie: Your problem looks like it might be due to smoothing groups. Also looking at the obj file in xsi it was showing a problem with the uv's where there was lots of overlapping and quads looked more like triangles than quads.

    Oleg: problem with your mesh and that error was all the face values were negative values.

    Vylaroth: Does it crash when opening the program or when trying to load a model?

    Whargoul: That is a possability I hadn't thought of. I might add that support down the road.

    EQ: Thanks, was thinking something was off with the camera. Rotation has been fixed. Spec value and sharpness will be added. as will reload and unload.

    I will admit this has been a big learning experience since I have not really had to work with various system specs plus varying obj files.
  • EarthQuake
    Cool, those simple things will make it a LOT more useable. And when you get your more advanced features in there it looks like it will be a nice little app.
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Monkeyscience: Tangent space is calculated with directx. AO is something I am planning for future releases, probably as it's own map though. I see alot of normal maps with a height map in the alpha channel. I like the idea of toggling texture compression and mip mapping. Support for tga files is in there as the directx texture loader class handles them just fine. I included jpg's as it is a smaller file to upload and download.
  • KaosNKorruption
    Offline / Send Message
    KaosNKorruption polycounter lvl 18
    Not sure if this was intentional or not, but whatever textures were loaded for the previous model are applied to the new model when it is loaded. I would expect the model to be loaded without any textures applied.

    Also, a nice feature might be the ability to rotate the model as I think that might be easier than moving the light source and then rotating the view.
  • EarthQuake
    You should also start thinging about making your own savable material files, so when you have more complicated shaders in there its easy to just load up your model and have all your settings.
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Kaos: that's not intentional. The big thing was getting the shaders to work. So I have to go back and fix that little bug.

    EQ: I like that idea.
  • roolie
    my model has no overlaping polies. Ive exported it in 2 unreal and maya and its been just fine. it has a lot of different smoothing groups but that shouldnt be a problem unless your viewer cant hndle it.
  • Ruz
    Offline / Send Message
    Ruz polycount lvl 666
    great. i really need something like this. pan doesnt work too well, but othwerwise a great start
    BTW I loaded obj files no prbs
    can't wait to see this progress
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Roolie: here's what the uv's look like when loading the obj into xsi.

    RoolieError.jpg

    The red means overlapping uv's.
    Seems it happens when you allow quads when exporting from Max. With triangles selected in the obj exporting options it works fine.

    Ruz: Thanks, the pan needs alot of tweaks. right now it moves too fast for smaller scale models. I need to get around to tweaking that as well.
  • Cubik
    Offline / Send Message
    Cubik polycounter lvl 18
    Interesting. Maybe you could make saveable cameras that could be run by pressing a button. The idea would be a quickly get nice screens from the same angles every time you have updated the models or textures.

    Do you think that you will have done any of your planned aditions before the deadline for the fzero comp?
  • Snowfly
    Offline / Send Message
    Snowfly polycounter lvl 18
    I see great things for this viewer. Official pimping tool of Polycount. smile.gif

    Any chance of getting some texture refresh buttons in there? Or checkboxes next to the textures you want automatically refreshed when they are updated outside the viewer? I'd like to use this as part of my texturing workflow.

    As for modeling formats, FBX and Collada are good choices, especially if you plan to get animation working in there eventually.

    By the way, I get flickering artifacts on the model with normal maps turned on. Just random specks the same color as the background.

    And a usability issue: When I try to load a file that isn't an image into one of the image slots, it gives me a warning message, then asks me to load another image file. Then a pure black texture is displayed where the texture is supposed to be. That's all fine, but I suggest not letting the program display a null texture, or even better, filter out non-image files in the file loading process. That's a nitpicky low priority issue for you. smile.gif
  • jaalto
    Offline / Send Message
    jaalto polycounter lvl 13
    [ QUOTE ]
    Interesting. Maybe you could make saveable cameras that could be run by pressing a button. The idea would be a quickly get nice screens from the same angles every time you have updated the models or textures.

    [/ QUOTE ]

    That would be a nice feature smile.gif
  • ElysiumGX
    Offline / Send Message
    ElysiumGX polycounter lvl 18
    [ QUOTE ]
    I exported an obj from max to you viewer and the smooth groups were all messed up.

    [/ QUOTE ]

    .OBJ files do not retain smoothing group information. smoothing groups are used in Max because the .3ds format cannot store accurate vertex normals. try setting hard edges.
    and it's best to export .obj files from max triangulated.

    My suggestion for the viewer is the dotXSI format. Export plugins exist for most apps.
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Updated the viewer. re-worked the gui a little to allow for more options down the road.

    - Light color is in, probably needs alot of work.
    - Camera control is fixed. Both rotations and panning.
    - Control for normal map strength
    - Control for specular shinyness.

    Edit: the refesh texture does not work yet. looking into that along with a reload texture option.

    Either grab the update at the top for all the updates (changed to tga for arsh's diablo) or click here

    Also of note for those of you using 3dsmax, PLEASE export your obj as triangles. the default exportor screws up quads by making the 2nd and 3rd vertex of a face have the same uv value.
  • roolie
    its not the mesh, its the way i exported it from max. ive always had problems with .obj formats when exporting from max it just always seems to mess up.
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Yes I realize that now. At the time I didn't have max installed. Since then, I have installed the trial and have learned why I dislike 3dsmax all over again.
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Updated again, adding in ambient occlusion texture support. There isn't an example of ambient occlusion included. was testing with a model included as an example in xnormal.

    Once again the links are:
    Full Update including examples
    Just the Executable

    Edit: If anyone would like to include examples, feel free to email me at Craig.Young.81 at gmail.com.

    Also I plan on adding parallax mapping support over the weekend and if I am sober enough start working on emissive maps.
  • dur23
    Offline / Send Message
    dur23 polycounter lvl 19
    See i told you the community was aching for a viewer. Good on ya kegger.
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    And you need to be online more often dur, I can't harass you as easily through the message boards.
  • tpe
    Offline / Send Message
    tpe polycounter lvl 18
    [ QUOTE ]
    its not the mesh, its the way i exported it from max. ive always had problems with .obj formats when exporting from max it just always seems to mess up.

    [/ QUOTE ]

    It is a common thing on max models that have been made a half at a time, then one half mirrored and attached to the original half. For some reason it makes the normals have negative values even though it does not look like the polies are flipped. To cure it you can hit reset xform on the selected object, then collapse the reset in the modifyer list. the instant you do you will notice that all the polies now look flipped, so select them all and flip. Now when you export to .obj everything will be ok.

    It is especially usefull to do this if you are using xsi or zbrush, becaues if you have mapped the UVs before exporting, upping the mesh res, moddling and then for example reimporting into max for a high poly normal map projection the UVs will have been intact all the way through the process and still match the low poly pretty well. then you can add a bump/displacement to the high poly and use it as a detail map for you normal map when projecting.

    tim
  • tpe
    Offline / Send Message
    tpe polycounter lvl 18
    Sorry for getting off topic keg, great viewer there, and really usefull. It would be top of my must have lists if it had some kind of shader support too smile.gifsmile.gifsmile.gif.

    tim
  • Snowfly
    Offline / Send Message
    Snowfly polycounter lvl 18
    Is it possible to get in some checkboxes next to the textures in the scene graph?

    How about being able to save models and textures as projects as suggested before?

    It's also a bit of a resource hog at the moment, with a 50k tri model and 3 1024, it's maximizing one of my cores. Typing in firefox is laggy, and painting in Photoshop is abysmal.... frown.gif

    Hope you get things sorted out, you've got a great little app on your hands here.
  • Xaltar
    Offline / Send Message
    Xaltar polycounter lvl 17
    Tpe, you are my hero, I have been having a serious problem with max's OBJ export and my UVs, now I can finally export with propper UVs laugh.gif

    Keg - Awesome work so far dude, keep it up laugh.gif
  • Ruz
    Offline / Send Message
    Ruz polycount lvl 666
    I see you got mr noel cower involved in this. good programmer and no mean artist
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    TPE: since you're the second to request this. There seems to be some interest so I think I shall add that to the to do list. I think that'll be last as I would want to make it a nice editor setup.

    Snowfly: yea, I'm looking into improving cpu usage. right now I get maybe 3-4% usage on my dual core.

    Xalter: thanks.

    Ruz: Noel mainly helped debugging the shader so it would work on more than just my machine.
  • tpe
    Offline / Send Message
    tpe polycounter lvl 18
    [ QUOTE ]
    TPE: since you're the second to request this. There seems to be some interest so I think I shall add that to the to do list. I think that'll be last as I would want to make it a nice editor setup.

    Snowfly: yea, I'm looking into improving cpu usage. right now I get maybe 3-4% usage on my dual core.

    Xalter: thanks.

    Ruz: Noel mainly helped debugging the shader so it would work on more than just my machine.

    [/ QUOTE ]


    That would be really cool, one other thing that would make it into a really usefull texturing tool, and please dont rebate me if it already has it, is for it to check the time stamp on the textures, so as if they get changed, for example by hitting control s in photoshop, and reloaded them each time they got changed, then you can just have it open all the time you are texturing and see the changes as they happen.

    tim
  • buddy the designer
    Great work, I'd like to see future releases and a .psd support smile.gif

    I can't open any example files though frown.gif

    PMed log.
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Tpe: that is something I am looking into and hopefully have implemented soon. I also want to get the performance issues resolved.

    Buddy: thanks. I will look into the crash log.
  • Ruz
    Offline / Send Message
    Ruz polycount lvl 666
    I noticed the obj model is reversed in the x axis in the model viewer.
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Ruz: Thanks for making me feel like an idiot :P Turns out a simple fix so no big changes. next update will have that fixed.
  • Ruz
    Offline / Send Message
    Ruz polycount lvl 666
    ha ha , no probs man
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Another update:

    Performance should be improved. Please let me know about if the performance is better now.

    This time textures are checked and reloaded if newer upon the program regaining focus. If the preferred route would to check every few seconds, that can be setup easily.

    Also improved the ambient light options and the selection tabs bring up a pop-up.

    Once again:
    Just The Update
    Full Version with examples
  • Ruz
    Offline / Send Message
    Ruz polycount lvl 666
    a lot faster now. i noticed something odd though. The angular edges of the low poly mesh are highlighted when the spec should be soley from the normal map/specular map if that makes sense.
  • Snowfly
    Offline / Send Message
    Snowfly polycounter lvl 18
    I noticed that too. It looks like a mix of vertex and per pixel lighting.

    Great update again man. I'm loading 3 1024x1024 32-bit TGA files with no lag, and Photoshop runs smoothly. Refreshing on focus is the right call.

    Do you have a roadmap for this? smile.gif Because I have several more suggestions but don't want to be pointing things out that you're already aware of.
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    snowfly: roadmap right now is
    - adding presets for camera/ light positions
    - parallax mapping
    - shadows
    - emissive maps
    - hdr lighting
    - multiple lights
    - background images
    - ground plane
    - multiple objects
    - sub surface scattering
    - custom shader support/basic text editing of shaders.

    about that order. no promise of the exact ordering other than custom shader support and authoring is near the end as a priority.

    I am glad of the performance problem being resolved. I will look into the lighting issue. It probably stems from the per pixel lighting setup for when there's no normal maps.
  • Ruz
    Offline / Send Message
    Ruz polycount lvl 666
    sounds great keg. can't wait for more updates.
    Can we have scene files? ie you set up a character and then add lights etc and save that as a scene?
  • dur23
    Offline / Send Message
    dur23 polycounter lvl 19
    I don't even know what online is!
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    After two weeks of slacking and taking a programming test, I finally got around to implementing parallax mapping.

    Question that remains is how to integrate it. Right now it's tied to the alpha channel of a normal map. Should it have it's own texture or not? I am not certain of the standard route for parallax mapping.

    Next I figure adding support for specular shinyness in the alpha channel of the specular map.

    Help and feedback is welcome as I am uncertain about how certain features are to be implemented.

    Edit: I will upload a new version tomorrow with support for the specular power as part of the specular map's alpha channel.
  • dur23
    Offline / Send Message
    dur23 polycounter lvl 19
    Yes separate texture. Also with the shininess i would keep that in its own file for now. If a person is using that in engine usually that shininess texture is not so big. Like you might have a 1024* spec and a 256 shininess. So i'd keep it separate. smile.gifHAI GUI!
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    Updated.

    Added parallax mapping support for people with pixel shader 3 cards. (couldn't get it to compile with 2.0). Gives an error for those attempting to use it with a card that only supports pixel shader 2.0.

    Also specular shinyness control in the alpha channel has been added. Along with fixes to the per pixel lighting to it is 100% per pixel not a mix between vertex and per pixel as it was.

    Model Viewer, Sept 18 update

    Model Viewer Update (just the exe, shader and readme)
  • fantasymaster
    Offline / Send Message
    fantasymaster polycounter lvl 12
    Can not start the viewer! Windows said you need to instal Net.Framework 2.0.
    After instaling it I receved an ERROR.
13
Sign In or Register to comment.