• 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
ankhd

Blending Problem to a rendertarget or something else?

5 posts in this topic

Hi all.

 

I refactored my rendering system to render the scene to a render target so I can do bloom, This all works fine.

 

This is what steps I do, First render all objects to off screen render target, then render bloom objects to there render target

Then the two rendered targets are blended to the final image. This all works.

 

The problem is when I use the final render target to render a blened quad on the screen it makes all the rendered object

turn blue and leaves the background the same and blends with it only,

 

here is the image of the final scene with the quad and the blue mesh.

 

I've set the blend state and the depth and nothing changes. The thing is this all worked Until I used a offscreen renderTarget.

 

Any Ideas on what it could be.

 

Image

BlendingGoneBad.jpg?psid=1

0

Share this post


Link to post
Share on other sites

Can you provide some source code? Are you able to narrow down the problem? Ie. disable parts of the code until you can confirm that the program works as intended.

 

Cheers!

0

Share this post


Link to post
Share on other sites

I turned of bloom and I am rendering to the render target the terrain and I'm still getting the terrain turning blue.

 

so it the same as my other terrain app but im using the new render to texture.

 

Wonder if its got something to do with the fullscreen quad that gets the scene texture applied to it.

the main render target gets a NDC space quad rendered to it then the blened rectangle.

does the NDC quad kill the depth.

 

//my blend state is this.

D3D10_BLEND_DESC blendDesc = {0};
	blendDesc.AlphaToCoverageEnable = false;
	blendDesc.BlendEnable[0] = true;
	blendDesc.SrcBlend       = D3D10_BLEND_SRC_ALPHA;
	blendDesc.DestBlend      = D3D10_BLEND_INV_SRC_ALPHA;
	blendDesc.BlendOp        = D3D10_BLEND_OP_ADD;
	blendDesc.SrcBlendAlpha  = D3D10_BLEND_ONE;
	blendDesc.DestBlendAlpha = D3D10_BLEND_ONE;//D3D10_BLEND_ZERO;
	blendDesc.BlendOpAlpha   = D3D10_BLEND_OP_ADD;
	blendDesc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;

DepthStencil

 // Create depth stencil texture
    D3D10_TEXTURE2D_DESC descDepth;
    descDepth.Width = width;
    descDepth.Height = height;
    descDepth.MipLevels = 1;
    descDepth.ArraySize = 1;
    descDepth.Format = DXGI_FORMAT_D32_FLOAT;
    descDepth.SampleDesc.Count = MultiSampleAmount;
    descDepth.SampleDesc.Quality = MultiSampleQuality;
    descDepth.Usage = D3D10_USAGE_DEFAULT;
    descDepth.BindFlags = D3D10_BIND_DEPTH_STENCIL;
    descDepth.CPUAccessFlags = 0;
    descDepth.MiscFlags = 0;

before rendering the quad

Device->OMSetRenderTargets( 1, &m_pRenderTargetView, m_pDepthStencilView );

 

//clear the backbuffer

 

float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha

Device->ClearRenderTargetView( m_pRenderTargetView, ClearColor );

 

 

// Clear the depth buffer to 1.0 (max depth)

Device->ClearDepthStencilView(m_pDepthStencilView, D3D10_CLEAR_DEPTH, 1.0f, 0 );

 

 

StencilRef = 1;

Device->OMSetDepthStencilState(m_DepthStencilState, m_StencilRef);

//add blending

 

float blendfactor[] = {0.5f, 0.5f, 0.5f, 1.0f};

Device->OMSetBlendState(mTransparentBS, blendfactor, 0xffffffff);

 

 

RenderFullScreenQuad(resourceviewfromscene);

 

shader used to render the fullscreen quad


The quad vertices are
// given in NDC space.
//=============================================================================
 
Texture2D gMap;

 

cbuffer cbPerFrame

 float gUseColour = 0.0;//render black and white default

};

 

SamplerState gTriLinearSam
{
 Filter = MIN_MAG_MIP_LINEAR;
 AddressU = Wrap;
 AddressV = Wrap;
};

struct VS_IN
{
 float3 posL : POSITION;
 float2 texC : TEXCOORD;
};

struct VS_OUT
{
 float4 posH : SV_POSITION;
 float2 texC : TEXCOORD;
};
 
VS_OUT VS(VS_IN vIn)
{
 VS_OUT vOut;

 vOut.posH = float4(vIn.posL, 1.0f);
 
 vOut.texC = vIn.texC;
 
 return vOut;
}

float4 PS(VS_OUT pIn) : SV_Target
{
if(gUseColour == 0.0)
{
 float r = gMap.Sample(gTriLinearSam, pIn.texC).r;
 
 // draw as grayscale
 return float4(r,r,r,1);
}
else
{
float4 colour = gMap.Sample(gTriLinearSam, pIn.texC);
 
 // draw as colour
 return colour ;
}

}
 
technique10 DrawMapTech
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
    }
}

 

//the shader for the blended rectangle parts


//color map texture
//Texture2D colorMap;
DepthStencilState DisableDepth
{
    DepthEnable = FALSE;
    DepthWriteMask = ZERO;
};

DepthStencilState NoDepthWrites
{
    DepthEnable = TRUE;
    DepthWriteMask = ZERO;
};

//texture sampler state
//SamplerState linearSampler
//{
 //   Filter = min_mag_mip_linear;
 //   AddressU = Clamp;
//    AddressV = Clamp;
 //   MaxAnisotropy = 16;
//};

//blend state
BlendState SrcAlphaBlendingAdd
{
 BlendEnable[0] = TRUE;
 SrcBlend = SRC_ALPHA;
 DestBlend = INV_SRC_ALPHA;
 BlendOp = ADD;
 SrcBlendAlpha = ZERO;
 DestBlendAlpha = ZERO;
 BlendOpAlpha = ADD;
 RenderTargetWriteMask[0] = 0x0F;

 

/--------------------------------------------------------------------------------------
// Techniques
//--------------------------------------------------------------------------------------
technique10 RENDER
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( CompileShader( gs_4_0, GS() ) );  
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
        SetBlendState( SrcAlphaBlendingAdd, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
    }   
    pass P1
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( CompileShader( gs_4_0, GSPass2() ) );  
        SetPixelShader( CompileShader( ps_4_0, PSPass2() ) );
        //SetBlendState( SrcAlphaBlendingAdd, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
         // we must also disable the depth buffer for stream-out only
        SetDepthStencilState( DisableDepth, 0 );
    }   
}

0

Share this post


Link to post
Share on other sites

sorry for the above that code was pasted in a code block.

 

I notice if I change the colour of the clear screen the terrain is change to the clear colour what does that mean ?????.

0

Share this post


Link to post
Share on other sites

Ok found the problem.

 

it was in the full screen quad shader the colour value in the pixel shaders alpha value had some value???. I set it

colour.a = 1.0; and It all worked.

1

Share this post


Link to post
Share on other sites

 Well I'm happy that you resolved the problem by yourself :)

 

Cheers!

1

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