Jump to content


Photo

Real Translucency Anyone?


75 replies to this topic

#1 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 886 posts

Posted 01 August 2010 - 04:30 AM

So I've been reading over bits and pieces from the polycount wiki and I found this...

http://wiki.polycoun...ighting_Example

And I've also found a way to implement it into Doom 3...



Generally when you make a material shader you're only permitted to use one set of diffuse, specular, and normal maps. But in the example posted on polycount they use two sets. So how do I make this work in idTech 4?

It turns out it's easy. You use vertex colors like you would if you were making vertex blended terrain. The trick is to apply 50% grey to all the vertices so each set of texture maps has equal weight when everything is composited.
  • Melan, 7upMan, nbohr1more and 1 other like this

#2 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 01 August 2010 - 04:49 AM

Really cool. Now we just need to convert all our foliage materials :)
  • nbohr1more likes this
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#3 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 886 posts

Posted 01 August 2010 - 05:43 AM

It's not just for foliage. You could also make things like curtains, space dividers, and even lampshades that don't need special skins to react appropriately to lights.
  • 7upMan and nbohr1more like this

#4 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 01 August 2010 - 05:50 AM

It's not just for foliage. You could also make things like curtains, space dividers, and even lampshades that don't need special skins to react appropriately to lights.


Even more cool :wub: Do you have the time to convert some of our existing materials to use the new technique?
  • nbohr1more likes this
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#5 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 886 posts

Posted 01 August 2010 - 06:52 AM

I can bust one out every now and then. I'll try one tonight and see how it goes.
  • 7upMan and nbohr1more like this

#6 Melan

Melan

    Contest Winner, Wordsmith

  • Campaign Dev
  • PipPipPipPip
  • 4455 posts

Posted 01 August 2010 - 07:17 AM

That's very nice! The shadowy silhouettes are perfect and very thiefy. :wub:
Come the time of peril, did the ground gape, and did the dead rest unquiet 'gainst us. Our bands of iron and hammers of stone prevailed not, and some did doubt the Builder's plan. But the seals held strong, and the few did triumph, and the doubters were lain into the foundations of the new sanctum. -- Collected letters of the Smith-in-Exile, Civitas Approved

#7 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37790 posts

Posted 01 August 2010 - 07:41 AM

Could this be used for self-lit windows? It would be awesome to see silhouettes of guards patrolling back and forth behind the windows of a mansion.
TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#8 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 886 posts

Posted 01 August 2010 - 08:03 AM

Yes, it could be used for self-lit windows. Although I don't see the point of it being self-lit anymore. If you stick a light behind the window it will light up, no additive stage required. ;)

A quick rule of thumb is if the texture is opaque, then you can use this trick.
  • nbohr1more likes this

#9 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 01 August 2010 - 08:06 AM

Yes, it could be used for self-lit windows. Although I don't see the point of it being self-lit anymore. If you stick a light behind the window it will light up, no additive stage required. ;)

A quick rule of thumb is if the texture is opaque, then you can use this trick.


I thought the idea behind (no pun intended :) self-lit windows was that you didn't need a light for each window (or for each building).
  • nbohr1more likes this
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#10 Fidcal

Fidcal

    Master Mapper

  • Development Role
  • PipPipPipPipPip
  • 16771 posts

Posted 01 August 2010 - 09:09 AM

Looks great. Can you post the material shader you used? I don't understand how it is working. It's two-sided with the same texture in both the vertexcolor and inversevertexcolor stages? But I don't see how the normal map produces translucency.

#11 rebb

rebb

    Advanced Member

  • Active Developer
  • PipPipPip
  • 726 posts

Posted 01 August 2010 - 10:08 AM

Cool stuff, is the amount of tranclucency controllable in some way ?
Possibly using the RGB Keyword on the "backfacing" diffusemap ?

#12 Komag

Komag

    Uber member

  • Development Role
  • PipPipPipPip
  • 3279 posts

Posted 01 August 2010 - 02:03 PM

I would love to see silhouettes in windows, curtains, etc. Would have to be careful when building though, to keep performance up
Posted Image Posted Image

#13 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 886 posts

Posted 01 August 2010 - 02:29 PM

