Shadows / Render Stencil and Saving/Loading levels

Posted By: Dooley

Shadows / Render Stencil and Saving/Loading levels - 06/26/16 18:56

I have experienced different problems with my shadows after saving/loading levels. I could not find anything in the manual about this particular aspect of using shadows.

Has anyone encountered this? Is there any set of guidelines to follow with regard to shadows in a game_load, game_save situation?
Posted By: Anonymous

Re: Shadows / Render Stencil and Saving/Loading levels - 06/26/16 20:14

What are the shadow types shadow_stencil =?? and the 'problems' like.

I don't have a off the top answer.. sorry

With PSSM shadow_stencil =8; there maybe some issue -> just looking at the manual.
http://www.conitec.net/beta/shadows_c.htm
Quote:
--PSSM shadows must be deactivated before changing the video resolution or video mode, or when loading a level or changing the level size. Activate them again one frame afterwards.

Quote:
--On the other hand, PSSM shadows require careful adjustment of the shadow bias (pssm_fbias, see below) and the camera clip_far value to the level size and type. Wrong values can cause artefacts such as "surface acne" or displaced shadows.

--The light source is the sun, as set up in the level map or in the script (sun_angle).

--Only objects that cast PSSM shadows can receive PSSM shadows. For this reason, the SHADOW flag should be set for level geometry and terrain.

--PSSM shadows must be deactivated before changing the video resolution or video mode, or when loading a level or changing the level size. Activate them again one frame afterwards.

--They should be deactivated when the player enters an indoor area (otherwise, everything indoor would be in shadow).

--Before activating PSSM shadows, set shadow_stencil at 8, and set camera.clip_near as high and camera.clip_far as low as possible. Make sure that level_ent.max_x and level_ent.min_x reflects the final level size.



Also Try doing game save in flag list one by one. Not SV_ALL. Just start with one flag and add the next like
Code:
game_save("info",0,SV_INFO+SV_STRINGS+SV_BMAPS);


The will help find a problem type to look deeper into
Posted By: rayp

Re: Shadows / Render Stencil and Saving/Loading levels - 06/27/16 14:09

Btw:
I cant recommend to use those functions (game_save/load). I know it sucks but its better to write your own save/load functions.

Greets
Posted By: Dooley

Re: Shadows / Render Stencil and Saving/Loading levels - 06/27/16 21:25

Thanks,
I actually did write my own save/load function which saves generated levels to a text file. Then it rebuilds the levels from the data in the file. However, there is one main level which I'm still using game_save/load, which seems too complex to do like that ... Maybe that's the answer.
Posted By: Dooley

Re: Shadows / Render Stencil and Saving/Loading levels - 06/27/16 23:57

I am using A7 - stencil_shadows set to 2 - Z-Fail Stencil Shadows

They need to be set before level_load.

This is what I call before loading, or reloading my levels:

Quote:

shadow_stencil = 2; // activate z-fail accelerated stencil shadows
stencil_blur(1); // activate blurred shadows
mat_shadow.alpha = shadow_alpha;
shadow_range = 10;


Right now, to avoid shadow artifacts coming back to the spaceship level, which does not use stancil shadows, I call:

Quote:

ssView.material = NULL;
camera.stage = NULL;
shadow_stencil = -1; // deactivate z-fail accelerated stencil shadows
stencil_blur(0); // deactivate blurred shadows
mat_shadow.alpha = 0;
shadow_range = 0;


Going back to the ship uses a game_load function, but landing on the planet uses my own reloading function.

Right now, if I land on a planet, then return to the ship, everything is fine. However, if I return to the planet again, there appears to be two versions of the stencil_shadows. One is blurred and one is not, and they are at slightly different angles, as if there are two light sources casting shadows. Also, there are self shadows cast of objects that are not even assigned the "shadow" flag.

To make things more interesting, if I leave the game, and then come back and reload the planet, the shadows work fine.
Posted By: Reconnoiter

Re: Shadows / Render Stencil and Saving/Loading levels - 06/28/16 09:59

Originally Posted By: Dooley

To make things more interesting, if I leave the game, and then come back and reload the planet, the shadows work fine.
, perhaps it is some bug with level load and game_load and stencil shadows? (might be something specific to A7)

Also alternative would be skipping stencil shadows and take a shadow shader from this forum. E.g. from Slin or such.
Posted By: rayp

Re: Shadows / Render Stencil and Saving/Loading levels - 06/28/16 10:46

Quote:
However, there is one main level which I'm still using game_save/load

Just wanted to mention again: Dont use those functions, they just wont work correct. Many users ( including me ) faced that problem ( in some kind of variation ).:D
I just tryed again to use those functions in my ZombieFPS project, bug-hell broke loose grin

Anyway...
Try with this game_save - flag
Code:
-SV_VIEWS

Does it help? Often solves shader/shadow props.

U checked out Malice's post yes?
Cause he mentioned to use some flags and gave usefull tips.

Btw: Std. 3dgs stencil shadows are slow like hell.
Performance tip: Use
Code:
shadow_lod

and let the LOD models of your entity cast the shadows.
Posted By: Dooley

Re: Shadows / Render Stencil and Saving/Loading levels - 06/28/16 18:03

Thanks for all the help guys.

I'm going to write the save/load function myself again. There are some other issues popping up which I need to fix, and they are all pointing my in the direction of writing my own save/load function.

I am okay with the A7 shadows for now (assuming I can fix this problem), but I will look at other options in my next phase of development. They do use LOD-1 by default (as opposed to LOD-0), but you can set them to different LOD levels if you need to.

@Malice - It sounds like you are referring to the A8 engine/manual. Sorry, I should have mentioned it was A7 in my original post.
Posted By: Anonymous

Re: Shadows / Render Stencil and Saving/Loading levels - 06/28/16 22:33

Quote:
@Malice - It sounds like you are referring to the A8 engine/manual. Sorry, I should have mentioned it was A7 in my original post.


Indeed was...! I've got nothing for the last gen. However my game_save with flags advice is relevant all the way back to A5.

A game save/load system isn't to hard . It's just a (load) level_load and a for_loop to 'adjust' the world. (Save) it's just a for_loop to record(in a form you choose) states for things, and only what you'd like to save.
© 2024 lite-C Forums