Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


Member Since 08 Apr 2011
Offline Last Active Today, 12:02 PM

Topics I've Started

sRGB on diffuse textures or gbuffer color texture?

24 August 2015 - 08:47 AM

Reading the following article: http://john-chapman-graphics.blogspot.hu/2013_01_01_archive.html


The last two paragraphs made me curious:




For a deferred renderer there is a pitfall which programmers should be aware of. If we linearize a non-linear input texture, then store the linear result in a g-buffer prior to the lighting stage we will lose all of the low-intensity precision benefits of having non-linear data in the first place. The result of this is just horrible - take a look at the low-intensity ends of the gradients in the left image below:






Clearly we need to delay the gamma correction of input textures right up until we need them to be linear. In practice this means writing non-linear texels to the g-buffer, then gamma correcting the g-buffer as it is read at the lighting stage. As before, the driver can do the work for us by using an sRGB format for the appropriate g-buffer targets, or correcting them manually.



From all the other resources I've read you should declare your input diffuse textures as *_SRGB and your gbuffer color texture as non-SRGB which is contradictory to this. 


Which is correct? Should the diffuse textures be sRGB or the gbuffer color texture be sRGB (effectively delaying the conversion untill sampling it in the lighting stage)?

Normal offsets in view space?

31 July 2015 - 09:44 AM

I'm trying to apply normal offsets as per http://www.dissidentlogic.com/old/images/NormalOffsetShadows/GDC_Poster_NormalOffset.png


I'm working in view space though and the offsets causes the shadows to slightly move around as the camera moves.

static const float gNormalOffset = 4.5;
static const float gBias = 1;

float3 ShadowAcneNormalOffset(in float3 normal, in float normalLightAngle, in float shadowmapSize)
    const float texelSize = 2.0 / shadowmapSize;
    const float normalOffsetScale = saturate(1.0 - normalLightAngle);

    float3 ret = normal * gNormalOffset * normalOffsetScale * texelSize;
    ret.z += texelSize * gBias;

    return ret;

viewPosition.xyz += ShadowAcneNormalOffset(viewNormal, normalLightAngle, gShadowmapSize);

Both the position and normals are in view space. Does this impact the alghorithm at all?

Rasterizer depth configuration for shadowmapping

14 July 2015 - 08:03 AM

Is there a set of universally-applicable constant values for the rasterizers SlopeScaledDepthBias and DepthBias? I realize this depends on the geometry in the scene but if there's a "standard" set of values that works in most scenarios I'd love to see them.



Simulating the sun

08 July 2015 - 07:55 AM

I'm trying to use a directional light to mimic the sun.


I've been looking around to find some info on how to simulate the sun using an initial light direction and then apply some rotation along some axis over time but I havn't found any useful information and yet surely this must be a recurring issue in game development. Any tips to achieve this?

GenerateMipmaps and staging textures

26 June 2015 - 11:45 AM

Here's what I'm trying to do:

  1. Create a temporary staging texture (D3D11_USAGE_STAGING)
  2. Fill staging texture with mip 0-level texture data only
  3. GenerateMipmaps on staging texture
  4. Readback the now fully mipmapped texture data
  5. Create a new static texture (D3D11_USAGE_IMMUTABLE) using above data

So in summary use an intermediate texture to generate all the mip data for a static texture.


It dosn't seem to be possible though. Textures with D3D11_USAGE_STAGING cannot have any BindFlags specified, but a texture must have bindflag D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE in order generate mipmaps.


Is there any other way to accomplish this? Can the mipmap generation be done on CPU only - if so, how?