Dynamic Realtime Shadows

Posted By: Espér

Dynamic Realtime Shadows - 05/24/09 15:42

hi there..
me again..

I wanted to ask if there´s a way for me ( commercial edition user ) to create dynamic realtime shadows...?

I need them for Models ( and etrrains in *.mdl format ). The only result i get is a blurred spot at the ground below the model... And that spot is rotating with the model.. and not against the light source...
Posted By: alibaba

Re: Dynamic Realtime Shadows - 05/24/09 17:49

write this in your main code: shadow_stencil=4;
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 05/24/09 17:51

Originally Posted By: alibaba
write this in your main code: shadow_stencil=4;

He said: ( commercial edition user ) !
And that's for Pro users. However, i guess he knows that, but maybe he wants another shadow maybe?
Posted By: Espér

Re: Dynamic Realtime Shadows - 05/24/09 17:53

I saw this at google a few minutes ago:


Any chance to get this shadow effect ( but a bit transparent + fadeout.. not only black )
Posted By: gri

Re: Dynamic Realtime Shadows - 05/25/09 07:44

Originally Posted By: Cowabanga
Originally Posted By: alibaba
write this in your main code: shadow_stencil=4;

He said: ( commercial edition user ) !
And that's for Pro users. However, i guess he knows that, but maybe he wants another shadow maybe?


WHAT ?

Stencil shadows are available in A7.com.

regards
,gri
Posted By: fogman

Re: Dynamic Realtime Shadows - 05/25/09 08:41

shadow_stencil = 4; is indeed for pro users.
But you can use shadow_stencil = 1; or shadow_stencil = 2;

http://www.conitec.net/beta/shadow_stencil.htm
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 05/25/09 14:38

@gri:


Originally Posted By: fogman
shadow_stencil = 4; is indeed for pro users.

Exactly.
Posted By: Espér

Re: Dynamic Realtime Shadows - 05/26/09 16:49

Ok
But doesn't matter what stencil_shadow I use.. It's always that bad blob-blurred shadow..
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 05/26/09 16:54

Originally Posted By: Espér
It's always that bad blob-blurred shadow..

So how do you want it?
Posted By: Espér

Re: Dynamic Realtime Shadows - 05/26/09 18:01

uhm... i posted an image in my last post ( 05/24/09 07:53 PM )

Here again:
Originally Posted By: "Espér, 05/24/09 07:53 PM"

Any chance to get this shadow effect ( but a bit transparent + fadeout.. not only black )

Posted By: KiwiBoy

Re: Dynamic Realtime Shadows - 05/26/09 18:48

Have you switched 'sunlight' off? Normally, the thresh hold is set to the default 'sun' and if it is off or its threah hold has been changed shadows wont appear.

Or if you use shaders that turn it off.
Posted By: Espér

Re: Dynamic Realtime Shadows - 05/26/09 22:07

i use a cartoon shader ( just outlines.. )..
Any chance to use a shadow like in the picture, together with a cartoon shader?
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 05/27/09 11:23

Well, it was a stencil shadow in the image. And can work fine with Toon shader.
Posted By: Espér

Re: Dynamic Realtime Shadows - 05/27/09 19:21

yes.. but what i get.. is not like in the picture.

See here:



That´s what i get with "shadow_stencil = 2;" + Dynamic light with CAST ( and SHADOW on models )
ugly.. And rotating with the player...
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 05/27/09 19:29

That's a decal shadow, it's supposed to generate a stencil shadow. Maybe you've defined my.shadow ...?
Posted By: KiwiBoy

Re: Dynamic Realtime Shadows - 05/27/09 20:03

In Main;

Stencil_shadow = 2;

In action
set(my, SHADOW);
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 05/28/09 05:01

@KiwiBoy:
He said he putted stencil_shadow = 2.
And how does the engine put a shadow without set(my,SHADOW)? So of course he putted that also. And actually he said that he putted SHADOW flag at all models in his last post. Think about it, not to increase your posts wink. However, that's an advice.

@Espér:
Did you defined my.shadow ...? confused
Posted By: Espér

Re: Dynamic Realtime Shadows - 05/28/09 11:51

no.. how to?
Posted By: pegamode

Re: Dynamic Realtime Shadows - 05/28/09 12:20

Where exactly in main.c have you put "shadow_stencil"?

Have you searched all your code (inclusive all includes you use) for another shadow_stencil command that overrides yours?

GS generates a decal shadow instead of a stencil shadow so there's something wrong somewhere in your code.

Maybe you should break down your code to just have a main.c that loads the level.

