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.


Dissipate

Member Since 31 Oct 2012
Offline Last Active Nov 20 2014 10:44 AM

Topics I've Started

Bizarre Quad's Triangles but a Cube is ok

04 November 2014 - 11:47 AM

Hi,
 
I am having problems drawing a quad of triangles. I am specifying the front and back of them and texture coordinates, no lighting yet. Please can you check that I am doing this correctly because it worked for my cubes that I rendered. I am getting mangled triangles. (I moved the cube back off 0,0,0).

 

 http://2014_11_04_165240.jpg

Notice below I am using an XMFLOAT3 in my program struct but a float4 Pos : POSITION; as my hlsl 'vertex in'. Is that a problem? It seems to work in the tutorial. I have tried also to have struct as XMFLOAT4 and Input Element Description as DXGI_FORMAT_R32G32B32A32_FLOAT and specify a 'w' component to experiment. But it created a quad that had one side near zero and the other stretching off into infinity. (cube at 0,0,0)
 
http://2014_11_04_170453.jpg 
 

struct stVERTEX_POS_TEX
{
    DirectX::XMFLOAT3 f3Pos;
    DirectX::XMFLOAT2 f2Tex;
};
const D3D11_INPUT_ELEMENT_DESC stPosTexIED[2] =
{
    {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
    {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT,    0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}
};
// Shader.h

#pragma pack_matrix(row_major)

#define FLIP_TEXTURE_Y 0

///////////////////////////////
// Constant Buffer Variables
///////////////////////////////
Texture2D txDiffuse    : register(t0);

SamplerState samLinear : register(s0);

cbuffer cbNeverChanges : register(b0)
{
    matrix xmView;
};

cbuffer cbOnResize     : register(b1)
{
    matrix xmProjection;
};

cbuffer cbEveryFrame   : register(b2)
{
    matrix xmWorld;
    float4 f4MeshColor;
};


/////////////////////
// Data Structures
/////////////////////
struct VS_INPUT
{
    float4 Pos : POSITION;
    float2 Tex : TEXCOORD0;
};

struct PS_INPUT
{
    float4 Pos : SV_POSITION;
    float2 Tex : TEXCOORD0;
};


/////////////////////
// Utility Functions
/////////////////////
float2 Get_Corrected_Texture_Coordinate(float2 f2TexCoord)
{
    #if FLIP_TEXTURE_Y
        return float2(f2TexCoord.x, 1.0 - f2TexCoord.y);
    #else
        return f2TexCoord;
    #endif
}
// Shader_VS.hlsl

#include "TextureMapping.h"


//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
PS_INPUT VS(VS_INPUT input)
{
    PS_INPUT output = (PS_INPUT)0;

    output.Pos = mul(input.Pos,  xmWorld);
    output.Pos = mul(output.Pos, xmView);
    output.Pos = mul(output.Pos, xmProjection);

    output.Tex = input.Tex;
    
    return output;
}
// Shader_PS.hlsl

#include "TextureMapping.h"


//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( PS_INPUT input) : SV_Target
{
    return txDiffuse.Sample( samLinear, input.Tex ) * f4MeshColor;
}

Below is the current situation:

http://radiate.vidmeup.com/view?q=54590fcbd11d4.flv

 

Below is when using XMFloat4 in struct

http://radiate.vidmeup.com/view?q=54590fcbd11d4.flv

 

*EDIT embedding video doesn't work


Should I try to optimise the World matrix build like this?

16 October 2014 - 02:41 PM

Hi all,

 

It seems a bit wastful to do this for every object in the application:

m_xmWorld = m_xmScale * m_xmSpin * m_xmTranslate * m_xmOrbit;

Especially if it isn't even scaling that particular frame. Or even spinning that particular frame. So my question is... is the following an optimisation? I'm trying to avoid unnecessary matrix multiplication:

// All booleans set to false each frame
// Then certain booleans set to true dependant on characteristics of movement during ::Update()

if (m_bScaling)
    m_xmWorld *= m_xmScale;

if (m_bSpinning)
    m_xmWorld *= m_xmSpin;

if (m_bTranslating)
    m_xmWorld *= m_xmTranslate;

if (m_bOrbiting)
    m_xmWorld *= m_xmOrbit;

Or are the first example's multiplications so over-optimisidly-fast that it would make no difference? Are there any problems with this idea?

 

Thanks smile.png


Problems trying to create custom shader w/XTK

23 August 2014 - 12:23 PM

Hi,

 

May I ask for your help with this issue please... (its an easy one)

 

Using: Win7, VS2012, DirectXTK

 

Error:

D3D11 ERROR: ID3D11Device::CreateInputLayout: The provided input signature expects to read an element with SemanticName/Index: 'NORMAL'/0, but the declaration doesn't provide a matching name. [ STATE_CREATION ERROR #163: CREATEINPUTLAYOUT_MISSINGELEMENT]
 

Ok I know that the NORMAL0 is supposed to be in the D3D11_INPUT_ELEMENT_DESC I am creating a custom shader and passing my own compiled shader in. Somehow the EffectFactory is overwriting the Input Element Description with its own shader description!?! Possibley from XTK/Src/VertexTypes.h. Would you kindly show me the correct way of using my own shader with DirectXTK. The Documentation is usless.

 

Question (also): How do you access the constant buffers then. To communicate with the shader?

 

Please see if I am doing this right? Also how do you access the constant buffers from the IEffect. Or do you reinterpret_cast it to DGSLEffect? ...maybe like:

m_spDGSLEffect.reset(reinterpret_cast<DGSLEffect*>(m_spEffect.get())); // ??

I have traced that it is through the DGSLEffectFactory's constructor that it creates the Pixel Shader (...::pImpl::CreatePixelShader(...)). There's so much of the private implementation that i can't touch - gonna have to augment the code with my own methods.

 

Here are fragments of my code from the knowledge I've managed to glean after weeks/months:

DGSLEffectFactory::DGSLEffectInfo info;
info.name = L"main";
info.alpha = 1.0f;
info.ambientColor = XMFLOAT3( 0.2f, 0.2f, 0.2f);
info.diffuseColor = XMFLOAT3( 0.8f, 0.8f, 0.8f );
info.pixelShader = L"VertexShader.cso";

std::unique_ptr<DGSLEffectFactory> m_spDGSLEffectFactory; // In header
std::unique_ptr<IEffect>           m_spEffect;            // In header

m_spDGSLEffectFactory.reset(new DGSLEffectFactory(g_pD3DObj->m_spD3DDevice.Get()));
m_spDGSLEffectFactory->SetDirectory(L"H:/Code/_PROGS/DXTB/x64/Debug");

m_spEffect = m_spDGSLEffectFactory->CreateDGSLEffect(info, g_pD3DObj->m_spD3DImmediateContext.Get());

D3D11_INPUT_ELEMENT_DESC stVertexDesc[] =
	{
		{"SV_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
		{"COLOR",       0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
		{"TEXCOORD",    0, DXGI_FORMAT_R32G32_FLOAT,       0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
		{"TEXCOORD",    1, DXGI_FORMAT_R32G32B32_FLOAT,    0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
		{"TEXCOORD",    2, DXGI_FORMAT_R32G32B32_FLOAT,    0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
		{"TEXCOORD",    3, DXGI_FORMAT_R32G32B32_FLOAT,    0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
		{"TEXCOORD",    4, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
		{"TEXCOORD",    5, DXGI_FORMAT_R32G32B32_FLOAT,    0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}
	};

	void const* pByte;
	size_t  Size = 0;
	m_spEffect->GetVertexShaderBytecode(&pByte, &Size);

	HR(g_pD3DObj->m_spD3DDevice->CreateInputLayout(stVertexDesc, 2, pByte, Size, &m_pInputLayout));

I have asked so much and would be deeply and graciously gratified with your suggestions.


Shader Designer Fonts all Jiggled Up. VS2012 Corruption?

19 August 2014 - 09:20 AM

Hi all,

 

I didn't really know under which heading to post this.

In DGSL Shader Designer; starting it up produced this picture:

Attached File  Visual Studio Shader Designer Window.png   10.89KB   0 downloads

 

Why are the fonts all messed up? Is it supposed to be like this? What do I need to do to rectify it? I have tried turning it off and on again :P I hope I dont have to do a VS->Repair.

 

I greatly appreciate your responses.


Pls suggest debugging t'kniques for why I can't display a cube

09 August 2014 - 04:34 PM

Hi All,

 

I am working through some examples in DirectX11 Frank D Luna on displaying a cube (His works mine doesn't) all mine displays is a blue window. I have studied the code incrementally, that I refactored in a more OO way, and have learned a lot. I'm sure I have done everything the way the tutorial suggests but I am unable to display the cube and he is!

 

I use a CGeometryBox object that I have encapsulated the box creation into. I check all the HRESULTs and assert(xxxx.IsValid) where neccessary. I don't know whether I should upload the project files! I'm very at a loss and I've solved all the other problems I've had.

 

Here is the DirectX Debug output:

*snip*
D3D11 INFO: Create ID3D11Context: Name="unnamed", Addr=0x0000000000453120, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097225: CREATE_CONTEXT]
D3D11 INFO: Create ID3DDeviceContextState: Name="unnamed", Addr=0x000000000046F0A0, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #3145735: CREATE_DEVICECONTEXTSTATE]
D3D11 INFO: Create ID3D11BlendState: Name="unnamed", Addr=0x000000000047A790, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097270: CREATE_BLENDSTATE]
D3D11 INFO: Create ID3D11DepthStencilState: Name="unnamed", Addr=0x000000000047A960, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097273: CREATE_DEPTHSTENCILSTATE]
D3D11 INFO: Create ID3D11RasterizerState: Name="unnamed", Addr=0x000000000047AB30, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097276: CREATE_RASTERIZERSTATE]
D3D11 INFO: Create ID3D11Sampler: Name="unnamed", Addr=0x000000000047AE00, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097267: CREATE_SAMPLER]
D3D11 INFO: Create ID3D11Query: Name="unnamed", Addr=0x000000000047B020, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097279: CREATE_QUERY]
D3D11 INFO: Create ID3D11Texture2D: Name="unnamed", Addr=0x000000000047BA70, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097234: CREATE_TEXTURE2D]
D3D11 INFO: Destroy ID3D11Texture2D: Name="unnamed", Addr=0x000000000047BA70 [ STATE_CREATION INFO #2097236: DESTROY_TEXTURE2D]
D3D11 INFO: Create ID3D11Texture2D: Name="unnamed", Addr=0x000000000047BA70, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097234: CREATE_TEXTURE2D]
D3D11 INFO: Create ID3D11RenderTargetView: Name="unnamed", Addr=0x000000000047C0D0, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097243: CREATE_RENDERTARGETVIEW]
D3D11 INFO: Create ID3D11Texture2D: Name="unnamed", Addr=0x000000000047C4D0, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097234: CREATE_TEXTURE2D]
D3D11 INFO: Create ID3D11DepthStencilView: Name="unnamed", Addr=0x000000000047C910, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097246: CREATE_DEPTHSTENCILVIEW]
D3D11 INFO: Create ID3D11Buffer: Name="unnamed", Addr=0x000000000048A130, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097228: CREATE_BUFFER]
D3D11 INFO: Create ID3D11Buffer: Name="unnamed", Addr=0x000000000048A4A0, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097228: CREATE_BUFFER]
D3D11 INFO: Create ID3D11ClassLinkage: Name="unnamed", Addr=0x000000000048E300, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097293: CREATE_CLASSLINKAGE]
D3D11 INFO: Create ID3D11Buffer: Name="unnamed", Addr=0x000000000048E870, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097228: CREATE_BUFFER]
D3D11 INFO: Create ID3D11VertexShader: Name="unnamed", Addr=0x00000000004881E0, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097249: CREATE_VERTEXSHADER]
D3D11 INFO: Create ID3D11PixelShader: Name="unnamed", Addr=0x00000000004886F0, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097261: CREATE_PIXELSHADER]
D3D11 INFO: Create ID3D11InputLayout: Name="unnamed", Addr=0x00000000004899A0, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097264: CREATE_INPUTLAYOUT]
'DXTB.exe' (Win32): Loaded 'C:\Windows\System32\cryptsp.dll'. Cannot find or open the PDB file.
'DXTB.exe' (Win32): Loaded 'C:\Windows\System32\rsaenh.dll'. Cannot find or open the PDB file.
'DXTB.exe' (Win32): Loaded 'C:\Windows\System32\RpcRtRemote.dll'. Cannot find or open the PDB file.
D3D11 INFO: Create ID3D11Texture2D: Name="unnamed", Addr=0x000000000049F910, ExtRef=1, IntRef=0 [ STATE_CREATION INFO #2097234: CREATE_TEXTURE2D]

Thanks I hope i haven't been to vague. Shall I post the CGeometry pertinent code...?

 


PARTNERS