Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / updated for DBC ---> LEES CHALLENGE TWO: Fast Quality Shadow Trick

Author
Message
Silverman
17
Years of Service
User Offline
Joined: 18th Jan 2007
Location: France
Posted: 23rd Sep 2012 17:19 Edited at: 4th Oct 2012 00:57
Hi all,
this is the second part of the challenge of LEE BAMBER, updated.(texture shifting on a 3D object)

You will find the first part here:
http://forum.thegamecreators.com/?m=forum_view&t=200186&b=10

challenge two:


enjoy!
@+

DirectX 9.0c (February 2010)/ DBClassic v1.20
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Oct 2012 09:33
Interesting.

This seems to be a variation of environmental mapping. You texture the object with what would seem to be a reflection, and you manipulate the texture coordinates to make it seem like the angle of the reflection is changing.

Can you explain what is happening?

Enjoy your day.
Silverman
17
Years of Service
User Offline
Joined: 18th Jan 2007
Location: France
Posted: 2nd Oct 2012 14:51 Edited at: 2nd Oct 2012 14:53
Hi latch,
(sorry for my bad english, I use google to translate but it is not perfect)

The principle of this shade is a special texture scroll on a second transparent object whose alphablending is negative.


The shadow texture is white with a black border.(The black border is important)

The second object has the alphablending negative for the gradual disappearance of the shadows, transparency set to 1.
The texture mode(set object texture obj, mode, mipmap) set to "clamp" mode.
(Clamp mode retains the colour of the last pixel at the textures edge and paint with that throughout the out of range area)

So alphablending negative and transparency will make a black shadow with transparent edges (invisible).

Now, if the texture out of a polygon, the polygon becomes invisible because the mode texturing of the object is set to "clamp" and the last pixel of the texture is invisible.


Texture coordinates are recalculated (per side in the example):
... 0.0 0.1 / 0.0 0.1 / 0.0 0.1 ...
... 1.0 1.1 / 1.0 1.1 / 1.0 1.1 ...

and become (only U in the example, but also recalculated V):
... -1.0 -1.0 / 0.0 0.1 / 1.0 1.1 ...
... 0.0 0.1 / 1.0 1.1 / 2.0 2.1 ...

The memblock scrolls texture, but "scroll object texture" have also agreed to this simple example.


I just updated the lee bamber challenge, and there is still work to do to improve this shadow effect. (I think it requires the use of dll for speed, and I do not make dll)

DirectX 9.0c (February 2010)/ DBClassic v1.20
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Oct 2012 00:33
Where is this file?: "C:\Program Files\Dark Basic Software\Dark Basic\lave.bmp"

Shh... you're pretty.
Silverman
17
Years of Service
User Offline
Joined: 18th Jan 2007
Location: France
Posted: 4th Oct 2012 01:04
@Obese87

not need. it was for my tests, I forgot to remove this line of code (first post edited), thank you for letting me know.

DirectX 9.0c (February 2010)/ DBClassic v1.20
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Oct 2012 23:06
Quote: "The principle of this shade is a special texture scroll on a second transparent object whose alphablending is negative."

Ah, I understand. So, if you had 10 different objects you wanted to cast a shadow on a terrain object, for example, you would need 10 additional copies of the terrain object so each one could be textured with the shadow?

It seems like it might be a bit inefficient.

Here's an idea:

You use ray casting. In DBC you would use Coldet so you could return the collided triangle(s).

Based on the size of the triangle returned, you might cast rays around it to get a larger area. Once you have the triangles, you create a new object out of the triangles using their dimensions. You then texture them with your shadow.

Since the new triangles are created in the same position as the collision detection, the overlay should be seamless. This would cut down the overhead of duplicating entire objects by just using the necessary triangles that the shadow might fall on.

This is just an idea, I've never tried it but it makes sense in my head.

Enjoy your day.
Silverman
17
Years of Service
User Offline
Joined: 18th Jan 2007
Location: France
Posted: 11th Oct 2012 13:42
@Latch
Quote: "So, if you had 10 different objects you wanted to cast a shadow on a terrain object, for example, you would need 10 additional copies of the terrain object ..."

exact!

For raycasting, I had the same idea as you, and tests I've done shows that the raycasting of coldet is slower than sparky. I would do other tests later when I would be less busy.

DirectX 9.0c (February 2010)/ DBClassic v1.20
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Oct 2012 22:14
Quote: "For raycasting, I had the same idea as you, and tests I've done shows that the raycasting of coldet is slower than sparky. I would do other tests later when I would be less busy."

Speed might depend on settings; but I suggest ColDet because you can return the triangle that is collided with.

Enjoy your day.

Login to post a reply

Server time is: 2024-04-18 05:27:06
Your offset time is: 2024-04-18 05:27:06