Regards,
Pegamode.
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 05/28/09 15:55

Originally Posted By: Espér
no.. how to?

No! no need for that, because if you defined it, you'll see those "ugly" shadows wink.
Posted By: Espér

Re: Dynamic Realtime Shadows - 05/28/09 17:08

The only codes I used:
Code:
level_load("test.wmb");
wait(3);
shadow_stencil = 2;

Code:
set(my, CAST); //dynamic light cast

Code:
set(my, SHADOW); //in model action

Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 05/28/09 17:15

Try:
Code:
shadow_stencil = 2;
level_load("test.wmb");
wait(3);

Posted By: KiwiBoy

Re: Dynamic Realtime Shadows - 05/28/09 18:35

Try a new level without the shader and see if stencils show up, that might give you a comparative and from there you can determine what the cause may be for the current problems smile

Another factor to check out, is the model closed off? Important as a model with big holes will either display strange artifacts.

Posted By: Espér

Re: Dynamic Realtime Shadows - 05/28/09 20:29

all meshs are closed..
With shadow_stencil before level initial, no shadow is shown..
The stencil isn´t shown without the shader, too
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/02/09 20:15

ok.. i made the sunlight off.. but still no shadow... *going crazy*
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 06/03/09 11:26

Maybe there's something in your code that disables the shadow??
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/03/09 11:41

I don't think so...
I only activate CAST in the light action, and shadows in the models action
No code wich disables the shadow functions..
Posted By: EvilSOB

Re: Dynamic Realtime Shadows - 06/03/09 12:28

It may be a dumb, or already answered question but

Is there any shader on the floor? That may be a problem...
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/03/09 14:20

No shaders on the floor or terrain

I tried it with a new script...
Just a ball with SHADOW flag, inside a cube, one dynamic light with CAST flag, and shadow stencil on 0,1 and 2
First gives no shadow (or it is to small to see)
The 1 & 2 are the blurred blob again...
Posted By: garv3

Re: Dynamic Realtime Shadows - 06/05/09 11:07

Maybe you are using a graphics card that does not support stencil grin
But to be serious, the error must be in your code or your hardware(settings).
Maybe you set up some strange behaviour in your grahpics card's control panel!?
Posted By: EvilSOB

Re: Dynamic Realtime Shadows - 06/05/09 14:44

This is a long thread, so ignore me if its already been said,
but have you tried on another machine, and/or another gstudio version,
and/or tried a gstudio re-install?
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 06/05/09 15:58

Originally Posted By: garv3
Maybe you are using a graphics card that does not support stencil grin

Ummmm, so how can his computer renders a toon shader that requires VS 1.3 (And stencil shadows needs VS 1.3)? smile
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/05/09 16:26

I tried some other shaders ( crystal, normal map2, the shade-c things )
They all worked perfect... So I think it's not a problem with the graphiccard..

Code problem... Don't think so. Just a main function wich creates 2 ents. 1 light and 1 model inside a cube...

Hmmm perhaps...do I have to include something???
Posted By: ChrisB

Re: Dynamic Realtime Shadows - 06/05/09 16:34

Maybe you are using models with a transparent texture? Stencil shadow doesn't work (or better 3dgs doesn't use them) with transparent skins.
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 06/05/09 16:35

@ChrisB:
That was my first thought, but, toon shader don't work with transparent skins, and Espér said it's working perfectly. smile
Posted By: bart_the_13th

Re: Dynamic Realtime Shadows - 06/06/09 10:07

Umm... maybe you need to set lightrange on Dynamic Light... You said that the light is engine generated, not level generated(which set lightrange at default 300)...
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/06/09 11:20

ok.. before everyone sais more things to let me think, that you think i´m stupid:

Code:
//=================================================================================================================================
//                                                                                                                               //
//                                                     DAS MAINSCRIPT                                                            //
//                                                     ^^^^^^^^^^^^^^                                                            //
//                                                                                                                               //
//=================================================================================================================================
//                                                                                                                               //
//                                          EINBINDEN DER UNTERORDNER UND SCRIPTS                                                //
//                                          """""""""""""""""""""""""""""""""""""                                                //
//                                                                                                                               //
//=================================================================================================================================
#include "acknex.h"
#include "default.c"

//=================================================================================================================================
//                                                                                                                               //
//                                                         PANELS                                                                //
//                                                         """"""                                                                //
//                                                                                                                               //
//=================================================================================================================================


