Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Scooby_Doo on September 18, 2006, 12:41:11 am

Title: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 18, 2006, 12:41:11 am
Since DirectX seems to be unsupported now. I've been trying to use opengl... but it looks ugly...

I've got the launcher Video to OpenGL, 1024*768, 32bit, Tri, 1XAF, high settings.  Command line is:
D:\FreeSpace2\fs2_open_3_6_9.exe -mod scooby -spec -glow -jpgtga -mipmap -cache_bitmaps -dualscanlines -orbradar -ship_choice_3d -3dwarp -warp_flash -wcsaga -snd_preload -fps

With DirectX (using the same settings) I get this [underbelly shot]:
(http://img.photobucket.com/albums/v356/Shodan_AI/direct-x.jpg)

And with OpenGL:
(http://img.photobucket.com/albums/v356/Shodan_AI/opengl.jpg)
The ambient is way too high and the shinemaps are way way too glossy, smooth (the directx version actually kinda ripples as you move over the "bumped" surfaces)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: WMCoolmon on September 18, 2006, 12:44:50 am
Code: [Select]
-ambient_factor 65 FTW.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 18, 2006, 01:22:08 am
That helped get some of the brightness down. I had forgotten about ambient_factor  :nervous:

Still doesn't solve the problem with shinemaps
DirectX:
(http://img.photobucket.com/albums/v356/Shodan_AI/dirctx2.jpg)
OpenGL:
(http://img.photobucket.com/albums/v356/Shodan_AI/opengl1.jpg)
Is there a flag to specific spec range?
Title: Re: Getting OpenGL to look as good as DirectX
Post by: taylor on September 18, 2006, 03:02:20 am
Remember that OpenGL will use mipmaps properly and that D3D doesn't.  That means that the actual image may be different, not just settings.  In the detail options screen make sure that "3D Hardware Textures" is set to the maximum, otherwise it will not make full use of your mipmap chain.  If you have a texture map which is 512x512, with mipmaps down to 1x1, then D3D will always use 512x512 as the first layer.  OpenGL, if you have "3D Hardware Textures" on dot 4 rather than dot 5, will use 256x256 as the largest map.  So OpenGL actually makes use of your detail screen settings while D3D does not, and that messes some people up when they aren't aware of this and try to compare quality.

Also, you need to use an Anisotropic Filter setting of at least 2x, since 1x is actually off.  The 5.5 Launcher (not publicly available yet) fixes this to actually give you the off setting rather than tell you it's 1x.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 18, 2006, 03:16:36 am
Sorry I'm not seeing "3d Hardware Textures" in either launcher or the display control panel.

With the old 6.14 nvidia drivers, I've set Image Settings to quality, AA - application (none), AF - application (none),  no texture sharpening?, use desktop color depth, autoselect buffer flipping, vsynch on and disabled texture clamp
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Shade on September 18, 2006, 03:24:34 am
It's an in-game setting. Options screen->detail->3rd option from the top in the left column.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 18, 2006, 03:31:05 am
Ahh the one place I didn't think of... it is set at high (3d hardware textures is max)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Kazan on September 18, 2006, 07:01:08 am
technically speaking your title is wrong - d3d is pretty much always playing catch up with OGL and it's extensions :D
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Bobboau on September 18, 2006, 02:00:20 pm
*cought*drawingtotextures*cough*
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 18, 2006, 03:35:43 pm
Well if directX is playing catchup, then is it possible to opengl to have that vibrant shine appearance or do I have to wait for bumpmapping?
It looks like someone took floor wax and waxed the ships, giving it a dull smooth appearance LOL

Drawingtotextures?
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Wanderer on September 18, 2006, 03:43:54 pm
You can change some parameter via command line... http://www.hard-light.net/wiki/index.php/Command-Line_Reference#Graphics_2 (http://www.hard-light.net/wiki/index.php/Command-Line_Reference#Graphics_2)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Flipside on September 18, 2006, 03:56:44 pm
I'm wondering how much of this is to do with Drivers now, I don't know if the ATI shine problem is solved because it's actually quite difficult to tell.

I think this is all going to be a pretty moot point once the Shaders come in anyway, at least, I am hoping so :)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: taylor on September 18, 2006, 05:21:59 pm
Is that model and textures available somewhere?  I'd like to take a look at it just to see if it's a system thing, or general code thing.  Video drivers do play a big part in quality so that could be some, or all, of the problem.  Lighting is different between D3D and OGL, but I don't really want to bother tweaking it to match D3D (especially since I like OGL lighting as it is).  The OpenGL code is optimized to allow better control though since the drivers and settings can have much more effect on the visual appearance and performance than it would in D3D.

*cought*drawingtotextures*cough*
Which the OpenGL code already has, if that's what you mean.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 18, 2006, 05:27:55 pm
Here you go:
http://www.badongo.com/file/1429699 (http://www.badongo.com/file/1429699)
(You'll need to replace the tbm file, but the dds and pof are there)

Shaders are getting closer? Eeeck I'll have to start looking for a new video card then.  :nervous:  Plus I don't have the faintest idea how to use them.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: taylor on September 18, 2006, 07:04:04 pm
Here you go:
It's just the mipmaps, OGL uses them, D3D doesn't.  So in the techroom you aren't seeing the full detail since it will use the mipmap layer which is best sized to the geometry.  It would have more detail in the lab, but I think it would still use one level down even then (depends on your screen resolution).

This is why I hate D3D vs. OGL comparisons at this point.  The D3D code is so out of date that it can't be used in any valid quality comparison.


Shaders are getting closer?
I'm not going to start working on them again until after 3.6.9, and after bumpmaps are working.  You've got a while still. :)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 18, 2006, 08:18:31 pm
So theres no way of getting it to look as good? Is my shinemaps the cause of the problem?
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Flipside on September 18, 2006, 08:32:34 pm
If the bumpmaps are working, you may find that alleviates many of the problems, since you won't get as many unbroken flat polygons, the lighting will not look so 'bland' across the model ;) Infact, you may find it leaves some parts of the ship too dark and you'll have to turn up ambient a touch, but I guess we all just have to wait and see ;)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: taylor on September 18, 2006, 09:02:29 pm
So theres no way of getting it to look as good?
You can't compare broken behavior with correct behavior and consider the broken version "better" than the non-broken version.  D3D is doing the wrong thing, period.  It hurts both performance and overall texture quality.  If you want the full detail like D3D is using then create your texture maps without mipmaps.  But then you will have to deal with shimmering, extra sharp textures, which perform like total ****.

You are basically comparing a bright red Ford Pinto, with racing stripes, which is 10 feet in front of you with the quality of a Ferrari 1/2 mile away.  It's just not a valid test of the quality or performance of the two vehicles.  If someone bothers to fix the D3D code to actually work properly, and then you come to me with comparison test, it will actually mean something.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: CP5670 on September 18, 2006, 09:53:46 pm
The -ogl_spec command line might help with your specular mapping issue.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 18, 2006, 10:31:21 pm
Ok I'm a bit confused.... DX is using lod 0 mipmap (the default map) for everything. and Opengl uses the correct lod mipmaps except lod 0 right?


Btw here the base texture:
(http://img.photobucket.com/albums/v356/Shodan_AI/crab2-1.jpg)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: taylor on September 18, 2006, 11:04:06 pm
Ok I'm a bit confused.... DX is using lod 0 mipmap (the default map) for everything. and Opengl uses the correct lod mipmaps except lod 0 right?
D3D doesn't support mipmaps properly, so it's always using the base map (the highest resolution one).  OpenGL will make full use of mipmaps, which means that it will use what ever mipmap level best fits the geometry.  Multiple mipmap levels can be in use on a model at the same time (when you are viewing at an angle, or perspective, etc.).  Whether you are viewing LOD0 or LOD3 of the model makes no difference for what mipmap is used, the two things are totally unrelated.  If you have a full mipmap chain, with 1024x1024 as the base, and a given LOD0 model would fit a 256x256 texture in the current view, then OpenGL will use what ever mipmap level is closest to 256x256.  There would just be no reason to use a 1024x1024 texture in that case since it would have to be filtered down to fit anyway, and that distorts the image, producing very sharp edges, coloring issues, shimmering, etc.  If you were viewing LOD3 at full screen then it might use the 1024x1024 texture because that's what best fits it.

It's the same thing as in real life, the further something is from you the less detail it has.  D3D isn't using textures properly to simulate this, OpenGL does.  It not only provides a more realistic view of the model/scene, it also can greatly increase performance since it's only using the texture size that best fits the model rather than forcing it to fit.

If you look at your model in the lab then you'll see more detail in the texture, since the model is larger in that view and it will use a larger mipmap.  Now change the LOD for that model, you'll notice that although the model geometry changes, the texture is exactly the same.  It's the same in-game, if you are futher away from the model it should have less detail in the textures, but if you get close up then you can see every single bit of detail in the texture.

It's doing exactly what it should do.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Taristin on September 18, 2006, 11:05:21 pm
That map is psychadelic!
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 18, 2006, 11:12:59 pm
Ahhh ok now I get it, I thought lod and mip level were directly related.  Opengl's mipmapping has lost points with me then.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: taylor on September 18, 2006, 11:26:17 pm
Opengl's mipmapping has lost points with me then.
It's not OpenGL's mipmapping though, that's just how mipmapping works, period.  If the D3D code wasn't crap then it would do the exact same thing.  ALL games do this if they support mipmapping (which is 99.9% of them).  And until I fixed the OpenGL code to work with mipmaps properly, FSO was in that 0.1% of badly designed games.  It's a good thing, and if you didn't compare it to the broken D3D code then it would look fine.  The whole point of mipmapping is so that it isn't tied to any particular LOD.

If you wanted the texture tied to a particular lod then go back to making 3 different versions of each texture and UV mapping them to each LOD, not using mipmaps.  You'll have to deal with the loss of overall quality, the performance drop, the extra memory needed, and having to create multiple textures when you could just make one, but that's your choice. :)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 18, 2006, 11:38:09 pm
Oh geez... there was an even simplier solution than all this.... just move the model closer to the camera. Looks great now  :)
(http://img.photobucket.com/albums/v356/Shodan_AI/fixed-1.jpg)
I was more concerned about the intel room video moreso than in-game, there hopefully you'll never be that close anyways (or want to be  :lol: )
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Mars on September 19, 2006, 03:34:56 pm
Sounds like you need to change your LOD values
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 19, 2006, 04:33:02 pm
Oh, I thought only lod 0 was used in the tech room.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: taylor on September 19, 2006, 04:52:02 pm
Oh, I thought only lod 0 was used in the tech room.
It is.  Your fix is about the only solution to get what you were looking for.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 19, 2006, 10:33:29 pm
Can OpenGL be forced to use the highest quality mipmap? At least for the tech room where you want the ship to show off it's best and framerate isn't as important.  I just notice that my frigate is suffering from lower mipmap level, in fact a lot of the windows aren't even displaying.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: taylor on September 19, 2006, 11:34:24 pm
It could do that, but I'm not going to make such a change.

Technically it's showing up properly as it is and changing it to do otherwise should be considered a bug.  Using a higher level mipmap layer doesn't necessarily look better because it still has to be filtered down and that looks bad, or really bad depending on your video card and various settings.  There have been several threads and Mantis bugs about it doing just that and the quality suffers severely.

As I've already said, it's doing exactly what it's supposed to.  Get used to it. :)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 20, 2006, 12:22:07 am
Would rescaling my textures down for the tech window help? I should play around with PS's mipmap export setting.

Edit: nope still looks blurry

Double Edit: Well it looks good (sharp) in game so I guess I can quit whining about it  :D

btw Got a question about shaders.  Are they done entirely by code (using CSG or something similar) or is there map work involved?
Title: Re: Getting OpenGL to look as good as DirectX
Post by: taylor on September 20, 2006, 05:13:36 am
btw Got a question about shaders.  Are they done entirely by code (using CSG or something similar) or is there map work involved?
In code.  Map work could be invovled, depending on the shader, but that would probably get folded into the material system or something and not be specifically tied to shaders.  I have to say that I'm pretty curious about what people actually come up with.  I also have a bad feeling that I might have to redesign some of the code to handle what people start doing. ;)

Normal maps (bumpmapping) will be a fair bit of map and model work though.  It will either come out about the same time as the initial shader support, or just before it.  I have/had bump mapping mostly working previously, but have since gotten side tracked by bug fixing, so it's been a while since I actually coded on that.  I don't know how long it would take to complete, or how long it is going to take to finalize the shader code that I have and integrate it into the current code base.  It probably all depends on how much pressure I get to finish the new pilot code first thing after 3.6.9 gets kicked out of the door. :)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 20, 2006, 04:19:59 pm
Eeeck normal mapping, my mapping won't work with normal mapping then, I reuse uv's to a certain extend.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Flipside on September 20, 2006, 05:31:33 pm
Yeah, that can be a problem with normal mapping :( It shouldn't be too bad on the Oragnic models though ;)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 20, 2006, 07:11:30 pm
Hmm good point.. and good since I haven't started playing with my creature meshes either (excluding zoyberg and the winged spikey thing)
I think on the normal craft, bumpmapping should hopefully be enough to give it some detail.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Backslash on September 21, 2006, 01:30:00 am
Hey Scooby, do you know about the F3 lab?  Try it out there.  Don't worry too much about how the techroom looks if the lab shows it fine.  Also try messing with anisotropic filtering, 2X or 4X.  See if that works without much of a slowdown.

It probably all depends on how much pressure I get to finish the new pilot code first thing after 3.6.9 gets kicked out of the door. :)
The graphics people are probably going to kill me, but I for one would like the new pilot code before bumpmapping ;)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: taylor on September 21, 2006, 02:38:33 am
It probably all depends on how much pressure I get to finish the new pilot code first thing after 3.6.9 gets kicked out of the door. :)
The graphics people are probably going to kill me, but I for one would like the new pilot code before bumpmapping ;)
I kinda want the pilot file code done as well, and as quickly as possible.  The problem is just how large of an update it is, and it's a significant pain to work on given the number of changes.  The first pilot file code rewrite was about 30,000 lines worth of changes.  This new update could very well surpass 100,000 lines, even after I clean out all of the debug/testing/trash code (it currently is sitting well above 100,000 lines worth of changes, and isn't even complete yet).  Basically, I'm rather scared of it at this point.  :shaking:

Bumpmapping on the other hand would possibly be a couple thousand lines, so it's a lot less of a brain altering experience to work on that. :)

I plan to start up work on the pilot code again after 3.6.9 ships, but I doubt I'll work on it exclusively as I have too many smaller projects to work out too (graphics stuff, sound stuff, CVPs, etc.).  Luckily I can do about 139 things simultaneously. :D
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 21, 2006, 02:41:38 am
OMG  :eek:
How long has F3 been around? I could have used that ages ago... Whoever made this (http://forums.anandtech.com/i/expressions/beer.gif)

(http://img.photobucket.com/albums/v356/Shodan_AI/ratoth-1.jpg)
(http://img.photobucket.com/albums/v356/Shodan_AI/ratoth-2.jpg)

Couple of small requests for it.. One be able to stop the rotation and move manually so we can get a good snapshot of it. two, be able to zoom, especially for capships. But otherwise wow.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Shade on September 21, 2006, 02:48:46 am
You can rotate the model at will (including *not* rotating it) by holding down the left mouse button and moving it around.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: taylor on September 21, 2006, 02:53:53 am
You can also just click on the "Render Options" menu at the top and tick the "No Rotation" box to prevent it from rotating.  Then you can still move it with the mouse, but it will remain in that position when you let go of the mouse button.  That's the best way to get lab screenshots too, btw.
Title: Re: Getting OpenGL to look as good as DirectX
Post by: karajorma on September 21, 2006, 02:55:47 am
OMG  :eek:
How long has F3 been around? I could have used that ages ago... Whoever made this (http://forums.anandtech.com/i/expressions/beer.gif)

Surely you'd heard people mention The Lab before :) I believe it was mentioned earlier on this thread in fact :)
Title: Re: Getting OpenGL to look as good as DirectX
Post by: Scooby_Doo on September 21, 2006, 03:16:42 am
I guess I never put two and two together LOL