Jump to content
The Dark Mod Forums

sprites with spec and normalmaps (and alpha)


mikebart

Recommended Posts

Ive been told its not possible with doom3 but im sceptical, all my attempts have resulted in a black image but the alpha still works, im basicly trying to create the same effect as the trees in Oblivion.

Hope someone can help.

Thanks.

Link to comment
Share on other sites

Could you describe what you want to do in more detail?

 

Contrary to popular D3W belief, sprites can receive lighting and have normalmaps just like anything else. After all, D3 uses a unified rendering system, so a sprite can have any material that geometry can have. However, regardless of whether you're using sprites, you may have problems with translucency and alpha maps, depending on what you want to do.

 

It's possible to use alpha-testing to punch out holes, so leaves are correctly shaped. Alpha-tested materials will be correctly drawn, receive shadows, etc, so they're perfect for foliage. I strongly recommend using alpha-tested surfaces for trees and such.

 

It's sort of possible to have lighting/specularity on a translucent surface (not to be mistaken for an alpha-tested surface), but there's severe problems and limitations to that. For example, shadows require depth-buffer information, so translucent surfaces will not be hit by shadows. Furthermore, there is no depth-sorting of translucent surfaces (though D3 does have categorical sorting of surfaces), so you'll get severe graphics errors if you try to use translucent surfaces to draw leaves. Also, all the lighting passes will be rendered additively before any custom passes, so if you want some leaves to obscure others, they cannot be lit.

 

An example of lit translucent sprites would be the test_volumetric map. However, keep in mind in test_volumetric the order in which the sprites are drawn didn't matter (unlike leaves) and the light doesn't have real shadows. Also, the map was very expensive.

 

For more information, you might check this discussion on the alpha-channel, translucency and depth-sorting.

Link to comment
Share on other sites

Hey thanks for the link, it was a very interesting discussion that answered alot of questions.

 

Contrary to popular D3W belief, sprites can receive lighting and have normalmaps just like anything else.

Thankyou :laugh:

 

I've basicly just added the 'defom sprite' def to an alpha tested material as you can see below and thats about as far as I got.

 

Im really not too clued up on shaders but this just seems like such a simple thing, from what I understand a material wich has the 'deform sprite' def is just like a lookat_target which tells the polys its been assigned to, to target and track the player, so why wouldnt it receive lighting and shadows?

 

models/nature/tree_foliage01
{
deform sprite
	noShadows
nonsolid
noimpact
twoSided

qer_editorimage models/nature/tree_foliage01_d.tga

{	   
	   blend	diffusemap
 map	models/nature/tree_foliage01_d.tga
 alphaTest 0.5
}

specularmap	models/nature/tree_foliage01_s.tga
bumpmap 	models/nature/tree_foliage01_local.tga
}

 

and heres a pic of what happens:

 

 

trees5hq3.th.jpg

 

It's sort of possible to have lighting/specularity on a translucent surface (not to be mistaken for an alpha-tested surface), but there's severe problems and limitations to that. For example, shadows require depth-buffer information, so translucent surfaces will not be hit by shadows. Furthermore, there is no depth-sorting of translucent surfaces (though D3 does have categorical sorting of surfaces), so you'll get severe graphics errors if you try to use translucent surfaces to draw leaves. Also, all the lighting passes will be rendered additively before any custom passes, so if you want some leaves to obscure others, they cannot be lit.

 

This is one ive used in the past, wich I think is doing what you were describing:

models/nature/tree_foliage02

{ 
qer_editorimage models/nature/tree_foliage01_d.tga 

DECAL_MACRO 
noShadows 
nonsolid 
noimpact 
twoSided 
translucent 
deform sprite		

{ 
blend GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA 
map models/nature/tree_foliage01_d.tga 

} 

}

 

But like you said, the brightness of the texture is determined by the diffuse and it receives no lighting or shadows and is unsorted.

 

I ended up just creating a 6-tri cluster model (3 planes facing at each axis) for the foliage using the same material but removed the 'deform sprite' def and I personally think it looks ok possibly even better than it would have if i'd used sprites.

