Game Development Community

Torque3D OpenGL Status

by Luis Anton Rebollo · in Torque 3D Professional · 02/24/2013 (1:33 pm) · 175 replies

I am working with BeamNG in port Torque3D to OpenGL. When finished there will be a merge with GG repository.

I will be updating this thread at least once a week.
Repository: Github.com/BeamNG/Torque3D/tree/dev_linux_opengl

Status:

  • Is a research & learn branch, lots of unfinised and ugly code. It will check and clean all code before repo merge with GG
  • Basic Lighting & Advanced Lighting render correctly (more or less) all effects.
  • There may be errors or differences with other implementations of OpenGL. They will be corrected later.
  • No Oculus rift port to glsl.

How to compile:

* Use this manual.
* On Windows you need to check TORQUE_OPENGL option.

Reporting bugs:

If possible, Github is a great place to post issues to a forum.

Torque 3D Version:

This branch is based on Torque3D 3.5 development.

OpenGL performance:

I check the code in a new Gerforce 750ti and T3D works just as fast in Opengl/Directx9.
The problems of speed it was a few months ago were due to drivers. Sounds like a good OpenGL performance is linked to new cards/drivers. NVidia of Kepler architectures (Geforce 600-700) not sure on AMD.

I appreciate any donation to help the project. https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif.

img24.imageshack.us/img24/9537/ssx8.pngimg547.imageshack.us/img547/3684/opengl0.pngimg21.imageshack.us/img21/214/opengl1.pngimg27.imageshack.us/img27/1646/opengl2t.png
#101
02/13/2014 (1:23 am)
@Timmy:
This may very well be an extreme corner-case, but on large DXT(1,3 or 5 at 512X8192 resolution) texture sheet, the

else if((format == GFXFormatDXT1 || format == GFXFormatDXT3 || format == GFXFormatDXT5) && numMipLevels >0)

chunk caused the objects sharing it to turn black.
attempted the resolution listed: http://www.opengl.org/discussion_boards/showthread.php/166930-DDS-mipmapping-doesn-t-work

via altering that chunk to:

retTex->mMipLevels = numMipLevels;
glTexParameteri(binding, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
glTexParameteri(binding, GL_TEXTURE_MAX_LEVEL, numMipLevels);

showed no difference, but I'm not entirely certain that the present workaround of tossing in:

glTexParameteri(binding, GL_TEXTURE_MAX_LEVEL, 0);

doesn't simply short-circuit the entire thing.
#102
02/13/2014 (6:01 am)
@Azaezel:

Yep i believe glTexParameteri(binding, GL_TEXTURE_MAX_LEVEL, 0) would completely bypass the mip maps. Technically we should be settings the max level as it can cause problems on some drivers.

Are you on amd or nvidia?

I'll try and reproduce the problem, just so i understand to reproduce the problem i need a 512X8192 DXTn compressed texture with mip maps and have a few static mesh sharing the same material?

Just one last thing, could you change the part of the code

// Complete the texture
glTexParameteri(binding, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

to

// Complete the texture
if(numMipLevels > 0)
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
else
  glTexParameteri(binding, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

Just see if that fixes the black texture, i'm doubting it will though but it's quick and easy to try. Going to be a lot easier if i can reproduce the problem here.

Honestly that whole function innerCreateTexture function could do with a complete overhaul.
#103
02/13/2014 (11:27 am)
Nvidia, and the code snippet you provided does appear to have corrected that, with glTexParameteri(binding, GL_TEXTURE_MAX_LEVEL, numMipLevels); making no difference either way that I can tell offhand.

Since it's just some programmer art at present if you wish to crosscheck it: github.com/Azaezel/Torque3D/tree/dev_linux_opengl_Acid_Test

A proper test would of course entail manually editing the MIPs to different colors for verification, but I've completely forgotten how to do so with gimp (not an application I typically use much.)

Much obliged.
#104
02/13/2014 (2:50 pm)
Thanks for the feedback Azaezel, i will fix it up. I have closed the original pull request i sent to Luis and i will work on fixing up that whole innerCreateTexture function.

One scenario that setting the GL_TEXTURE_MAX_LEVEL can help with is if a texture has an incomplete set of mip maps and is missing say the last 3 levels, this can cause troubles with some drivers if you don't set that max level. It's always good practice to set the GL_TEXTURE_MAX_LEVEL to the number of mip maps.
#105
02/14/2014 (3:31 am)
New update on Github: github.com/LuisAntonRebollo/Torque3D/commits/dev_linux_opengl
  • OpenGL Fix: Render upside down when PostFX are disabled.
  • OpenGL Fix: GuiColorPickerCtrl not select color correctly
  • OpenGL Fix: PrimBuild render incorrect when no texture are asigned.
#106
02/15/2014 (10:53 pm)
@Azaezel:

The code i posted above and previously for the amd fix is totally wrong, i have wrongly assumed ( yes we all know the saying about this lol ) about what the fields forceMips and numMipLevels actually mean. I will correct this and send a pull request to Luis once i can confirm it A)Actually corrects the AMD problem B)Doesn't cause any side affects to NVidia etc.

Once i get this sorted out i'm going to look into why fullscreen mode doesn't work under windows, i'm not sure the status of this on the linux/osx side?
#107
02/16/2014 (5:35 am)
I have now sent a much revised pull request to luis for this amd loading problem. I have changed a bit of loading code in the texture manager so even if you don't have a amd gpu it would be much appreciated if you could test it out. Pull request is here github.com/LuisAntonRebollo/Torque3D/pull/37
#108
02/16/2014 (4:01 pm)
Seems to work, judging by the results of the revised texture sheets I just slapped up for verification. (Thanks Andrew.)
#109
02/16/2014 (4:28 pm)
No problem. (I had nothing to do with it haha)
#110
02/16/2014 (5:31 pm)
heh. No, the artist.
#111
02/17/2014 (6:46 pm)
New update on Github:github.com/LuisAntonRebollo/Torque3D/tree/dev_linux_opengl
  • OpenGL Fix: Precipitation render as solid color quads. Thx to Tim Newell.
  • OpenGL: Add support for setupGenericShaders GSTexture (FFP emulation). Thx to Tim Newell.
  • OpenGL Fix: Typo in common/gl/basicCloudsV.glsl. gvTexCoord0 -> vTexCoord0. Thx to Tim Newell.
  • OpenGL Windows Fix: Window color buffer are only 16bit.
  • OpenGL: Generalize code for GFXGLWindowTarget on all platforms.
  • Added ARB_debug_output and AMD_debug_output support. Thx to Timmy
#112
02/25/2014 (12:13 am)
I tried the Conifer Forest Pack Demo with the OpenGL Build.

HDR_RGB10_MAX is disable in shaders/gl/torque.glsl at line 156. This cause a crash or a endless loading spamming the error message that HDR_RGB10_MAX is undefined. After uncomment the variable it load the map :)

