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.
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
<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/Рабочий%20стол/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 />
edit: email is craig.young.81 at gmail.com
Also reload and unload texture buttons.
- 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.
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.
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.
EQ: I like that idea.
BTW I loaded obj files no prbs
can't wait to see this progress
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.
Do you think that you will have done any of your planned aditions before the deadline for the fzero comp?
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.
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
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.
- 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.
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.
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
tim
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....
Hope you get things sorted out, you've got a great little app on your hands here.
Keg - Awesome work so far dude, keep it up
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: 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
I can't open any example files though
PMed log.
Buddy: thanks. I will look into the crash log.
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
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? Because I have several more suggestions but don't want to be pointing things out that you're already aware of.
- 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.
Can we have scene files? ie you set up a character and then add lights etc and save that as a scene?
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.
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)
After instaling it I receved an ERROR.