Looks great. Can you post the material shader you used? I don't understand how it is working. It's two-sided with the same texture in both the vertexcolor and inversevertexcolor stages? But I don't see how the normal map produces translucency.


There isn't anything special going on there. It's practically the same thing as what you would use if you were vertex blending something.

textures\leaftest
{
	noshadows
	twosided
	{
		blend	bumpmap
		map	textures\leaftest\normal.tga
		vertexcolor
	}
	{
		blend	diffusemap
		map	textures\leaftest\diffuse_alpha.tga
		alphatest 0.1
		vertexcolor
	}
	{
		blend	bumpmap
		map	textures\leaftest\normal_back.tga
		inversevertexcolor
	}
	{
		blend	diffusemap
		map	textures\leaftest\diffuse_back.tga
		alphatest 0.1
		inversevertexcolor
	}
}

The trick is in the normal map. By inverting the blue channel it now faces the opposite direction. Grey vertex colors ensure both sets of textures are rendered and the most brightly lit of the two overpowers the other. Since shadows cast on the back have an impact on it's brightness, they become visible from the front.

Also notice I have a different diffuse map. Basically all you need to do here is paint over the original diffuse to make it appear as it would if light was shining through it.

Cool stuff, is the amount of tranclucency controllable in some way ?
Possibly using the RGB Keyword on the "backfacing" diffusemap ?


Just use a different value of grey for the vertex color.

Edited by rich_is_bored, 01 August 2010 - 02:31 PM.

  • nbohr1more likes this

#14 aidakeeley

aidakeeley

    Advanced Member

  • Banned
  • PipPipPip
  • 913 posts

Posted 01 August 2010 - 02:30 PM

Oooh let's see a curtain!





<_<




<_<



I know that sounds geek, but I'm actually serious. Would love to see this. Also, if you do do, can you please put the video up somewhere to download rather than stream?

Very.

Very.

Very.

Cool!
"A Rhapsody Of Feigned And Ill-Invented Nonsense" - Thomas Aikenhead, On Theology, ca. 1696

#15 New Horizon

New Horizon

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 13907 posts

Posted 01 August 2010 - 02:36 PM

Cool, so this could be used for illuminating the globes around the gas lights as well?

#16 OrbWeaver

OrbWeaver

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 7660 posts

Posted 01 August 2010 - 02:46 PM

Instead of using grey vertex colours, couldn't you just put "rgb 0.5" into every stage?

#17 Serpentine

Serpentine

    Uber member

  • Active Developer
  • PipPipPipPip
  • 2903 posts

Posted 01 August 2010 - 02:51 PM