Something I've found with sprites is that they have to be quite small otherwise you really notice them when you orbit around the model, so with the cluster models I was able to double them in size and by doing so cut out a few tris from the model.

 

But im still very interested in alpha-sprites which have normalmaps and specular, there would be so many uses for them.

 

thanks again :)

Link to comment
Share on other sites

Hmm... I'm not seeing anything obviously wrong with the shader. I'll have to go try that and see if I can get it working myself... Actually it occurred to me that I've only tested lighting with particles (which behave just like sprites), not specifically "deform sprite". Are you saying the material works when you take away "deform sprite"? If so, I may have to eat my own words about sprites being able to receive lighting...

 

Another possibility, which may have a similar effect, would be to use a particle deformation instead. You could make an alpha-tested leaf texture (without deform sprite), make a particle effect that uses it, and then make an invisible material that emits those particles (sort of like how SneaksieDave's rain map uses a surface that emits rain particles). I guess that would only work if you could come up with a particle effect where the particles don't fade in/out.

 

PS, I love your textures!

Link to comment
Share on other sites

If so, I may have to eat my own words about sprites being able to receive lighting...

I wasn't even aware that sprites were in Doom3, but maybe that's just because I was assuming particles were just regular textures? Are these sprites as in games from 20 years ago, or a different evolution of sprites?

 

Anyway, if particles are sprites, then I can confirm they can be lit - set up a dark room with a light in it, and put a fly swarm half in and half out of the light. In the dark, only silhouettes are visible. In the light, you can make out wings, eyes, etc. The timestop command helps to see it. Are we talking about the same thing?

 

I've actually wondered if this might be part of the reason rain and snow particles are so... damn... slow. Maybe they're lit, and that's almost definitely unnecessary...

Link to comment
Share on other sites

I wasn't even aware that sprites were in Doom3, but maybe that's just because I was assuming particles were just regular textures? Are these sprites as in games from 20 years ago, or a different evolution of sprites?

 

"deform sprite" is a particular material option which makes the triangles always face the viewer (also known as billboarding). It does not refer to the Commodore 46 era technology which is a 2-dimensional image overlayed on the screen.

 

I wonder if it is possible that deform sprite materials are actually not lit, because the geometry modification takes place as a final step AFTER all of the lighting passes have been rendered? Just a theory, I don't actually know how these are handled.

Link to comment
Share on other sites

Hmm... I'm not seeing anything obviously wrong with the shader. I'll have to go try that and see if I can get it working myself... Actually it occurred to me that I've only tested lighting with particles (which behave just like sprites), not specifically "deform sprite". Are you saying the material works when you take away "deform sprite"? If so, I may have to eat my own words about sprites being able to receive lighting...

yep, the material works fine when you take away 'deform sprite'

Another possibility, which may have a similar effect, would be to use a particle deformation instead. You could make an alpha-tested leaf texture (without deform sprite), make a particle effect that uses it, and then make an invisible material that emits those particles (sort of like how SneaksieDave's rain map uses a surface that emits rain particles). I guess that would only work if you could come up with a particle effect where the particles don't fade in/out.

 

Ive done some tests with particles myself, but it was a long time ago, early days of doom3 and I have a distinct memory of having a particle emit static sprites with diffuse, normal and specular reacting properly to light, but it was a long time ago, for all I know I might have dreamt it and confused it with reality.

I tried it again with a particle emitter recently in quake4 and got pretty much the same effect as the 'deform sprite' shader.

 

PS, I love your textures!

I love your shaders! I actually just found your test videos last night in the public forum, really impressive stuff, I wasnt aware those things were possible in doom3, it shows you have a very creative mind.

 

I wasn't even aware that sprites were in Doom3, but maybe that's just because I was assuming particles were just regular textures? Are these sprites as in games from 20 years ago, or a different evolution of sprites?

 

More like the sprites in Doom 1 and 2, Duke3D like the objects, candleabras, trees, pickup items although I dont think they are the same thing because in doom3 a sprite, wether its a particle or defined by the shader, is applied to a 2 triangle plane and thats why I find it hard to believe that we cant have lit sprites with bump as a stand alone shader.

 

I wonder if it is possible that deform sprite materials are actually not lit, because the geometry modification takes place as a final step AFTER all of the lighting passes have been rendered? Just a theory, I don't actually know how these are handled.

 

you might be onto something there, is it possible to change the order of events in a shader like that?

Link to comment
Share on other sites

Anyway, if particles are sprites, then I can confirm they can be lit - set up a dark room with a light in it, and put a fly swarm half in and half out of the light. In the dark, only silhouettes are visible. In the light, you can make out wings, eyes, etc. The timestop command helps to see it. Are we talking about the same thing?

 

have you tryed the same thing pointing at a material with diffuse, spec and local maps?

 

Btw, thanks for all the help guys :)

Link to comment
Share on other sites

Thanks sneaksie but I cant get the image to load, are you sure the links ok?, is it just me or has imageshack totally gone to shit lately?

Is the sprite material targeting a .tga file or a material file? if its a material file could you show it to me?

Link to comment
Share on other sites

I can see the images clearly. :) Imageshack is complete crap, that's why I found this other site, whcih is much faster. Haven't used it yet though, because Oddity said they are adding a watermark. I guess I have to look for another one if that's true (which I assume).