//=================================================================================================================================
//                                                                                                                               //
//                                                       FUNKTIONEN                                                              //
//                                                       """"""""""                                                              //
//                                                                                                                               //
//=================================================================================================================================
function lichttest()
{
	my.lightrange = 1000;
	my.x = 500;
	my.y = 500;
	my.z = 800;
	set(my, SHADOW | CAST);
//	while(1)
//	{
//		if(editorgogo == 0)
//		{
//			vec_set(my.x,player.x);
//			my.y += 100;
//			my.z += 400;
//		}
//		wait(1);
//	}
}

function test()
{
	set(my, SHADOW);
}


//=================================================================================================================================
//                                                                                                                               //
//                                                        AKTIONEN                                                               //
//                                                        """"""""                                                               //
//                                                                                                                               //
//=================================================================================================================================

//=================================================================================================================================
//                                                                                                                               //
//                                                     DAS MAINSCRIPT                                                            //
//                                                     """"""""""""""                                                            //
//                                                                                                                               //
//=================================================================================================================================

function main()
{
	fps_max = 60;
	video_mode = 8;
	d3d_antialias = 9;
	video_set(1024,768,32,0);
	video_window(vector(10,10,NULL),NULL,2,"Test");
	level_load("Editor.wmb");
	sky_color.red = 1;
	sky_color.green = 1;
	sky_color.blue = 1;
	wait(3);
	shadow_stencil = 2;
	mouse_mode = 0;
	
	ent_create("Charakter_human_Template_2.mdl",vector(150,150,1000),test);
	ent_create(NULL,vector(0,0,156),lichttest);
	
	wait(1);
	hud_update();
	wait(1);
}



i tried with shadow_stencil = 2; before the level_load too..
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 06/06/09 12:04

I see no problem in your code. But:

Code:
#include "acknex.h"
#include "default.c"

What? it's supposed to be:

Code:
#include <acknex.h>
#include <default.c>

Except if you copied them...
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/06/09 13:00

I know there´s no problem.. but the shadow isn´t working..

and.. i copied acknex.h and default.c in my game folder ( because in the last GS Version, the acknex.h has an error with PANEL Element.. so i needed to use an older acknex.h )
Posted By: EvilSOB

Re: Dynamic Realtime Shadows - 06/06/09 13:18

Stup up to public beta 7.77 then, its got no problems to the best of my knowledge.

It may also fix the issue too. Mixing old acknex.h's with with different engine can never be trusted.
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/06/09 13:35

ok.. i installed the update to 7.77 and changed "" to <>

still no changes..
Posted By: EvilSOB

Re: Dynamic Realtime Shadows - 06/06/09 13:59

Have you tried it in a NEW level? That may be something 'broken' in editor.wmb
thats causing it.
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/06/09 14:40

editor.wmb is the new level..
Posted By: Tobias

Re: Dynamic Realtime Shadows - 06/06/09 15:06

For stencil shadow you must manage 3 things:

1. Setting shadow_stencil, before loading your level. As far as I see, you already managed that.

2. Having a model with SHADOW flag, and it must not be a transparent model, because transparent models dont throw shadows. Now when you ask "What is a transparent model"? you find transparency described in the manual under "Entities".

3. Not switching off the sun.

Hope this helps.
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/06/09 15:47

ok..

1. & 2. is ok..


Code:
sun_light= 0; //Keine Sonne


i´ve done that before and after level_load..

but no stencil shadow..
Posted By: XD1v0

Re: Dynamic Realtime Shadows - 06/06/09 18:02

Espér looks like mystical things goes with shadows crazy , maybe my advance can help
Try to create simple model something like this
Code:
 ent_create (SPHERE_MDL,vector(150,150,1000),test);

If this model throwing shadow then problem with you skin model.
Posted By: Anonymous

Re: Dynamic Realtime Shadows - 06/06/09 21:35

Originally Posted By: Espér

Code:
sun_light= 0; //Keine Sonne


i´ve done that before and after level_load..

but no stencil shadow..


He said don't switch off the sun!
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/06/09 22:24

ok.. sun shines.. no shadow...
Posted By: Anonymous

Re: Dynamic Realtime Shadows - 06/06/09 22:26

can you upload the level, so we can check if it works for us?
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/06/09 22:33

ok.. if it helps you:

http://daten.rmxpworld.de/Editor.rar
Posted By: Anonymous

Re: Dynamic Realtime Shadows - 06/06/09 22:40

and the script please smile
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/06/09 23:01

