Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1301609 Posts in 58004 Topics- by 49068 Members - Latest Member: maji

June 23, 2017, 09:14:12 am

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsFeedbackDevLogsDavy Dreams of Flying
Pages: [1]
Print
Author Topic: Davy Dreams of Flying  (Read 2983 times)
David Pittman
Level 2
**


MAEK GAEM


View Profile WWW Email
« on: December 06, 2012, 12:04:57 am »

Davy Dreams of Flying is a game poem developed in 2 short weeks.

The Announcements thread is here: http://forums.tigsource.com/index.php?topic=30314.0








« Last Edit: December 10, 2012, 11:39:04 pm by David Pittman » Logged

coupon
Level 0
**



View Profile
« Reply #1 on: December 06, 2012, 02:05:30 am »

Looks dreamlike, love the halftone patterns.
Logged
David Pittman
Level 2
**


MAEK GAEM


View Profile WWW Email
« Reply #2 on: December 10, 2012, 11:38:29 pm »

About the halftone shader:

I start with a texture with a nice gradient dots pattern:



In my vertex shader, I emit a screenspace position using the function:

Code:
return float4( 0.5f * ( float2( p.x + p.w, p.w - p.y ) ), p.zw );

There might be a simpler way to do that, but it works.

Then in the pixel shader, I use that position multiplied by a scalar to sample the dots texture. I also scale it ~115% larger on the Y axis to correct the squashing.



In the pixel shader, I compute a light value with the standard dot(N,L) function, but instead of directly multiplying the albedo color by the light, I use the light value to control the halftone map.

Essentially, I want to threshold that blurry pattern at the light value, which will give me smaller dots for brighter surfaces and larger dots for darker surfaces. The dots will represent the "inked" areas, so brighter surfaces should have smaller dots and less ink.

I use the HLSL smoothstep intrinsic to do a Hermite interpolation between values slightly greater than and less than the light value, so I get a soft blend around the dots.

For example, here's the dots clamped at a darker value:



And clamped at a higher value:



Then I lerp between the light color and the local ambient light color using this value. (Unintuitively, I've shown the dots light and the backdrop dark, but remember that the dots here represent the area where the darker halftone value is "printed," so I'm actually doing the interpolation between the lit value at 0 and the dark value at 1.)

And the result looks something like:



And that blends nicely over the surface of an object using per-pixel lighting.

Logged

coupon
Level 0
**



View Profile
« Reply #3 on: December 13, 2012, 02:19:14 am »

Cool, although I don't personally understand it, I appreciate the detailed run-down, add a bit of googlewikiing and I've learned a few things.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic