Game Development Community

dev|Pro Game Development Curriculum

Torque3D OpenGL updates... advanced lighting

by Luis Anton Rebollo · 07/29/2013 (10:05 am) · 15 comments

Advanced Lighting in OpenGL


GitHub: github.com/LuisAntonRebollo/Torque3D/tree/dev_opengl

A new update to the OpenGL code. It may be AL operating, the part of DX9 worked but you need to define "$pref::enablePostEffects = false;" in TorqueScript. I hope to continue to report project status at least 2 times a month in this forum: www.garagegames.com/community/forums/viewthread/133262/

imageshack.us/a/img29/5576/i462.png
imageshack.us/a/img59/128/mj3k.png

Milestone 1: Render Full template correctly (more or less)

This is the first objective of the roadmap. For now I have to fix OpenGL rendering to face up in BL. When this all finished we will have to write documentation because there will be changes to the definition ShaderData, PostEffect and CustomMaterial. When you reach the milestone will write a new blog.

OpenGL renders always upside down

I'm trying to render OpenGL upside down to maintain cohesion between the texture coordinate systems between DX9/OpenGL and make it easier to keep and port code for the shaders. For now it is very simple, at the end of the shader invert Z gl_Position, is necesary invert cull too. . HLSL and GLSL now assume that the top-left starting textures.

DX and most graphics file formats use a Y coordinate system starts at the top-left, but in OpenGL begins below-left. Textures from files loaded upside down in OpenGL. RTT textures are created are correct. It's a small problem that also makes it harder to maintain backward shaders and unified shader languages as CG. Unity also solves this problem rendering upside down in OpenGL.

You will see much code that seems HLSL shader in OpenGL, I apologize but for now it is easier and faster to copy / paste. I will clean in future.

This brings a few problems:
  • PostEffect has to differentiate when rendering to backbuffer, not rendered backwards.
  • Basic OpenGL rendering ligthing need a texturea and then copy the backbuffer, this prevents use AA (the moment is rendered upside down BL)

DX samplers can not directly mapped to registers

OpenGL does not support direct mapping of the samplers, so now the information is extracted after compiling the shader. This makes the definition of ShaderData, CustomMaterial and PostEffect is more important to have that link textures with samplers and rtParams. I have to work harder the code, explain later.

About the author

I'm working on a port of Torque3D to OpenGL and Linux/SteamOS


#1
07/29/2013 (12:23 pm)
@Luis,
Awesome progress! Sounds like you are really taking this thing to town.
#2
07/29/2013 (1:05 pm)
Good job Luis!

What happened to the donations? Did you give up on that? Wouldn't mind throwing 20$ your way if it is your intention to finish this!
#3
07/29/2013 (1:31 pm)
Cool stuff.

I guess a lot of those that pledged for the failed Linux support indigogo wouldn't mind donating some money... but I think you should definitly come to an agreement with Dushan in case you are sharing code with him as he would deserve a cut too.
#4
07/29/2013 (2:19 pm)
I am already having nightmares about all textures and so on being wrong in openGL and would need to be inverted by hand. Is this the cases when switching to openGL?
#5
07/29/2013 (2:39 pm)
@Duion,
I think he talking about the coordinate system. I thought that could be changed in OpenGL though. I was under the impression the coordinate system can be anything you want with the right transform. This should not have any effect on source textures.
#6
07/29/2013 (3:04 pm)
There is a checkbox when you generate normal maps if you want to invert the y-axis, which needs to be done for directX, so I suppose for openGL they have to be not-inverted.
#7
07/29/2013 (4:07 pm)
I suppose you could just program in the invert / no-invert into the rendering system itself to avoid that issue and invert the axis by code if necessary.
#8
07/30/2013 (9:12 am)
OpenGL just has to be setup to work with the same transforms as DirectX uses. It doesn't matter what you use as OpenGL does not care. There are standard "conventions" but its all math so you can use whatever you want. I ported a DX engine to opengl es 2.0 about 6 months or more ago and I just used the DX math with OpenGL.
#9
07/30/2013 (9:21 am)
Magnificent work Luis!
This is all good news!
Thank you!
#10
07/30/2013 (7:30 pm)
failed to resist myself from trying it out .
last time i tried with rony's push.
but it always crashed during loading.

with your new update game is starting up ok.
but my screen remains black.
+sometimes it crashes.

here is a screeshot:
http://www.mediafire.com/?iho7ih75qqbortd

log file:
http://www.mediafire.com/?iho7ih75qqbortd
filled with shader related compiling error.

is that the problem?
or problem with my built-in intel video card's driver?
any idea?


d3d9 working ok.


encourageous work.keep it up.
Alas,if i could have joined with u and Dushan
:(
but no knowledge on rendering Code.although have started with:
(OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3)
http://www.amazon.com/OpenGL-Programming-Guide-Official-Learning/dp/0321773039
#11
07/31/2013 (1:02 pm)
Thank you all

@Lukas
You can find the link for donations here: www.garagegames.com/community/forums/viewthread/133262/, but maybe it's better to wait for the completion of Milestone 1.

@Ahsan
First of all, thanks for taking the time to test the code. When testing on the computer of a friend, I think I found the bug you say (affect ATI & Intel videocards). Could you post the link to the log, it seems you've put 2 times the image. This error will be fixed soon.
#12
07/31/2013 (3:08 pm)
sorry.copy paste error.

here it is:
http://www.mediafire.com/download/6cplxoljacocomy/console.log
#13
08/02/2013 (1:37 am)
any update on that issue?
#14
08/05/2013 (11:20 am)
New update, I think the problem when compile on ATI & Intel GPUs it's solved.

You can follow updates on the forum: www.garagegames.com/community/forums/viewthread/133262/
#15
10/07/2013 (9:48 pm)
"OpenGL renders always upside down"
is that fixed now?