Cockpit Shadows

Want to edit the game, build your own craft and missions? Here you'll find help, tools, guides and people to discuss with.

Cockpit Shadows

User avatar
blue_max
XWAU Member
Posts: 2295
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Thu Jun 04, 2020 1:07 am

This is something I've been working on for a while now, it's finally coming to fruition:

https://youtu.be/tOX1yDf7uQU

https://youtu.be/DsgyHwoAPV8

cockpit-shadows-1.jpg
cockpit-shadows-3.jpg

The blackness of the shadows can be configured, so don't worry about that ;)

Yes, the shadows can be disabled for people who don't like them.

The way this is going to work is by side-loading simplified geometry and using that to compute regular shadow mapping. It will only work on the cockpit for now.

Coming soon!
You do not have the required permissions to view the files attached to this post.

Bman
Lieutenant Commander
Posts: 1167
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Thu Jun 04, 2020 4:54 am

Nice. Great job.
W-I-P: TFTC, MC Viscount Cr., ISD-II Avenger, NL-1 Platform, Ton-Falk Esc. Cr., & Misc.

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Thu Jun 04, 2020 6:21 am

Oh, sweet!

User avatar
Mark_Farlander
Rebel Alliance
Posts: 580
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Thu Jun 04, 2020 6:54 am

Amazing!
I don't judge tactics. The Battle is the best and only Judge.

User avatar
Trevor
Lieutenant JG
Posts: 541
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Thu Jun 04, 2020 12:16 pm

YES!!!
Finally shadows :P

suggestion, at the end of the vid, show the light source.
Its fine seeing the shadows and all, but if we cant see the source they could be mirrored or totally random.

Cant wait to see more (Hoping for full ship occlusion)

Somewhat related, I have been playing with SSDO settings again (Oh and the new multi-core options work great and I have 0 problems (someone mentioned sound problems)) and I think the Hangar needs some special lighting.
At present there is 1 infinit light source directly above.
this causes some weird shading (and if shadows are present could totally occlude the hangar) so I think local lights are needed.

Trev

User avatar
ual002
XWAU Member
Posts: 983
Joined: Wed Sep 24, 2008 2:23 am

Post by ual002 » Thu Jun 04, 2020 1:51 pm

Blue_max. You're killing me with your visual contributions my dude. This is fantastic.
Image Image Image Image Image

User avatar
Ace Antilles
Admiral (Moderator)
Posts: 7829
Joined: Sat Jan 22, 2000 12:01 am
Contact:

Post by Ace Antilles » Thu Jun 04, 2020 4:01 pm

Trevor wrote:
Thu Jun 04, 2020 12:16 pm
Somewhat related, I have been playing with SSDO settings again (Oh and the new multi-core options work great and I have 0 problems (someone mentioned sound problems)) and I think the Hangar needs some special lighting.
Trev
It's very random. You can have no issues with the music and then you can have it hit you mid game.
A fix is being tried but it's elusive. Also we can't recreate the bug happening fast to know if it's fixed or not.
Chief XWAU Team annoying nitpicker.
Ace Antilles - The X-Wing Outpost
Image

User avatar
AngeI
Lieutenant JG
Posts: 524
Joined: Sun Jan 24, 2016 5:27 pm

Post by AngeI » Thu Jun 04, 2020 8:22 pm

As usual blue max, amazing work, can't wait to try it out :)

User avatar
blue_max
XWAU Member
Posts: 2295
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Fri Jun 05, 2020 4:45 pm

Trevor wrote:
Thu Jun 04, 2020 12:16 pm
suggestion, at the end of the vid, show the light source.
Its fine seeing the shadows and all, but if we cant see the source they could be mirrored or totally random.
Check this out:

https://youtu.be/onCBwKrhiEA
Cant wait to see more (Hoping for full ship occlusion)
What do you mean by this?
Somewhat related, I have been playing with SSDO settings again and I think the Hangar needs some special lighting.
Can you post some pictures of the problem? I know the shadows in the hangar have the wrong color; but otherwise the hangar looks fine to me.

User avatar
Trevor
Lieutenant JG
Posts: 541
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Fri Jun 05, 2020 8:04 pm

