Jump to content
  • Advertisement

Michael McLafferty

  • Content Count

  • Joined

  • Last visited

Community Reputation

105 Neutral

About Michael McLafferty

  • Rank
  1. Michael McLafferty

    Down/Up scaling struggles

    Here is an image of the banding issue. The noise you see as the N dot L gets closer to 0 is caused by the best fit normals. I am not sure what I am doing wrong there, but I tried using a different normal storage technique and it did not affect the banding at all, so best fit normals is not causing this issue.
  2. Michael McLafferty

    Down/Up scaling struggles

    I am using HdrBlendable for my lighting buffer which on windows is 16bits per channel. I am also just using a single light with a color of white (255,255,255) for this test scenario, so in reality there shouldn't be any banding at all. I'd post a screenshot if I could figure out how to attach an image. I thought gamedev support uploading images do your profile's gallery, but I guess not.
  3. Michael McLafferty

    Down/Up scaling struggles

    Got some more time to look at this issue. It turns out it has nothing to do with my post processing framework. The issue was just exacerbated by the exposure adjustments. The issue is in my lighting buffer. Simply outputting n dot l causes a faint banding. Even more annoying is the banding becomes animated with the adapted luminance. So frustrating, I still don't know what is causing this.
  4. Michael McLafferty

    Down/Up scaling struggles

    Actually, it turns out it is not the down sampling. It is something with how I calculate my exposed color. I've narrowed it down to this code: float3 CalcExposedColor(float3 color, float avgLuminance, float threshold) { // Use geometric mean to dynamically determine middle gray value. avgLuminance = max(avgLuminance, 0.001f); float middleGray = 1.03f - (2.0f / (2.0f + log10(avgLuminance + 1.0f))); float linearExposure = (middleGray / avgLuminance); float exposure = log2(max(linearExposure, 0.0001f)); exposure -= threshold; return max(exp2(exposure) * color, 0.0f); } This is using some suggestions that MJP has recommended on this post: http://www.gamedev.net/topic/588388-glarebloom-effect-what-you-use/ I call that function and pass the result to a filmic tone mapping function. float3 ToneMapFilmic(float3 color) { color = max(0, color - 0.004f); color = (color * (6.2f * color + 0.5f)) / (color * (6.2f * color + 1.7f)+ 0.06f); // Result above is in gamma space since it is baked into the equation, // so put it back in linear space. return pow(color, 2.2f); } The bright pass is done as follows: float4 BrightPassPS( in float2 vTexCoord : TexCoord0 ) : COLOR0 { float4 vSample = tex2D( PointSampler, vTexCoord ); float fAdaptedLum = tex2D( AdaptedPointSampler, float2(0.5f, 0.5f) ).r; float3 vColor = CalcExposedColor(vSample.rgb, fAdaptedLum, g_BrightPassThreshold); vColor = ToneMapFilmic(vColor); return float4( vColor, 1.0f ); } I'll keep digging but any suggestions are welcome.
  5. Michael McLafferty

    Down/Up scaling struggles

    Hi All. I am struggling to get my downscaling/upscaling working correctly. I have significant banding happening on my bloom source. I believe this to be related to my 4x4 downsampling. I am using XNA and have corrected my half pixel issue by offsetting my position coordinates using the following code: position.x = position.x - g_ClipSpaceHalfPixel.x; position.y = position.y + g_ClipSpaceHalfPixel.y; position.z = position.z; position.w = 1.0f; g_ClipSpaceHalfPixel is calculated by dividing 1.0f by the target rendertarget width and height. My downscaling pixel shader looks like so: float4 SWScalingPS( in float2 texCoord : TEXCOORD0 ) : COLOR0 { float4 fSampleSum = 0.0f; for(int iSample = 0; iSample < 16; iSample++) { fSampleSum += tex2D(PointSampler, texCoord + g_SampleOffsets[iSample]); } // Divide the sum to complete the average return (fSampleSum / 16); } My offset generation code looks like the below. Also, i pass in the source render target dimensions as the parameters. private Vector2[] Get4x4Offsets( int iWidth, int iHeight ) { // Use the multiplicative inverse instead of dividing each // offset by the Width and Height. float fU = 1.0f / iWidth; float fV = 1.0f / iHeight; Vector2[] offsets = new Vector2[16]; int index = 0; for( int y = 0; y < 4; ++y ) { for( int x = 0; x < 4; ++x ) { offsets[index].X = ( x - 1.5f) * fU; offsets[index].Y = ( y - 1.5f ) * fV; ++index; } } return offsets; } Because my texels and pixels are aligned, I still need to apply a .5 offset to get the texel center, right? I figured that is the case and that is why I am using x -1.5f since I am using Point sampling and not Linear sampling. However, I have also tried it using x - 1.0f and that did not seem to make any difference at all. Any help would be much appreciated. Thanks in advanced.
  6. Michael McLafferty

    Deferred Lighting + Fresnel

    I have yet to test the built in Predicated Tiling on XNA, so I cannot say how well it works with regards to performance. I currently do not hold a Creators Club membership and have mostly been designing based on knowledge i've read around in the web. I will probably create another renderer that does the fat-g buffer and see if I can measure the performance penalties of perdicated tiling. Worst case, I use the NdotV approach for Xbox with deferred lighting and a fat g-buffer on the PC. Or, if predicated tiling does not seem to be an issue then I will just stick with a fat g-buffer. Thanks for posting the shader code, it is kinda interesting that they are reading it from a texture as it would seem like it would only support dielectric materials. Is the texture monochromatic?
  7. Michael McLafferty

    Deferred Lighting + Fresnel

    Thanks for the reply. You are correct, by deferred lighting I am referring to what is also called "Light Pre Pass". The same thing Wolf has posted on his blog as well as the technique Uncharted and CryEngine 3 is using. Uncharted applied the fake Fresnel effect using N dot V, and it sounds like the CryEngine 3 did something on the CPU to supply a L.H value to the second forward pass. Not exactly sure what they did there. The main reason why I chose it was because I would like to get it running on the xbox 360 with decent performance. The traditional deferred rendering with the fat g-buffer will be problematic at higher resolutions on the xbox-360 due to the 10mb EDRAM. Of course, the way people have worked around that is to split the screen in half and render in two passes. I was hoping to avoid that.
  8. Michael McLafferty

    Deferred Lighting + Fresnel

    Hello All. I have been attempting to create more physically correct rendering pipeline. It uses deferred lighting and a normalized blinn-phong. I have come to a stumbling block when attempting to imeplement the Fresnel effect using Shlick's approximation. I do not want to fake it by using N dot V in the second forward pass. So far my render targets look like the following: Depth + A: Nothing stored in alpha yet. RGBA8 - Best Fit Normals in RGB and monochrome gloss map value stored in A, which is used for specular power. I am using a 16bit floating point per channel render target for my light accumulation buffer since I could not find a decent storage method to use with an 8bit per channel one. All that I could find info on required swapping rendering targets back and forth when you have overlapping lights, which doesn't seem like a good idea performance wise (not tested though). My first thought was to create a lookup map for specular color. I could store 256 common specular colors within this lookup and store the index into the Depth render targets alpha channel. I could then lookup the color during the light accumulation phase and output the accumulated specular color to yet another render target. This would require another large render target to support HDR values, much like my light accumulation target. I noticed in Tri-Ace's 2012 GDC slides, they use Deferred Lighting with FresnelShlick but they didn't go into much detail on how they accomplished it in the lighting phase. Does anyone have any brilliant ideas on how I might accomplish this or is my current idea sufficient for a decent range of materials. Thanks in advanced, -Mike
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!