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

Jofo

Members
  • Content count

    9
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Jofo

  • Rank
    Newbie
  1. I guess it is sorted, but weird way.   I plugged the monitor into the integrated card, rebooted and indeed I was now able to create context on the Intel chip, even on GeForce which had no output. I plugged it back to the GeForce and now device context can be created on both cards simultaneously.
  2. Dingleberry and Alessio1989 - you were right! I enabled debug for the app in the panel, then it prompted me to install Graphics Tools. So now the debug output works.   Intel drivers are up to date, I installed them yesterday. And I guess the video ram amount is also OK - because I am querying DXGI_ADAPTER_DESC1.DedicatedVideoMemory, which as of integrated card, has none. Or maybe its because of the monitor, will try...
  3. I just enabled it in BIOS (i7 4770K, ASRock Z87E-ITX), I can see it in device manager and it is listed among adapters returned by DXGI factory.  
  4. Hello everyone!   I'm trying out DX12 (did some work in DX11 and a lot in OGL), but I got some issues.   First of all, how to enable debug in DX12? In my code (copied from tutorial) ID3D12Debug* debugController; if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController)))) { debugController->EnableDebugLayer(); std::cout << "DEBUG enabled...\n"; } else { std::cerr << "DEBUG NOT WORKING!\n"; } and it always fails. I tried it event in DX tutorials I got from GitHUB - the same. In DX11 there was this DX Control Panel app, in which I enabled debug, but I cant find it in Win10.     Secondly, I am planning to do some GPU coop, that probably means creating a context on a device with no monitor attached. I have a GTX 780 (monitor attached) and integrated Intel HD 4600. I see the Intel chip among the adapters, but I cannot create context on that card. I even tried to lower the feature level to 10, but it fails anyway. So how to create a multi-GPU context / context for off-screen rendering?  
  5. Thank You for replies! The point is that currently there are lots of systems with dual-gpu configuration, thanks to Intel/AMD and their integrated GPU cores in processors. I want to exploit dual-GPU config for shadow mapping, where one GPU would render the scene itself, and the other one would be responsible for shadows, e.g. creating the shadow map and transfering the map to the primary GPU. I will try to see into it a bit more...
  6. Is there any way to transfer textures between multiple (two) GPU in DX or OGL? Let's say I render something off-screen on a slave GPU and use it on primary GPU. Thank You!
  7. This setup produces result like this: [url="http://s7.directupload.net/images/120204/ytgev879.png"]http://s7.directuplo...04/ytgev879.png[/url] the dog is located at x = 0 and z=0, his head pointing towards positive z. Light is at (0, 10, 0) - above the dog. When I debugged my code in AMD GPU PerfStudio, the applied map is actually stored in back texture and not in front (despite containing front map). If I set front view matrix for back map generation, I can get correct back map: [url="http://s7.directupload.net/images/120204/jcmytkzt.png"]http://s7.directuplo...04/jcmytkzt.png[/url] But front map is always empty, that means initialized to 1s, so everything is lighted.
  8. I have simmilar problem as minhpu, I'm implementing DPSM in DirectX 11 and the problem is that I can't make front map work, and back map works only with some "crazy" parameters (setting front view matrix for light). I spent week trying to find what's wrong, but I can't find it. Please help. I followed code from [url="http://gamedevelop.eu/en/tutorials/dual-paraboloid-shadow-mapping.htm"]THIS[/url] website. Here is initialization code (SRVs, RenderTargets, Textures,...): [code] lightViewPort.Width = SM_DP_SIZE; lightViewPort.Height = SM_DP_SIZE; lightViewPort.MinDepth = 0.0f; lightViewPort.MaxDepth = 1.0f; lightViewPort.TopLeftX = 0.0f; lightViewPort.TopLeftY = 0.0f; //Sampler D3D11_SAMPLER_DESC shadowMapDesc; ZeroMemory( &shadowMapDesc, sizeof( shadowMapDesc ) ); shadowMapDesc.AddressU = D3D11_TEXTURE_ADDRESS_BORDER; shadowMapDesc.AddressV = D3D11_TEXTURE_ADDRESS_BORDER; shadowMapDesc.AddressW = D3D11_TEXTURE_ADDRESS_BORDER; shadowMapDesc.ComparisonFunc = D3D11_COMPARISON_NEVER; shadowMapDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; shadowMapDesc.MaxLOD = D3D11_FLOAT32_MAX; //shadowMapDesc.BorderColor[3] = 1.0f; result = device->CreateSamplerState( &shadowMapDesc, &samplerF ); if( FAILED( result ) ) { ... } result = device->CreateSamplerState( &shadowMapDesc, &samplerB ); if( FAILED( result ) ) { ... } //Depth-stencil D3D11_TEXTURE2D_DESC texDesc; ZeroMemory(&texDesc,sizeof(texDesc)); texDesc.Width = SM_DP_SIZE; texDesc.Height = SM_DP_SIZE; texDesc.MipLevels = 1; texDesc.ArraySize = 1; texDesc.Format = DXGI_FORMAT_D32_FLOAT; texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Usage = D3D11_USAGE_DEFAULT; texDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; texDesc.CPUAccessFlags = 0; texDesc.MiscFlags = 0; //depth-stencil texture result = device->CreateTexture2D( &texDesc, NULL, &tDepthTexture ); if( FAILED( result ) ) { ... } D3D11_DEPTH_STENCIL_VIEW_DESC dDSV; ZeroMemory(&dDSV,sizeof(dDSV)); dDSV.Format = DXGI_FORMAT_D32_FLOAT; dDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; dDSV.Texture2D.MipSlice = 0; result = device->CreateDepthStencilView( tDepthTexture, &dDSV, &DSVShadowMap ); if( FAILED( result) ) { ... } //Both depth textures texDesc.Format = DXGI_FORMAT_R32_FLOAT; texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; result = device->CreateTexture2D( &texDesc, NULL, &tShadowTextureF); if( FAILED( result ) ) { ... } result = device->CreateTexture2D( &texDesc, NULL, &tShadowTextureB); if( FAILED( result ) ) { ... } //Shader Resource View D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; ZeroMemory( &srvDesc, sizeof( srvDesc ) ); srvDesc.Format = DXGI_FORMAT_R32_FLOAT; srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; srvDesc.TextureCube.MipLevels = 1; srvDesc.TextureCube.MostDetailedMip = 0; //Shadow maps as shader resources result = device->CreateShaderResourceView( tShadowTextureF, &srvDesc, &SRVShadowMapF); if( FAILED( result ) ) { ... } result = device->CreateShaderResourceView( tShadowTextureB, &srvDesc, &SRVShadowMapB); if( FAILED( result ) ) { ... } //Render target D3D11_RENDER_TARGET_VIEW_DESC DescRT; DescRT.Format = DXGI_FORMAT_R32_FLOAT; DescRT.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; DescRT.Texture2D.MipSlice = 0; result = device->CreateRenderTargetView(tShadowTextureF,&DescRT,&RTVShadowMapF); if( FAILED( result ) ) { ... } result = device->CreateRenderTargetView(tShadowTextureB,&DescRT,&RTVShadowMapB); if( FAILED( result ) ) { ... } //const. buffer with light stuff D3D11_BUFFER_DESC constDesc; ZeroMemory( &constDesc, sizeof( constDesc ) ); constDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; constDesc.ByteWidth = sizeof( ConstBuff ); constDesc.Usage = D3D11_USAGE_DEFAULT; constDesc.CPUAccessFlags = 0; result = device->CreateBuffer( &constDesc, 0, &paramCB ); if( FAILED( result ) ) { ... } //Rasterizer D3D11_RASTERIZER_DESC rDesc; ZeroMemory(&rDesc, sizeof(rDesc)); rDesc.FillMode = D3D11_FILL_SOLID; rDesc.CullMode = D3D11_CULL_BACK; rDesc.FrontCounterClockwise = FALSE; rDesc.DepthClipEnable = TRUE; rDesc.ScissorEnable = FALSE; rDesc.MultisampleEnable = FALSE; rDesc.AntialiasedLineEnable = FALSE; result = device->CreateRasterizerState(&rDesc,&rasterizerB); if( FAILED( result ) ) { ... } rDesc.CullMode = D3D11_CULL_NONE; result = device->CreateRasterizerState(&rDesc,&rasterizerN); if( FAILED( result ) ) { ... } lightPos = XMFLOAT3(0.0f,10.0f,0.0f); return true; [/code] Here is the rendering code: [code] float clearColor[4] = { 0.0f, 0.0f, 0.25f, 1.0f }; float clearColorSM[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; context->ClearRenderTargetView( defaultRenderTarget, clearColor ); context->ClearDepthStencilView( defaultDSV, D3D11_CLEAR_DEPTH, 1.0f, 0 ); context->IASetInputLayout( inputLayout ); context->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); context->VSSetShader( sVShader, NULL, 0 ); context->PSSetShader( sPShader, NULL, 0 ); context->RSSetViewports(1,&lightViewPort); MatrixBuffer cb1; cb1.mView = XMMatrixTranspose(XMLoadFloat4x4(&view)); //passed via func. argument cb1.mProj = XMLoadFloat4x4(&mProjection); //second buffer with light params struct ConstBuff cb2; cb2.nearClip = 0.1f; cb2.farClip = 50.0f; cb2.parDirection = 1.0f; cb2.lightPos = lightPos; cb2.mSMWorldView = XMMatrixTranspose( XMMatrixLookAtLH(XMLoadFloat3(&lightPos), XMLoadFloat3(&XMFLOAT3(lightPos.x,lightPos.y,lightPos.z+1.0f)), XMLoadFloat3( &XMFLOAT3(0.0f, 1.0f, 0.0f )) )); //-------------------RENDERING------------------ //-------FIRST PASS - FRONT MAP--------------------------- context->OMSetRenderTargets(1,&RTVShadowMapF, DSVShadowMap); context->ClearRenderTargetView(RTVShadowMapF, clearColorSM); context->ClearDepthStencilView( DSVShadowMap, D3D11_CLEAR_DEPTH, 1.0f, 0 ); context->RSSetState(rasterizerB); for(unsigned int i=0;i<renderMeshes.size();++i) { context->UpdateSubresource( paramCB, 0, NULL, &cb2, 0, 0 ); context->UpdateSubresource( matrixCB, 0, NULL, &cb1, 0, 0 ); context->VSSetConstantBuffers(0, 1, &matrixCB ); context->VSSetConstantBuffers(1, 1, &paramCB ); context->IASetVertexBuffers( 0, 1, &meshes[renderMeshes[i].meshIndex].pVertexBuffer, &meshes[renderMeshes[i].meshIndex].stride, &meshes[renderMeshes[i].meshIndex].offset ); context->IASetIndexBuffer( meshes[renderMeshes[i].meshIndex].pIndexBuffer, DXGI_FORMAT_R32_UINT, 0 ); context->DrawIndexed(meshes[renderMeshes[i].meshIndex].numIndices,0, 0); } //------------SECOND PASS - Backmap------------------------ context->OMSetRenderTargets(1, &RTVShadowMapB, DSVShadowMap); context->ClearRenderTargetView(RTVShadowMapB,clearColorSM); context->ClearDepthStencilView( DSVShadowMap, D3D11_CLEAR_DEPTH, 1.0f, 0 ); context->RSSetState(rasterizerN); //Vypnutie orezavania cb2.parDirection = -1.0f; cb2.mSMWorldView = XMMatrixTranspose( XMMatrixLookAtLH(XMLoadFloat3(&lightPos), XMLoadFloat3(&XMFLOAT3(lightPos.x,lightPos.y,lightPos.z-1.0f)), XMLoadFloat3( &XMFLOAT3(0.0f, 1.0f, 0.0f )) )); for(unsigned int i=0;i<renderMeshes.size();++i) { cb1.mWorld = XMLoadFloat4x4(&renderMeshes[i].worldMat); context->UpdateSubresource( paramCB, 0, NULL, &cb2, 0, 0 ); context->UpdateSubresource( matrixCB, 0, NULL, &cb1, 0, 0 ); context->VSSetConstantBuffers(0, 1, &matrixCB ); context->VSSetConstantBuffers(1, 1, &paramCB ); context->IASetVertexBuffers( 0, 1, &meshes[renderMeshes[i].meshIndex].pVertexBuffer, &meshes[renderMeshes[i].meshIndex].stride, &meshes[renderMeshes[i].meshIndex].offset ); context->IASetIndexBuffer( meshes[renderMeshes[i].meshIndex].pIndexBuffer, DXGI_FORMAT_R32_UINT, 0 ); context->DrawIndexed(meshes[renderMeshes[i].meshIndex].numIndices,0, 0); } //---------FINAL SCENE------------ context->OMSetRenderTargets(1, &defaultRenderTarget, defaultDSV); context->ClearDepthStencilView( defaultDSV, D3D11_CLEAR_DEPTH, 1.0f, 0 ); context->RSSetViewports(1,&viewPort); context->VSSetShader( rVShader, NULL, 0 ); context->PSSetShader( rPShader, NULL, 0 ); //Samplers context->PSSetSamplers( 0, 1, &samplerF); context->PSSetSamplers( 1, 1, &samplerB); //Textures context->PSSetShaderResources( 0, 1, &SRVShadowMapF ); context->PSSetShaderResources( 1, 1, &SRVShadowMapB ); context->RSSetState(rasterizerB); //Setting the front view light matrix cb2.mSMWorldView = XMMatrixTranspose( XMMatrixLookAtLH(XMLoadFloat3(&lightPos), XMLoadFloat3(&XMFLOAT3(lightPos.x,lightPos.y,lightPos.z+1.0f)), XMLoadFloat3( &XMFLOAT3(0.0f, 1.0f, 0.0f )) )); for(unsigned int i=0;i<renderMeshes.size();++i) { cb1.mWorld = XMLoadFloat4x4(&renderMeshes[i].worldMat); context->UpdateSubresource( matrixCB, 0, NULL, &cb1, 0, 0 ); context->UpdateSubresource( paramCB, 0, NULL, &cb2, 0, 0); context->VSSetConstantBuffers( 0, 1, &matrixCB ); context->VSSetConstantBuffers( 1, 1, &paramCB ); context->PSSetConstantBuffers( 1, 1, &paramCB ); context->IASetVertexBuffers( 0, 1, &meshes[renderMeshes[i].meshIndex].pVertexBuffer, &meshes[renderMeshes[i].meshIndex].stride, &meshes[renderMeshes[i].meshIndex].offset ); context->IASetIndexBuffer( meshes[renderMeshes[i].meshIndex].pIndexBuffer, DXGI_FORMAT_R32_UINT, 0 ); context->DrawIndexed(meshes[renderMeshes[i].meshIndex].numIndices,0, 0); } //disconnect render target context->OMSetRenderTargets(0,NULL,NULL); //disconnect resources ID3D11ShaderResourceView* nullViews[2] = {0};//, 0, 0, 0, 0, 0, 0, 0}; context->PSSetShaderResources(0, 2, nullViews); [/code] ..and shader code: [code] cbuffer MatrixBuffer : register(b0) { matrix mWorld; matrix mView; matrix mProj; }; //Parametrization buffer cbuffer ParamBuffer : register(b1) { matrix mSMView; //light view matrix float3 lightPos; //light position float parDirection; //Shadow map direction float nearClip; //near clipping plane float farClip; //far clipping plane }; //-----------------------Samplers and textures-------------------------- SamplerState shadowSamplerF : register(s0); SamplerState shadowSamplerB : register(s1); Texture2D SMFront : register(t0); Texture2D SMBack : register(t1); //----------------------------Structs------------------------------ struct VS_INPUT { float4 pos : POSITION; float2 uv : TEXCOORD; float3 normal : NORMAL; }; struct PS_INPUT_SHADOW { float4 pos : SV_POSITION; float clipDepth : TEXCOORD1; float depth : TEXCOORD2; }; struct PS_INPUT { float4 pos : SV_POSITION; float3 worldPos : TEXCOORD0; float2 uv : TEXCOORD1; float3 normal : NORMAL; }; //---------------------Shadow map generation shaders----------------------- PS_INPUT_SHADOW VS_S(VS_INPUT input) { PS_INPUT_SHADOW Out = (PS_INPUT_SHADOW) 0; Out.pos = mul(input.pos, mWorld); Out.pos = mul(Out.pos, mSMView); Out.pos /= Out.pos.w; Out.pos.z *= parDirection; float vecLength = length(Out.pos.xyz); // normalize Out.pos /= vecLength; // save for clipping Out.clipDepth = Out.pos.z; //calc "normal" on intersection, by adding the // reflection-vector(0,0,1) and divide through // his z to get the texture coords Out.pos.x /= Out.pos.z + 1.0f; Out.pos.y /= Out.pos.z + 1.0f; // set z for z-buffering and neutralize w Out.pos.z = (vecLength - nearClip) / (farClip - nearClip); Out.pos.w = 1.0f; // DP-depth Out.depth = Out.pos.z; return Out; } float PS_S(PS_INPUT_SHADOW input) : SV_Target { clip(input.clipDepth); return input.depth; } //-----------------OUTPUT RENDER-------------------- PS_INPUT VS_R (VS_INPUT input) { PS_INPUT Out = (PS_INPUT) 0; Out.pos = mul(input.pos, mWorld); Out.worldPos = Out.pos.xyz; Out.pos = mul(Out.pos, mView); Out.pos = mul(Out.pos, mProj); Out.normal = mul(input.normal, mWorld); Out.uv = input.uv; return Out; } float4 PS_R (PS_INPUT input) :SV_Target { float4 viewPos = mul(float4(input.worldPos.xyz,1.0f), mSMView); float viewLen = length(viewPos); // normalize viewPos /= viewLen; // compute and read according depth float fSceneDepth = (viewLen - nearClip) / (farClip - nearClip); float fDPDepth = 0.0f; if(viewPos.z >= 0.0f) { float2 vTexFront; vTexFront.x = (viewPos.x / (1.0f + viewPos.z)) * 0.5f + 0.5f; vTexFront.y = 1.0f - ((viewPos.y / (1.0f + viewPos.z)) * 0.5f + 0.5f); fDPDepth = SMFront.Sample(shadowSamplerF, vTexFront).r; } else { // for the back the z has to be inverted float2 vTexBack; vTexBack.x = (viewPos.x / (1.0f - viewPos.z)) * 0.5f + 0.5f; vTexBack.y = 1.0f - ((viewPos.y / (1.0f - viewPos.z)) * 0.5f + 0.5f); fDPDepth = SMBack.Sample(shadowSamplerB, vTexBack).r; } // lighting and shadowing float shadowBias = 0.005f; float4 ambientColor = float4(0.05f, 0.05f, 0.05f, 1.0f); float4 diffuseColor = float4(0.7f, 0.7f, 0.7f, 1.0f); float3 lVec = input.worldPos.xyz - lightPos; float shadowFactor = (fDPDepth + shadowBias) >= fSceneDepth; float L = saturate(dot(normalize(input.normal),normalize(-lVec))); return saturate(ambientColor + shadowFactor*L*diffuseColor); } [/code] I'm a DX beginner, so if You see something "stupid" in my code, just let me know. Thanks a lot ;)
  9. Hello everyone! I'm quite new to DirectX and I'm making a school project in DX11. I have some issues with constants in HLSL... Could anyone pls explain to me, how do constants/global variables in HLSL work? Because I'm making a simple demo, and want to access constants in cbuffer from pixel shader. But it doesn't work! I tried to even put them outside the cbuffer and set it manually in .fx source - same result. snippet from .fx file: [code] cbuffer ConstantBuffer : register (b0) { matrix mWorld; matrix mView; matrix mProj; float4 cColor; // - always black } float4 gColor = float4(1.0f,0.0f,0.0f,1.0f); //same here ... VS..... float4 PS_Main( PS_Input frag ) : SV_TARGET { //return cColor; // - doesn't work, always black //return gColor; // - same here //return frag.color; //works, but not elegant return float4( 1.0f,0.0f,0.0f,1.0f); //works, also not nice } [/code] Any answer greatly appreciated EDIT1: partially solved, forgot to call PSSetConstantBuffers.... jeez EDIT2: the global stuff still not working