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.

Dark GDK / Texture Projection

Author
Message
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 19th Aug 2009 21:15 Edited at: 19th Aug 2009 21:16
hey guys!

I'm trying to find a way to achieve simple Texture Projection ( like for decals, stains, maybe even simplified shadows ).
Now what would be best?

I thought about a shader, but it has to be simple! shall i search for one or is it easy to write one?
Is there a good way to do it without using shaders?

thanks in advance.

They say it's better to burn out, than it is to fade away...
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 20th Aug 2009 01:23
hmm, I believe that I saw a demo in DBPro using its native lightmapping commands to do something very similar to what you are asking...

Or you could texture your decal image onto a plain and make it transparent or something and postion it where you want(probably better for non permanent or animated decals like fire or something)

If it ain't broke.... DONT FIX IT !!!
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 20th Aug 2009 01:38
do you remember the topic of that post? was it about 'decals'?
searching now...

the method with positioning planes, is good for some small effects (as you already said), but i need something to use at edges and terrains.

They say it's better to burn out, than it is to fade away...
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 20th Aug 2009 01:50 Edited at: 20th Aug 2009 01:53
Hmm someone gave me a link to an article a while ago on how someone did decals in his games, and it was very informational. I'm looking for it now... Will post/edit when I find it.

EDIT: Ah ha! Found it:
http://www.moddb.com/games/overgrowth/news/how-to-project-decals
It doesn't give you any code directly but it has very good description on the method behind decals.

Games are like life, they should never stand still.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 20th Aug 2009 01:53 Edited at: 20th Aug 2009 01:55
I cant remember where I got it from, It may have been from darksource or from the snippets board....

here ill post the dbpro code for it...

sorry, its not gdk, if you have trouble porting it let me know and ill hammer it out for you



The 2 media files are in the attachment zip.. about 48k .. you can see from the example its pretty masic, this is what it looks like :



Hope this helps you get the look you are after

EDIT : Seems the technique was blend mapping, not light mapping like I said before.. sorry about that

If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 20th Aug 2009 02:30
@Mista Wilson: thanks for the example! but i already know about this, the problem is that the blended stuff on the surface has to be movable (dynamic).

@heyufool1: thanks! that's exactly the effect i'm looking for! nice article, i'll have to work through this, as this is just what i need for my game.

does anybody have experience with this method?

They say it's better to burn out, than it is to fade away...
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 20th Aug 2009 02:56
I think the technique in that article is also static by the looks of it, its a weathering decal applied to concrete so its not going to be moving much...

That said, small movements can be obtained through scrolling the blended texture's UV's.... similar to how you would make a cloud effect except faster

If you want larger movement though that are likely to be across multiple objects, then texturing transparent plains with your decal would probably be the answer, they are about as dynamic as it gets lol

If it ain't broke.... DONT FIX IT !!!
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 20th Aug 2009 05:26
I guess mabie Im not understanding it correctly, but...

Doesn't Evovled's shadow mapping program, project the light texture on the teapot and the box ground? Where when you press the "shift" key it updates and projects to a new orientation/location based on the camera view.

For example: For a sun shadow effect, couldn't you use evolved's method to quickly move the camera at the sun location, update shadowing, and then move the camera back to a "player view" so it looks like you get shadows from the sun?

I thought "texture projection" is always projected from the camera view??

_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 20th Aug 2009 13:15
@Mista Wilson: yes, in the article the decal is not moving, but the technique of applying the decal is explained.
textured plains is no option because they will not adopt to the surface underneath.

@Todd Riggins: Evolved's shadow mapping does project the shadow onto the texture, but i can't figure out how to extract that code from his shader!

Now to make it clearer, here's what i'm trying to achieve:
You know these 'old-school' shadows, that are just a dark circle under the player. That's what i want, but it has to adopt the terrain, so you won't see it overlapping at edges.

They say it's better to burn out, than it is to fade away...
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 20th Aug 2009 14:25
You could make a plain that is divided into a grid of about 10x10 squares, and position that beneath the player. For each vertex, find the ground height at that point, and put the vertex just above it.

_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 20th Aug 2009 17:14
I thought about that too. But my terrain is a .x-model ( like the rest of the level ),
so i'd have to check the height for each of these vertices by using Sparky's RayCast downwards.
i would end up with 10x10 raycasts each frame - and that just for the shadow! i think that's too much computation...
but thanks anyway!

They say it's better to burn out, than it is to fade away...
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 20th Aug 2009 17:55
You wouldnt need to use that method, that would be slow...

Just go through and store the vertex positions in an array, a 2d array of floats, where each x and z position matches the x,z of a vertex, the float value would be the height.

Then you would just need to use some interpolation calcs to get they height value of the piece of terrain you are after..

for a working example of doing just this, take a look at VanB's Tersculpt terrain editor in the WIP or Prog Announce section(cant remember which) ... it uses a technique similar to what I just described both to deform it's terrain(capable of large terrains - it basically uses a static object that moves with the camera and deforms to a terrain height array) and to deform the tool cursor to the terrain itself... as you move the cursor(which is a textured 3d object) over the terrain, its verts move to match, its quite simple to do. That particular editor is in dbpro, but I have a copy floating around here somewhere that I ported to GDK a while ago to play with, I can dig it out if you cant make any sense of the dbpro one

If it ain't broke.... DONT FIX IT !!!
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 20th Aug 2009 18:06
ah ok, sounds interesting!

so i basically have to store the height values of my ground-model in an array, after loading the object. and then i just access these something like this:
float height = ground_array [x][z]
and then i deform the shadow to fit.

this would be the first time i actually deform objects real-time with DarkGDK. Is this done with memblocks?
Got any basic samples / tutorials?

They say it's better to burn out, than it is to fade away...
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 20th Aug 2009 18:34
something like that .... you would go through and get the vertex heights with the dbGetVertexDataPositionX, Y & Z commands.

And then set them based on your array heights.

As for examples, like I said, check out VanB's Tersculpt terrain editor. It's cursor and terrain both use this technqie, its quite simple and doesnt require memblocks, just modifying vertexdata.. the most important bit, after you figure out the actual vertex manipulation, is the interpolation of the height array.. have a read through the tersculpt thread, as VanB discusses it a few times in there in various posts.

If it ain't broke.... DONT FIX IT !!!
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 20th Aug 2009 19:21
ok, gonna check it out!

thanks a lot!
cheers

They say it's better to burn out, than it is to fade away...

Login to post a reply

Server time is: 2024-11-20 17:43:16
Your offset time is: 2024-11-20 17:43:16