So I guess it should be enabled.

#113
02/25/2014 (10:44 am)
@Thomas, thx... added to my ToDo list.

I started working fulltime with BeamNG to make T3D multiplatform.

More info in blog: Torque3D is going multiplatform, thanks to BeamNG

Development moved to github.com/BeamNG/Torque3D/tree/dev_linux_opengl
#114
02/26/2014 (3:51 am)
thank you very much for your efforts.
#115
03/05/2014 (6:45 am)
just noticed someone else already reported this.
#116
03/05/2014 (4:13 pm)
quickie notes/queries: (Mar 04, 2014 baseline)

gfxD3D9PCDeviceProfiler.cpp - #include <d3d.h> deprecated for newer PC directx versions. Thinking bracket it in a compiler flag, or look for a directx version tag?

gfxGLDeviceProfiler.cpp - GFXDevice::GFXDeviceEventType::deInit 2008 didn't like that one. older compilers can get away with GFXDevice::deInit , or I could cook up and toss over one that encapsulates that enum in a subclass. Preference?
#117
03/07/2014 (8:41 am)
If anyone is having a hard time looking through the OpenGL traces with apitrace, simply change the implementation of the following methods:

void GFXGLDevice::enterDebugEvent(ColorI color, const char *name)
{
	if (gglHasExtension(EXT_debug_marker))
	{
		glPushGroupMarkerEXT(dStrlen(name), name);
	}
}

void GFXGLDevice::leaveDebugEvent()
{
	if (gglHasExtension(EXT_debug_marker))
	{
		glPopGroupMarkerEXT();
	}
}

void GFXGLDevice::setDebugMarker(ColorI color, const char *name)
{
	if (gglHasExtension(EXT_debug_marker))
	{
		glInsertEventMarkerEXT(dStrlen(name), name);
	}
}

This will give you nice nested draw calls so you can see when each render bin is being rendered, as well as when each mesh is being rendered (assuming you are using antons latest code).
#118
03/07/2014 (3:02 pm)
New update on Github: github.com/BeamNG/Torque3D/tree/dev_linux_opengl
  • Fixed imposter generator code.
  • Remove GFXGLTextureTargetAUXBufferImpl
  • Change GL_EXT_framebuffer_object to GL_ARB_framebuffer_object
  • Clean GFXProfile.
  • Support GL_ARB_gpu_shader5 on GLSL and fix fxaaP.glsl error:...
  • Change context to 3.2 and remove more FFP
  • Fix: HDR_RGB10_MAX is not declared on GLSL.
  • Fix: Missions take 10 minutes to load on AMD cards. Thx to Timmy
  • Add OpenGL cache for avoid glGet* calls.
  • explicit asignment for auto &ssd = mDesc.samplers[i];
  • Remove glMapBuffer, and use FrameAllocator for lock/unlock...
  • Add HW instancing support.
  • Add a simple gpu profiler.
  • Separate sampler object from texture object.
  • Fix: GFXDevice::disableShaders() set incorrect GFXDevice::setupGenericShaders.
  • Add support for sampler1D
  • Fix: Declare a glsl function with name "mul" cause problems with some drivers.
  • Fix EOL in some files.

A good week of work in BeamNG :D


@Azaezel:
Thx for your review :D
About <d3d.h>... I only move existing code from Engine/source/gfx/D3D9/pc/gfxPCD3D9Device.cpp but yes it's deprecated.

About GFXDevice::GFXDeviceEventType::deInit, yes this will cause problems on some compilers. Added to my ToDo.

@James:
As always, another great contribution. Added to my ToDo.
#119
03/07/2014 (3:25 pm)
Nice work Luis, things are definitely moving along now :-)
#120
03/09/2014 (8:44 am)
Is anyone here familiar with how the Advanced Lighting works? Our current OpenGL code is based on an earlier port with a few ideas from Anton's port (e.g. the vertex attributes in the shaders). I have the lighting pass as well as the spotlight shadows working, but the sunlight vector lighting is proving to be a challenge to fix. Essentially I am getting shadows but they are moving based on the camera position. In most cases they do not appear at all. Does anyone know of a good way to debug whats going on? I suspect its just a problem with the vector light shader as the spot lights still work, but I'm still at a loss as to which part of the shadowmap check is going wrong...

Unlike the port on github, we do not flip Y coordinates in the vertex shader, which I suspect is accounting for some of the oddness.

Also has anyone noticed any problems with the shaders rendering green / orange artefacts on OSX (typically when rendering the glow & lighting specular)?