Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


wngabh11

Member Since 19 Aug 2012
Offline Last Active Mar 06 2013 08:19 PM

Topics I've Started

Difference between two ways of assigning values to variables in HLSL constant buffer

12 February 2013 - 01:47 AM

As far as I know, There are two way passing values to variables in HLSL constant buffer.
 

 
cbuffer cbGeometryRender : register( b0 )
{
    float4x4 WorldMatrix;
    float4x4 ViewMatrix;
    float4x4 ProjMatrix;
    float4x4 WVPMatrix;
    float4x4 VPMatrix;    
    float3 EyePos;
    float3 LightDir; // start at the sun
    float4 SplitPos;
};

 

 

 
The first way is to use Effect11 Library. For example

 
ID3DX11Effect *pEffect; // initialize when compiling the fx file
ID3DX11EffectVectorVariable *pEyePos = pEffect->GetVariableByName("EyePos")->AsVector();
pEyePos->SetFloatVector(......);

 

 

 
The second way is to use the constant buffer created with the desc in the following.

 D3D11_BUFFER_DESC bd;
 bd.Usage = D3D11_USAGE_DYNAMIC;
 bd.ByteWidth = sizeof( CONSTANT_BUFFER_STRUCT );
 bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
 bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
 bd.MiscFlags = 0;
 hr = pd3dDevice->CreateBuffer( &bd, NULL, &g_pCB ); 

 

 

On each frame, we map g_pCB to b0, assign the values, and then unmap it. After that, We set constant buffer for each stage.

 

IS Anyone who know what the differences are between these two methods?

which is better?

can Effect11 Library be used with deferred context?

 

Can these two ways be used together, i.e., using Effect Library compile the fx file and using the second way to pass the value to GPU?


real and complex fog representatin

02 February 2013 - 09:07 PM

There are some easy algorithms or formulars to simulate fog effect.

such as:

 

Linear fog adds a linear amount of fog based on the distance you are viewing the object from:


    Linear Fog = (FogEnd - ViewpointDistance) / (FogEnd - FogStart)

Exponential fog adds exponentially more fog the further away an object is inside the fog:


    Exponential Fog = 1.0 / 2.71828 power (ViewpointDistance * FogDensity)

Exponential 2 fog adds even more exponential fog than the previous equation giving a very thick fog appearance:


    Exponential Fog 2 = 1.0 / 2.71828 power ((ViewpointDistance * FogDensity) * (ViewpointDistance * FogDensity))

All three equations produce a fog factor. To apply that fog factor to the model's texture and produce a final pixel color value we use the following equation:


    Fog Color = FogFactor * TextureColor + (1.0 - FogFactor) * FogColor

For this tutorial we will generate the fog factor in the vertex shader and then calculate the final fog color in the pixel shader.

 

but the effect generated is not satisfying, for i think the scattaring effects must be considered. I know some indoor single scattaring formulars, but outdoor effect are different from that indoor.

DO anyone know if there are any complex method to simulate very real fog effect or if there are any physics based equations to simulate it?

And i prefer physics method.

 

Thanks.


TXAA details

19 August 2012 - 11:02 PM

does anyone know about details of TXAA anti-aliasing or have any articles or papers of it? I've been trying to look for them, but just find some introductions and advertisement.

PARTNERS