Gerhard

Link to comment
Share on other sites

I wonder if it is possible that deform sprite materials are actually not lit, because the geometry modification takes place as a final step AFTER all of the lighting passes have been rendered? Just a theory, I don't actually know how these are handled.
I was thinking the same thing, except I was wondering if "deform sprite"s wouldn't have lightgem flickering problems...
Link to comment
Share on other sites

Thanks sneaksie but I cant get the image to load, are you sure the links ok?, is it just me or has imageshack totally gone to shit lately?

Is the sprite material targeting a .tga file or a material file? if its a material file could you show it to me?

Not just you; imageshack is shit. :)

 

Here's another attempt, hopefully at another mirror:

fliesbz5.th.jpg

 

The particle references a material. For completeness, here's the 'junebug' definition:

textures/decals/junebug
{
	noSelfShadow
noshadows
nonsolid
twosided

qer_editorimage textures/decals/junebug.tga

	{	   
	   blend	diffusemap
 map	textures/decals/junebug.tga
 scale  bugwings[ time *10 ],1
 alphaTest 0.5
}
{	   
	   blend	bumpmap	
 map	textures/decals/junebug_local.tga
}
{	   
	   blend	specularmap
 map	textures/decals/junebug_s.tga
 scale  bugwings[ time *10 ],1
}
{	   
	   blend	add
 map	textures/decals/junebug_s.tga
 scale  bugwings[ time *10 ],1

}
}

Link to comment
Share on other sites

I think I'm lost. :mellow: Are you asking, having confirmed the sprite, can a regular material have alpha and specular and normalmaps? Your castle walls with window cutouts have them, so I assume that I'm misunderstanding the question (doesn't help that I'm no expert at this :laugh:).

Link to comment
Share on other sites

I think I'm lost. :mellow: Are you asking, having confirmed the sprite, can a regular material have alpha and specular and normalmaps? Your castle walls with window cutouts have them, so I assume that I'm misunderstanding the question (doesn't help that I'm no expert at this :laugh:).

 

Yeah it dosent help that im no expert either :), are you sure that the fly is actually a sprite and not a decal?

I mean does it always face the camera no matter what angle you veiw it from?

Link to comment
Share on other sites

are you sure that the fly is actually a sprite and not a decal? I mean does it always face the camera no matter what angle you veiw it from?

I don't really know the difference. AFAIK, it's a texture like any other, and used in the particle effect, probably set to 'view', which makes it always face the camera, yes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Ansome

      Finally got my PC back from the shop after my SSD got corrupted a week ago and damaged my motherboard. Scary stuff, but thank goodness it happened right after two months of FM development instead of wiping all my work before I could release it. New SSD, repaired Motherboard and BIOS, and we're ready to start working on my second FM with some added version control in the cloud just to be safe!
      · 0 replies
    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
×
×
  • Create New...