Code:
//=================================================================================================================================
//                                                                                                                               //
//                                                     DAS MAINSCRIPT                                                            //
//                                                     ^^^^^^^^^^^^^^                                                            //
//                                                                                                                               //
//=================================================================================================================================
//                                                                                                                               //
//                                          EINBINDEN DER UNTERORDNER UND SCRIPTS                                                //
//                                          """""""""""""""""""""""""""""""""""""                                                //
//                                                                                                                               //
//=================================================================================================================================
#include <acknex.h>
#include <default.c>

//=================================================================================================================================
//                                                                                                                               //
//                                                         PANELS                                                                //
//                                                         """"""                                                                //
//                                                                                                                               //
//=================================================================================================================================


//=================================================================================================================================
//                                                                                                                               //
//                                                       FUNKTIONEN                                                              //
//                                                       """"""""""                                                              //
//                                                                                                                               //
//=================================================================================================================================
function lichttest()
{
	my.lightrange = 1000;
	my.x = 0;
	my.y = 0;
	my.z = 200;
	set(my, SHADOW | CAST);
}

function test()
{
	set(my, SHADOW);
}


//=================================================================================================================================
//                                                                                                                               //
//                                                        AKTIONEN                                                               //
//                                                        """"""""                                                               //
//                                                                                                                               //
//=================================================================================================================================

//=================================================================================================================================
//                                                                                                                               //
//                                                     DAS MAINSCRIPT                                                            //
//                                                     """"""""""""""                                                            //
//                                                                                                                               //
//=================================================================================================================================

function main()
{
	fps_max = 60;
	video_mode = 8;
	d3d_antialias = 9;
	video_set(1024,768,32,0);
	video_window(vector(10,10,NULL),NULL,2,"Test");
        // shadow_stencil = 2;
	level_load("Editor.wmb");
	sky_color.red = 1;
	sky_color.green = 1;
	sky_color.blue = 1;
	wait(3);
	shadow_stencil = 2;
	mouse_mode = 0;
	
	ent_create("dummy.mdl",vector(150,150,1000),test);
	ent_create(NULL,vector(0,0,156),lichttest);
}



dummy.mdl is just a sphere model with a blue skin... simple to make by your own ^^
Posted By: testDummy

Re: Dynamic Realtime Shadows - 06/07/09 06:49

Quoting Tobias.
Quote:
1. Setting shadow_stencil, before loading your level.

It seems, in that sample, shadow_stencil is set ~3 frames after level_load.

Maybe "shadow_stencil = n;" should be placed as the first line in function "main()"?

Set sun parameters in WED?
Posted By: Quad

Re: Dynamic Realtime Shadows - 06/07/09 06:52


not even changed a single line or recompiled the level, just put a dummy.mdl and ran.
Posted By: KiwiBoy

Re: Dynamic Realtime Shadows - 06/07/09 09:37

Check your skin, though I recall some one else also pointing this out.
Manage skins;
Texture format;
should be 8 to 24 bit but 24 bit for todays graphics, not 32 bit.
Sorry if you been thru this but there is no reason why you have no dynamic shadows unless
1. Sunlight turned off.
2. Dynamic lights not enough range for minimun shadow creation.
3. Shaders which affect other lights in level
4. Alpha skin settings on.

I have no probs as Quadraxus states, I simply apply the conditions and the shadow is their dragging down on my frames per second render process laugh
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/07/09 10:55

the dummy.mdl is just a spehere with ablue TGA skin.. 24bit, no alpha channel.. what the hell should i check there..

seems like a problem in my engine.. i try to download it again.. and reinstall..
Posted By: KiwiBoy

Re: Dynamic Realtime Shadows - 06/07/09 11:36

Rechecked code, who is 'my' in function test(); ?
Shouldnt you have a pointer to an entity?
The only way I have used it is directly in the player script or npc itself and it works fine that way.
It knows who 'my' is and sets itself to that doesnt it?
Posted By: Quad

Re: Dynamic Realtime Shadows - 06/07/09 11:39

if you look closer to that line:
ent_create("dummy.mdl",vector(150,150,1000),test);


test is used like an action and refers to the entity that has dummy.mdl as model.
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/07/09 11:50

ok.. after reinstalling the engine.. the shadows work.. it was a problem with my engine.. -.-

But the shadows are looking ugly on the model:


Any way to make them better?
Posted By: KiwiBoy

Re: Dynamic Realtime Shadows - 06/07/09 11:52

Ok thanks again, but its still not working is it?
So maybe trying it as a full entity might bring a resultt or discount the theory?
Im clueless and guessing and just ran out of experience... smile
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 06/08/09 15:08

You mean the ugly shadows 'on' the player?

Just put: set(my,CAST);
in player's action. smile
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/08/09 17:43

EDIT*