rich, is it possible to manipulate the normal in the material def rather than making a new copy? i.e the channels can be manipulated but I dont know if it can use the result as a normal map... else this would most likely not be a viable thing on larger textures due to the size of extra normals :(

on a slightly related topic :
I've been playing with procedural generation of textures for TDM using FilterForge, using some of the example filters I came up with this in a few minutes:

horrible screenshot
(edit : wow the jpeg save really wasn't kind on the curtain details, the only time I use the automatic conversion to jpeg!)

Hopefully I can get the hang of it, tho estimating depth and such for exported heightmaps/ao can be a challenge as you can no doubt see :)

Edited by Serpentine, 01 August 2010 - 02:54 PM.


#18 OrbWeaver

OrbWeaver

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 7660 posts

Posted 01 August 2010 - 02:58 PM

rich, is it possible to manipulate the normal in the material def rather than making a new copy? i.e the channels can be manipulated but I dont know if it can use the result as a normal map... else this would most likely not be a viable thing on larger textures due to the size of extra normals :(


Try replacing the "map" statement in the bumpmap section with:

map scale(path/to/normal/map, 1, 1, -1, 1)

(although I haven't tested it myself).
  • nbohr1more likes this

#19 Fidcal

Fidcal

    Master Mapper

  • Development Role
  • PipPipPipPipPip
  • 16771 posts

Posted 01 August 2010 - 09:18 PM

But if the degree of translucency relies on the shade of grey you could have a real gradient transparency and hence blend a texture edge to nothing? So a grass or dirt edge model could overlay any texture in game and so provide blending? (I never give up on this holy grail :rolleyes: )

#20 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9522 posts

Posted 01 August 2010 - 09:33 PM

Can one of the textures be a "clear" alpha-test texture and therefore pass through a little real background detail? :huh:

Edited by nbohr1more, 01 August 2010 - 09:33 PM.

Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#21 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 886 posts

Posted 01 August 2010 - 10:00 PM

rich, is it possible to manipulate the normal in the material def rather than making a new copy? i.e the channels can be manipulated but I dont know if it can use the result as a normal map... else this would most likely not be a viable thing on larger textures due to the size of extra normals :(


I have a few ideas about that but I need to test them out first.

Hopefully I can get the hang of it, tho estimating depth and such for exported heightmaps/ao can be a challenge as you can no doubt see :)


Changing the depth of a normal map should be possible inside a material shader. You can probably use the addnormal keyword to blend the existing texture with a flat normal map to "smooth it out".

Try replacing the "map" statement in the bumpmap section with:

map scale(path/to/normal/map, 1, 1, -1, 1)

(although I haven't tested it myself).


That's not quite how the scale function works but it's irrelevant anyway. It's not the orientation of the image that you need to invert but rather the color represented in the blue channel.

But if the degree of translucency relies on the shade of grey you could have a real gradient transparency and hence blend a texture edge to nothing? So a grass or dirt edge model could overlay any texture in game and so provide blending? (I never give up on this holy grail :rolleyes: )


Transparency and translucency are two different things. In this specific case, we can say that the color value of vertices affects translucency but on a technical level all it's doing is specifying the influence of one set of textures in relation to another.

I don't suspect you can use vertex blending to fade a texture to nothing. You have to supply an image to each stage in the shader and if you look at the shaders for invisible materials like "nodraw" they have no stages.

No stages means you have no place to put the vertexcolor or inversevertexcolor keywords.

I do have one idea that might coax the engine into doing what you want. I'll have to test it separately and I don't think it will work but I'll get back to you.
  • nbohr1more likes this

#22 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 886 posts

Posted 02 August 2010 - 05:48 AM

Can one of the textures be a "clear" alpha-test texture and therefore pass through a little real background detail? :huh:


I just tried it and it doesn't work.

The only options you have for transparency in conjunction with illumination are to use the alphatest or translucent (badly named keyword as it makes a material 50% transparent) keywords.

Anyway, I've implemented this trick on a model ...

shot00001.jpg

And here is what it looks like in practice as viewed in the archery practice area of the training mission...

shot00003.jpg

It took a little longer than expected since I had to make a normal map. I also took the liberty of removing the shadow casting mesh.

And for those who would like to see it first hand here is everything packaged in a PK4.

Download
  • nbohr1more likes this

#23 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3580 posts

Posted 02 August 2010 - 05:50 AM

I once tried blending a texture to nothing using vertexpainting and the supposedly transparent parts ended up black.

But this looks very promising rich. I wonder whether this could be done easier and more comfortable with code support. Judging from JC's posts, it seems like we have a lot of access to how normalmaps etc are rendered. Maybe we could introduce a new shader keyword that automatically also uses the inverted z-values on materials... This way foliage etc. could be converted very quickly to use this technique.

EDIT: Love that new screen you just posted. Faked subsurface scattering. Neat!! :) Looking at that screen, I see that it would of course be better to use altered diffusemaps to generate this effect, instead of just inverting the z-values just like in my proposal.

#24 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3580 posts

Posted 02 August 2010 - 06:04 AM

Could this be used for self-lit windows? It would be awesome to see silhouettes of guards patrolling back and forth behind the windows of a mansion.

While this would work according to rich, this would also mean, that the things behind the window will have to be inside the same visportal-zone as the player (or at the very least, the portal of that zone will have to be active), which probably isn't practicable in this engine. I guess it could/should only be used selectively, say if it is important to the plot...

#25 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9522 posts

Posted 02 August 2010 - 07:32 AM

Wouldn't it be cheaper to play a video clip (forgot which format Doom 3 uses) of the guard's shadow in the window?

(Edit: ROQ video)

(Edit two: Yep a scripted GUI could even react to the guard position and play one of multiple ROQ's ... pacing back, pacing forth, idle, etc)...

(Edit: Yup, Yup, Yup)

ROQ in GUI at ModWiki

Edited by nbohr1more, 02 August 2010 - 08:14 AM.

Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users