Page 1 of 2

Cockpit Shadows

Posted: Thu Jun 04, 2020 1:07 am
by blue_max
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!

Re: Cockpit Shadows

Posted: Thu Jun 04, 2020 4:54 am
by Bman
Nice. Great job.

Re: Cockpit Shadows

Posted: Thu Jun 04, 2020 6:21 am
by keiranhalcyon7
Oh, sweet!

Re: Cockpit Shadows

Posted: Thu Jun 04, 2020 6:54 am
by Mark_Farlander
Amazing!

Re: Cockpit Shadows

Posted: Thu Jun 04, 2020 12:16 pm
by Trevor
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

Re: Cockpit Shadows

Posted: Thu Jun 04, 2020 1:51 pm
by ual002
Blue_max. You're killing me with your visual contributions my dude. This is fantastic.

Re: Cockpit Shadows

Posted: Thu Jun 04, 2020 4:01 pm
by Ace Antilles
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.

Re: Cockpit Shadows

Posted: Thu Jun 04, 2020 8:22 pm
by AngeI
As usual blue max, amazing work, can't wait to try it out :)

Re: Cockpit Shadows

Posted: Fri Jun 05, 2020 4:45 pm
by blue_max
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.

Re: Cockpit Shadows

Posted: Fri Jun 05, 2020 8:04 pm
by Trevor
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

Re: Cockpit Shadows

Posted: Sat Jun 06, 2020 9:45 am
by korekwerner
Great work Blue_Max.
Thank you

Re: Cockpit Shadows

Posted: Sun Jun 07, 2020 12:00 am
by rogue518
That's fantastic!! blue_max... ;)

Sincerely, Rogue518

Re: Cockpit Shadows

Posted: Sun Jun 07, 2020 6:49 am
by blue_max
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.

Re: Cockpit Shadows

Posted: Sun Jun 07, 2020 8:47 am
by Camerad
Pretty damn cool.

Re: Cockpit Shadows

Posted: Sun Jun 07, 2020 3:40 pm
by Trevor
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.

Re: Cockpit Shadows

Posted: Fri Jun 19, 2020 5:08 pm
by Mr_Blastman
Wow!

Has this been released yet?

Re: Cockpit Shadows

Posted: Fri Jun 19, 2020 7:33 pm
by blue_max
Not yet, still working on it.

Re: Cockpit Shadows

Posted: Fri Jun 19, 2020 7:41 pm
by Mr_Blastman
Sweet! Thank you so much for all your awesome contributions to this project. Amazing how far it has come.

Re: Cockpit Shadows

Posted: Fri Jun 19, 2020 11:48 pm
by Q
This is truly amazing work Blue_Max! One question, what about missions that have more than one light source?

Re: Cockpit Shadows

Posted: Sat Jun 20, 2020 1:18 am
by blue_max
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.

Re: Cockpit Shadows

Posted: Fri Jul 24, 2020 6:35 am
by blue_max
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.

Re: Cockpit Shadows

Posted: Fri Jul 24, 2020 12:21 pm
by Ronin65
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

Re: Cockpit Shadows

Posted: Fri Jul 24, 2020 4:29 pm
by blue_max
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).

Re: Cockpit Shadows

Posted: Fri Jul 24, 2020 6:19 pm
by Ronin65
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 :)

Re: Cockpit Shadows

Posted: Fri Jul 24, 2020 10:32 pm
by Trevor
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