Works now.. thx ^^ helped me out much ^^
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/23/09 22:16

NEW PROBLEM

WTF: Where´s this line coming from???



This ugly...
Posted By: Quad

Re: Dynamic Realtime Shadows - 06/23/09 22:24

your mesh is not closed
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/23/09 22:32

it´s closed... looked very often ( perhaps i dreamed.. better looking 10 times.. )
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 06/24/09 07:42

To check, Go to MED -> Tools -> Mesh Tester. And see the results.
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/24/09 11:06

... see last post from me (sometimes i think, that you think i´m stupid) -.-

THE MESH IS CLOSED!!!!!
Posted By: Cowabanga

Re: Dynamic Realtime Shadows - 06/24/09 11:22

Fine. If you like that, just don't ask me again.
Posted By: alibaba

Re: Dynamic Realtime Shadows - 06/24/09 11:29

Guy please dont squabble!
Btw can you upload the model , then we can look into it.
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/24/09 11:59

@Cowabanga: nothing against you.. but i said that i looked if the mesh is opened.. And the answer of you is like i don´t know how to look... not really helpful after i saif that it´s closed.

@alibaba
sure:
http://daten.rmxpworld.de/Template.mdl
For all other.. before they say it again:
Posted By: alibaba

Re: Dynamic Realtime Shadows - 06/24/09 12:01

ah thanks esper i´ll look into it and try to help you.

EDIT: esper is right. but i can not figure out why this happens.
Posted By: Machinery_Frank

Re: Dynamic Realtime Shadows - 06/24/09 12:29

How many polygons / vertices does it have? It looks too dense especially since GS smoothes the material. So such a dense mesh is not needed.

It might be that it has too many vertices and that is the reason for creating wrong shadow extrusions.
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/24/09 13:29

i don´t think that there´re to many polys..

shadows of a model with 12000 Polys are normal.. This mode, has only 3576..
Posted By: Machinery_Frank

Re: Dynamic Realtime Shadows - 06/25/09 06:04

Yes. That should be ok.
Posted By: EvilSOB

Re: Dynamic Realtime Shadows - 06/25/09 07:08

Im not much of a modeller, so I dont know IF this is related to the problem,
But open the model in MED, goto "faces" mode, and "edit/select all".

Then roll the 3d-view around until you are looking at the "top" of the head/ears.
See those black marks on the ears? What are they anyone?
Damaged polys, flipped normals, or what? The dont belong but I cant
figure out what they are...
Posted By: Espér

Re: Dynamic Realtime Shadows - 06/25/09 10:19

yes.. i see..

hmm.. in normal view, they´re not visible, even when i activate "show backface"... They´re just visible if i mark the model..
Edit: And i can´t select them o.O
Posted By: EvilSOB

Re: Dynamic Realtime Shadows - 06/25/09 15:03

Im sorry i still dont have a "fix", but I may have found a way to highlight
the (many) problem polygons. I think it is possibly caused by import errors.

Open in WED, goto to faces mode, then select JUST ONE polygon, then keep
clicking on "select touching" button until no more selection is being added.
You will see this leaves a LOT of unselected polys.
This doesnt make sense, because if you hit "select connected" it will select
ALL the polys.
AND which polys end up not selected varies depending on where the start poly was too.
_ _
O.o
Posted By: Germanunkol

Re: Dynamic Realtime Shadows - 06/26/09 06:19

So maybe build your model again in a different program (if you haven't already done that?) and import again?
If you build it in another program in the first place, see if everything's right there...
Posted By: Espér

Re: Dynamic Realtime Shadows - 07/11/09 22:00

New Shadow Question...:

Can it be: Sprite Entities can´t throw a stencil shadow?
Posted By: Espér

Re: Dynamic Realtime Shadows - 07/22/09 23:31

ok.. little performance question:

is this normal:

I put 1 lightsource into my level. the level is a hollowed block. inside are 50 models ( 1 playfield and 49 rasterblocks on it ). Each model has the SHADOW Flag activated.
The lightsource is a dynamic light, with active CAST flag.
When i make a testrun, the FPS drop down to 10-20..
Why???

Pc.:
AMD Athlon(tm) 64 X2 Dual Core Processor 4400+ 2,30GHz
3GB DD2 Ram
NVidia GeForce 9400GT

How can this be???
Posted By: Enduriel

Re: Dynamic Realtime Shadows - 07/23/09 12:17

non accelerated stencil shadows are slow.
Posted By: Espér

Re: Dynamic Realtime Shadows - 07/23/09 16:00

How to make that better?
© 2024 lite-C Forums