• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
CC Ricers

Color pixels are being clipped at a different depth in GBuffer

4 posts in this topic

I have a GBuffer shader in use with XNA to produce a typical output of diffuse/albedo, depth and normals. As all the vertex buffers are being batched and sent through with the same world, view and projection matrices for all render targets at once (and have no masked textures), I expected that they will all cover the same screen area for each render target. But the diffuse color component of the GBuffer appears to have the geometry cut off at a somewhat closer distance than the far clip plane of the camera.

 

When combined with the lighting, terrain at far distances has a transparent "trim" where you can see the lighting of the terrain, but not its color, so it shows the color of the background, skybox, etc behind it. So the depth and normal values are rendered at that distance, but not the diffuse color values. Indeed, I debug the render targets on PIX and in my program and there are less pixels being drawn to the diffuse component, as if it had its own far clipping value. I will post a screenshot of the problem later, until there here is my pixel shader GBuffer code.

 

struct VertexShaderOutput
{
   float4 Position : POSITION0;
   float2 TexCoord : TEXCOORD0;
   float3 Depth : TEXCOORD1;
   float3x3 TangentToWorld : TEXCOORD2;
};

struct PixelShaderOutput
{
   half4 Color : COLOR0;
   half4 Normal : COLOR1;
   half4 Depth : COLOR2;
};

// First, relevant depth output code in the vertex shader
// wvp is the product of World, View and Projection matrices

    output.Position = mul(input.Position, wvp);

    output.Depth.x = output.Position.z;
    output.Depth.y = output.Position.w;

// Complete GBuffer pixel shader

PixelShaderOutput PixelShaderGBuffer(VertexShaderOutput input)
{
    PixelShaderOutput output;

    // First check if this pixel is opaque
    //output Color
    output.Color = tex2D(diffuseSampler, input.TexCoord);
    clip(output.Color.a - 0.5);

    // Output the normal, in [0,1] space
    float3 normalFromMap = tex2D(normalMapSampler, input.TexCoord);

    normalFromMap = mul(normalFromMap, input.TangentToWorld);    
    output.Normal.rgb = 0.5f * (normalize(normalFromMap) + 1.0f);

    // Output specular intensity
    float4 specularAttributes = tex2D(specularSampler, input.TexCoord);
    output.Normal.a = specularAttributes.r; //specularIntensity;

    // Output Depth
    output.Depth = input.Depth.x / input.Depth.y;  

   return output;
}

 

In this shader, the only pixels that I am clipping are the diffuse color texture, if the alpha value is less than 0.5. But this probably is not setting faraway pixels from being clipped, I hope.

0

Share this post


Link to post
Share on other sites
It sounds like you might have alpha blending on (so the pixels with alpha > 0.5 end up being drawn, and you can still see the background through them). Turn it off for rendering to your G-buffer.
(if that's not the problem, perhaps you're using multisampling?)
0

Share this post


Link to post
Share on other sites

I removed the line with the alpha clipping- it was a leftover from a non-terrain shader and don't really needed it for terrain anyways. I still don't see a difference in the visuals, though. The diffuse color buffer still stops drawing at a slightly closer distance. Here is a screenshot showing the problem:

 

dpyesdI.jpg

0

Share this post


Link to post
Share on other sites
The screenshot looks like it's after the final lighting pass. What do the individual buffers in the G buffer look like?
And you're sure alpha blending is off? Edited by phil_t
0

Share this post


Link to post
Share on other sites

In the individual buffers, the normal buffer and depth buffer both show the whole mountain, and in the diffuse color buffer, the mountain appears partly cut off, leaving that empty space that you see.

 

Right before I draw to the GBuffer, I clear the screen to black, set DepthStencilState to Default and BlendState to opaque. Then, to prepare it with default values, I fill the color buffer with black pixels, the normal buffer with gray, and depth buffer with white. Additive, not alpha, blending is used for the lighting pass, but I don't see how that would have any effect since the GBuffer is already created at that stage.

 

UPDATE: I just realized what it was. I was going to post a screenshot showing the individual buffers and also removed the skybox from the scene for visual clarity. After removing the skybox, I realized that the colors were being rendered correctly and nothing was clipped off prematurely. It seems that, although I put a restriction to render the skybox in its own depth range, I still needed to scale the skybox by a reasonable amount, or else it would cut into the scenery. So I changed the scaling amount from 20 to 200 and the colors aren't cut off anymore! And the skybox still appears the same size due to perspective.

Edited by CC Ricers
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0