Check this out:
Gorgeous:)
What do you mean by this?
(lol) I assume you are joking, but just in case you are not, I mean shadows cast from the ships onto other ships (and undersides being in shadow)
Can you post some pictures of the problem? I know the shadows in the hangar have the wrong color; but otherwise the hangar looks fine to me.
Yes, shadows generated by xwa are the wrong colour but I mean more Global Illumination.
So, In Space (as most of the game is in space) I set Ambient to 0, BUT the hangar has lots of DIR and so should be brighter.
You already explained that your implementation of DIR would only extend 1m and no more due to limitations, so, the only way to get "Realistic" results is to use Ambient OR add Upward pointing lights.
With Headlights now being a thing it got me thinking about having real lights in the hangar anywhere there is a drawn light.
(actually I just relised how many that is and its impractical, but Id still like to add an uplighter to approximate light reflected from the floor (and there are some lights on the floor anyway)

(I was to attach some images, but Ill post this first incase my power goes out.)

ok, so this image was a fun render (took 10 mins to render with all the lights and DIR)
DIR render.png
Trev
You do not have the required permissions to view the files attached to this post.

korekwerner
Cadet 1st Class
Posts: 154
Joined: Wed Mar 20, 2019 7:04 pm

Post by korekwerner » Sat Jun 06, 2020 9:45 am

Great work Blue_Max.
Thank you

User avatar
rogue518
XWAU Member
Posts: 2856
Joined: Wed Jul 12, 2000 11:01 pm
Contact:

Post by rogue518 » Sun Jun 07, 2020 12:00 am

That's fantastic!! blue_max... ;)

Sincerely, Rogue518
'Stay in Attack formation!' Darth Vader aka: Anakin Skywalker During the 'Battle Of Yavin'

User avatar
blue_max
XWAU Member
Posts: 2295
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Sun Jun 07, 2020 6:49 am

Thanks for your comments guys. I think I can release this soon as it is now working in VR as well. As usual, there might be a few glitches that I'll continue to fix in future releases.

@Trevor: No, I wasn't joking. "Occlusion" can mean a number of things, so better to ask ;) At the moment, I can only add shadows to the cockpit because the cockpit is centered on the camera, so I know where it is at all times. Adding it to other craft would require knowing where they are, their orientation, etc, and I still don't know how to extract that information from XWA.

I'll see if something can be done in the hangar. At the very least I think I can fix the color of the shadows as I find that disturbing too.

User avatar
Camerad
Cadet 3rd Class
Posts: 28
Joined: Wed Dec 25, 2013 12:07 pm

Post by Camerad » Sun Jun 07, 2020 8:47 am

Pretty damn cool.
Windows 10 Pro 64-bit, i7-10700KF, 64GB 3200MHz DDR4, Geforce RTX 2080 Super 8GB

User avatar
Trevor
Lieutenant JG
Posts: 541
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Sun Jun 07, 2020 3:40 pm

Sounds good Blue

Trev

P.S. I had fun rendering these too. Full lighting (every light emits light) and DIR.
You can see that while there are subtle shadows etc, for a scene like this with plenty of lights, ambient does the job its supposed to very well.
You do not have the required permissions to view the files attached to this post.

Mr_Blastman
Cadet 4th Class
Posts: 21
Joined: Sat Aug 22, 2009 5:01 am

Post by Mr_Blastman » Fri Jun 19, 2020 5:08 pm

Wow!

Has this been released yet?

User avatar
blue_max
XWAU Member
Posts: 2295
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Fri Jun 19, 2020 7:33 pm

Not yet, still working on it.

Mr_Blastman
Cadet 4th Class
Posts: 21
Joined: Sat Aug 22, 2009 5:01 am

Post by Mr_Blastman » Fri Jun 19, 2020 7:41 pm

Sweet! Thank you so much for all your awesome contributions to this project. Amazing how far it has come.

User avatar
Q
Ensign
Posts: 456
Joined: Sat Dec 28, 2002 12:01 am
Contact:

Post by Q » Fri Jun 19, 2020 11:48 pm

This is truly amazing work Blue_Max! One question, what about missions that have more than one light source?
"I like work; it fascinates me. I can sit and look at it for hours."

User avatar
blue_max
XWAU Member
Posts: 2295
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Sat Jun 20, 2020 1:18 am

There's support for multiple lights, but I'm only processing one at the moment. I can add a switch to enable multiple/single Suns.

User avatar
blue_max
XWAU Member
Posts: 2295
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Fri Jul 24, 2020 6:35 am

Recent releases of the VR mod/effects ddraw already have support for cockpit shadows. However, additional work is needed to enable this feature.

First you'll need a new directory in the XWA install directory called "ShadowMapping". This directory should contain OBJ files, one per cockpit. The name of the files should match the name of the cockpit, like "XWingCockpit.obj", "YWingCockpit.obj", etc. You can create these files yourself by exporting OBJ files from the cockpit OPTs. Strip all the textures and materials and remove all the small details like buttons. See the examples provided here:

https://www.dropbox.com/s/9seoblhr8widf ... g.zip?dl=0

(Before publishing this ZIP file I had already asked the various cockpit authors for permission to publish simplified versions of their cockpits)

For some reason I still don't understand, sometimes the shadow map OBJ will be flipped/mirrored on one axis. To fix this you can add the following settings in the material definition file for the cockpit, in the [Default] section:

Code: Select all

shadow_map_mult_x = 1
shadow_map_mult_y = 1
shadow_map_mult_z = 1
If you want to flip one axis, use -1 instead of 1. For instance, this is what the X-Wing cockpit material file looks like:

Code: Select all

[Default]
Metallic   = 0.4
Intensity  = 0.8
Glossiness = 0.08
shadow_map_mult_z = -1
Link to the full file:

https://www.dropbox.com/s/o6dvui1gbcrgj ... t.mat?dl=0

Finally, to enable the feature itself just add the following lines to SSAO.cfg:

Code: Select all

; Shadow mapping feature switch
shadow_mapping_enable = 1

; Adds a bias to the shadow map to prevent self-shadowing
shadow_mapping_bias_sw = -0.03

; Screen-space search radius used to soften the edges of the shadow
shadow_mapping_pcss_radius  = 0.00125

; Number of samples around the current pixel used to soften shadows
shadow_mapping_pcss_samples = 3

; Blackness of the shadows. 0 is full black, 1 disables shadows.
shadow_mapping_black_level = 0.2[
I'll be working to automate all of this and provide shadow mapping OBJs in future releases. But for now, if you can't wait, this is how you enable this feature.

Ronin65
Cadet 3rd Class
Posts: 48
Joined: Thu Jul 02, 2020 1:00 pm

Post by Ronin65 » Fri Jul 24, 2020 12:21 pm

Hi Blue Max,

You say "For some reason I still don't understand, sometimes the shadow map OBJ will be flipped/mirrored on one axis."

This wouldn't happen to be on the AssaultGunboatCockpit and the AwingCockpit would it?

I only ask as there are a around 20 faces on the Gunboat that are inverted and most of the body of Awing cockpit that is inverted

Also do you have to have the dynamic cockpits enabled to use these or does it work without them

Thanks

User avatar
blue_max
XWAU Member
Posts: 2295
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Fri Jul 24, 2020 4:29 pm

Ronin65 wrote:
Fri Jul 24, 2020 12:21 pm
You say "For some reason I still don't understand, sometimes the shadow map OBJ will be flipped/mirrored on one axis."

This wouldn't happen to be on the AssaultGunboatCockpit and the AwingCockpit would it?
Hello Ronin65.

No, this happens on the X-Wing. The workflow I usually follow to create a shadow map is like this:

1. Export OPT to OBJ.
2. Duplicate the OBJ to have a backup.
3. Remove all textures and materials.
4. Remove unnecessary faces or small details.
5. Fill in any gaps in the cockpit.
6. Export to regular OBJ file without any normal or texture data.

At this point, the shadow map OBJ and the original OBJ should overlap perfectly. But in the case of the X-Wing cockpit, I also have to do this:

7. Mirror the Z-axis.

So the shadow map and the OBJ don't overlap anymore. This doesn't make any sense, so instead of asking people to do this weird step, I added the setting in the materials file.
I only ask as there are a around 20 faces on the Gunboat that are inverted and most of the body of Awing cockpit that is inverted
The clockwise/counter-clockwise ordering of the vertices and the normals of the polygons is ignored for shadow mapping, so this doesn't matter, but thanks for the heads-up.
Also do you have to have the dynamic cockpits enabled to use these or does it work without them
No, this is not needed, but you need to enable one of the SSAO shaders (deferred, SSAO or SSDO).

Ronin65
Cadet 3rd Class
Posts: 48
Joined: Thu Jul 02, 2020 1:00 pm

Post by Ronin65 » Fri Jul 24, 2020 6:19 pm

Ok thanks for the clarification, about not having to use dynamic cockpits

It just seemed coincidental that the faces where inverted and you where having problems with the shadows, this is why I asked :)

Strange, is it just the xwing cockpit?

In future will you be providing more *.Mat files for other craft along with the Shadow OBJ files, you've included some OBJ files but no *.mat files it just seems a little counter productive if you don't included them for all craft, just thought there should be standard mat files for each opt :) even with the global mat file, some craft still look like and to coin a phrase used by Forceflow, they look like polystyrene. Sorry I don't mean to be rude, but they do, you must have noticed it your self :)

User avatar
Trevor
Lieutenant JG
Posts: 541
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Fri Jul 24, 2020 10:32 pm

Ronin, this is beta, not a finished product.
You cant expect Blue to spend time making obj's and mtls for every craft when the spec could change tomorrow - i.e. objs shouldn't even be needed.

anyway, I got to test shadows and … *drool* they look great, but I was also going to mention the "wandering shadows" bug too.

May I ask technically how you are achieving the raycast shadows?

Trev

Post Reply