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.

Author
Message
puppysss
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 19th Aug 2010 04:24 Edited at: 19th Aug 2010 04:37
Howdy! I have coded deferred shading.
I know it.
1. Bring a Main Scene From Main Camera
2. Draw Depth Map Of Main Scene ( Black & White Fog )
3. Draw Normal Map
4. Draw Light Map
5. Multiple Maps
6. Output Multipled Scene To Quad
Also I know shadow map.
1. Put Camera To Light Position
2. Bring a Camera Scene And Draw Depth Map ( Same Above )
3. Project Depth Map
4. Draw Depth Map To Object Texture

But I really don't know how to draw shadow map in deferred shading.
I really wanna get some advises with tips


[Plus]
- Diffuse -

- Depth -

- Normal -

- Light-


Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 19th Aug 2010 13:15
You could try asking Evolved. His web site is www.evolved-software.com

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Aug 2010 15:05
Or you could look at my shadow mapping demo on the "Learning to write shaders" sticky thread. It was posted around 23 October 2009.
puppysss
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 19th Aug 2010 18:26
@baxslash
oh! thanks for your tips!

@Green Gandalf
wow! I just ran your code!
it's very cool!
but could it manufacture shadows in many lights?
if it can , what does it use the way?


Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Aug 2010 19:23
Quote: "but could it manufacture shadows in many lights?"


No. It would need many changes to the code and would have a big effect on performance.
puppysss
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 20th Aug 2010 05:35
Your code is very cool!

Umm... So Could it run well ?(under process)


[process]
for all of light camera
{
- Bring light camera scene for shadow [depth mapped]
- Accrue it
}
- Draw accrued texture to object
(use 2d or 3d texture)

Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Aug 2010 11:38
You might be able to do it that way. I hadn't thought of that. Thanks for the suggestion.
puppysss
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 20th Aug 2010 14:03
I also thank your helps!
Umm... I saw 3d texture. It was veeeerrrry odd ...
but I just noticed that many engine of well-known fps games used 3d texture.


Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 26th Aug 2010 01:26
Hey Green Gandalf, I saw your example (on pg. 42 of the Learning To Write Shaders thread) and I think it's amazing . So I decided to have a look through the FX code. A lot of it is still over my head, but I was wondering what this meant:



Is that last part
a boolean, like an if statement of some sort? What is the syntax for that? What is that line of code doing?

Also, why are a lot of the values inverted?


Guns, cinematics, stealth, items and more!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Aug 2010 02:10
Quote: "like an if statement of some sort?"


Yes, it's equivalent to the following DBPro syntax:



Loosely, it's testing whether the rendered pixel is in shadow or not. If I recall correctly, In.depth contains the distance of the current pixel from the light whereas the tex2Dproj() bit is the distance of the corresponding lit pixel recorded in the depth map. In other words if the current pixel is further away than the lit pixel (in the same projected position in the depth map) then the current pixel must be in shadow. As you say, that code seems inverted - it would be more readable if I'd called the variable "lit" rather than "shadow", i.e. when shadow = 0 the lighting is zero and when "shadow" is 1 the pixel receives full light, i.e. not in shadow.

Hope that makes sense.
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 26th Aug 2010 04:53
Ah, got it. Thanks . By inverted I didn't mean the variable name though, I meant the light range . I thought there were others besides that one that were also inverted but I may be mixing your shader up with another.


Guns, cinematics, stealth, items and more!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Aug 2010 13:07 Edited at: 26th Aug 2010 13:08
Quote: "I meant the light range"


Which bit of the code exactly?

Quote: "I thought there were others besides that one that were also inverted but I may be mixing your shader up with another."


I know the feeling - I have enough trouble keeping track of my own with all their revisions and reincarnations.

Glad you got it sorted anyway - but you asked about the syntax of the ?: operator. It forms an expression and takes three arguments as follows:



so in the example we had



I believe the result arguments can be any valid type, i.e. floats, float4's, etc.

Edit

puppysss Apologies for hijacking your thread.
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 26th Aug 2010 15:10 Edited at: 26th Aug 2010 15:11
Thanks for explaining that

Quote: "Which bit of the code exactly? "


Ah, they were in the DBP code. Maybe I should have said reciprocal instead :





I also found them in the FX file:







The reasoning behind it is probably beyond me at this point though

@puppyss: If you have another question then I'll stop asking mine


Guns, cinematics, stealth, items and more!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Aug 2010 15:26
Quote: "The reasoning behind it is probably beyond me at this point though"




It's very simple.

I usually use multiplication rather than division if I have a choice - especially for something that's likely to be used millions of times per second, e.g. *0.002 rather than /500.0, as in a shader light attenuation calculation.

Of course, if a pre-shader calculates the reciprocal beforehand then there might not be a performance gain.
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 26th Aug 2010 15:44
Ah, I see. Thanks

Quote: "as in a shader light attenuation calculation."


That leads me to another question... and I apologize again for having so many in someone else's thread... Should I make my own thread? And thanks for answering them all GG!

Anyway, my question is: What is the most basic equation for positional lighting? I've tried to find a shader with just per-pixel diffuse lighting but all I can find is normal mapping with those confusing tangent binormals . Where can I find a simple shader that works in DBPro with 1 positional point light that takes into account the light range, color and ambient color?


Guns, cinematics, stealth, items and more!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Aug 2010 16:01
Quote: "That leads me to another question... and I apologize again for having so many in someone else's thread... Should I make my own thread?"


Wouldn't the Learning to write shaders sticky thread be the obvious place for these sorts of questions?

Quote: "Where can I find a simple shader that works in DBPro with 1 positional point light that takes into account the light range, color and ambient color?"


On the above mentioned thread if you wait for me to have my lunch - a couple of hours time say?
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 26th Aug 2010 16:04 Edited at: 26th Aug 2010 17:56
Quote: "Wouldn't the Learning to write shaders sticky thread be the obvious place for these sorts of questions?
"


Oh, right .

Quote: "On the above mentioned thread if you wait for me to have my lunch - a couple of hours time say? "

Thanks. Take your time, I'll watch for your post


Guns, cinematics, stealth, items and more!

Login to post a reply

Server time is: 2026-07-23 12:10:43
Your offset time is: 2026-07-23 12:10:43