Jump to content
  • Advertisement

bigworld12

Member
  • Content Count

    11
  • Joined

  • Last visited

Community Reputation

112 Neutral

About bigworld12

  • Rank
    Member
  1. bigworld12

    Understanding D3D11 basics

    struct VS_IN { float4 pos : POSITION; float4 col : COLOR; }; Your vertex shader is expecting 8 floats(2x float4) per vertex, as mentioned above, and this is where that information was dictated. if you do not follow the signature of the shader bad ju ju will follow. In dx9 this meansgarbage in garbage out. In dx10 and later, they got smart by forcing a validation with an input signature when compiling a shader. This is your layout parameter above as well. the shader signature, input layout, and vertex data must match if the shader has any hope of doing something with that data other than mangling it.   thanks now i understand what to do   Edit : i changed my vertexes to this Dim MyVertexes() As Vector4 = {New Vector4(0.0F, 0.5F, 0.0F, 1.0F), New Vector4(GetColorRGBA(Color.Red)), New Vector4(0.45F, -0.5F, 0.0F, 1.0F), New Vector4(GetColorRGBA(Color.Green)), New Vector4(-0.45F, -0.5F, 0.0F, 1.0F), New Vector4(GetColorRGBA(Color.Blue))} which works perfectly ! thanks all
  2. bigworld12

    Understanding D3D11 basics

    and let me guess , this is what controlling it ?  var layout = new InputLayout(                 device,                 ShaderSignature.GetInputSignature(vertexShaderByteCode),                 new[]                     {                         new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),                         new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0)                     });
  3. bigworld12

    Understanding D3D11 basics

    will , this is starting to make sense now so in no way i can create a Vector3 that does all of the above ?
  4. bigworld12

    Understanding D3D11 basics

    the thing is : - this code :  Dim vertixes2 = {New Vector4(0.0F, 0.5F, 0.5F, 1.0F), New Vector4(1.0F, 0.0F, 0.0F, 1.0F), New Vector4(0.5F, -0.5F, 0.5F, 1.0F), New Vector4(0.0F, 1.0F, 0.0F, 1.0F), New Vector4(-0.5F, -0.5F, 0.5F, 1.0F), New Vector4(0.0F, 0.0F, 1.0F, 1.0F)} shows this  but this code : Dim MyVertexes() As Vector3 = {New Vector3(0.0F, 0.5F, 0.0F), New Vector3(0.45F, -0.5F, 0.0F), New Vector3(-0.45F, -0.5F, 0.0F)} shows this
  5. bigworld12

    Understanding D3D11 basics

    ok here is my current progress 1 - i managed to change background dynamically on my interact  or automatically  _d3d11DevCon.ClearRenderTargetView(_renderTargetView, GetColor4(BackGround)) 2 - i decided i will make a triangle instead , so i changed to this  _d3d11DevCon.Draw(3, 0) 'insted of 1 Dim MyVertexes() As Vector3 = {New Vector3(0.0F, 0.5F, 0.0F), New Vector3(0.45F, -0.5F, 0.0F), New Vector3(-0.45F, -0.5F, 0.0F)} verticesBuffer = Direct3D11.Buffer.Create( _d3d11Device, BindFlags.VertexBuffer, MyVertexes) _d3d11DevCon.InputAssembler.InputLayout = layout _d3d11DevCon.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList _d3d11DevCon.InputAssembler.SetVertexBuffers(0, New VertexBufferBinding(verticesBuffer, 32, 0)) _d3d11DevCon.VertexShader.Set(vertexShader) _d3d11DevCon.Rasterizer.SetViewport(New Viewport(0, 0, m_rendrform.ClientSize.Width, m_rendrform.ClientSize.Height, 0.0F, 1.0F)) but it isn't working and i fail to see why is this not working since it's a perfect triangle i got the whole code from here https://github.com/sharpdx/SharpDX-Samples/tree/master/Desktop/Direct3D11/MiniTri and i just changed the vertexes but it shows this
  6. bigworld12

    Understanding D3D11 basics

    1 - the vertices array :  vertices = Direct3D11.Buffer.Create( _d3d11Device, BindFlags.VertexBuffer, {New Vector4(0.0F, 0.5F, 0.5F, 1.0F), New Vector4(1.0F, 0.0F, 0.0F, 1.0F), New Vector4(0.5F, -0.5F, 0.5F, 1.0F), New Vector4(0.0F, 1.0F, 0.0F, 1.0F), New Vector4(-0.5F, -0.5F, 0.5F, 1.0F), New Vector4(0.0F, 0.0F, 1.0F, 1.0F)}) 2 - pixel shader :  vertexShaderByteCode = ShaderBytecode.CompileFromFile("MyPointsShaders.fx", "VS", "vs_4_0", ShaderFlags.None, EffectFlags.None) vertexShader = New VertexShader(_d3d11Device, vertexShaderByteCode) pixelShaderByteCode = ShaderBytecode.CompileFromFile("MyPointsShaders.fx", "PS", "ps_4_0", ShaderFlags.None, EffectFlags.None) pixelShader = New PixelShader(_d3d11Device, pixelShaderByteCode) and the MyPointsShaders.fx is struct VS_IN { float4 pos : POSITION; float4 col : COLOR; }; struct PS_IN { float4 pos : SV_POSITION; float4 col : COLOR; }; PS_IN VS(VS_IN input) { PS_IN output = (PS_IN)0; output.pos = input.pos; output.col = input.col; return output; } float4 PS(PS_IN input) : SV_Target { return input.col; } technique10 Render { pass P0 { SetGeometryShader(0); SetVertexShader(CompileShader(vs_4_0, VS())); SetPixelShader(CompileShader(ps_4_0, PS())); } } 3 - it doesn't matter for me if i use c# or vb.net it's just that i prefer vb.net more when learning new things
  7. hello every one , i have this code here  Dim desc = New SwapChainDescription() With { .BufferCount = 1, .ModeDescription = New ModeDescription(m_rendrform.ClientSize.Width, m_rendrform.ClientSize.Height, New Rational(60, 1), Format.R8G8B8A8_UNorm), .IsWindowed = True, .OutputHandle = m_rendrform.Handle, .SampleDescription = New SampleDescription(1, 0), .SwapEffect = SwapEffect.Discard, .Usage = Usage.RenderTargetOutput} ' Create our device with swap chain and get the device context Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, _d3d11Device, _swapChain) _d3d11DevCon = _d3d11Device.ImmediateContext _factory = _swapChain.GetParent(Of Factory)() _factory.MakeWindowAssociation(m_rendrform.Handle, WindowAssociationFlags.IgnoreAll) ' New RenderTargetView from the backbuffer backBuffer = Texture2D.FromSwapChain(Of Texture2D)(_swapChain, 0) _renderTargetView = New RenderTargetView(_d3d11Device, backBuffer) ' Compile Vertex and Pixel shaders vertexShaderByteCode = ShaderBytecode.CompileFromFile("MyPointsShaders.fx", "VS", "vs_4_0", ShaderFlags.None, EffectFlags.None) vertexShader = New VertexShader(_d3d11Device, vertexShaderByteCode) pixelShaderByteCode = ShaderBytecode.CompileFromFile("MyPointsShaders.fx", "PS", "ps_4_0", ShaderFlags.None, EffectFlags.None) pixelShader = New PixelShader(_d3d11Device, pixelShaderByteCode) ' Layout from VertexShader input signature layout = New InputLayout(_d3d11Device, ShaderSignature.GetInputSignature(vertexShaderByteCode), {New InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), New InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0)}) ' Instantiate Vertex buiffer from vertex data vertices = Direct3D11.Buffer.Create( _d3d11Device, BindFlags.VertexBuffer, {New Vector4(0.0F, 0.5F, 0.5F, 1.0F), New Vector4(1.0F, 0.0F, 0.0F, 1.0F), New Vector4(0.5F, -0.5F, 0.5F, 1.0F), New Vector4(0.0F, 1.0F, 0.0F, 1.0F), New Vector4(-0.5F, -0.5F, 0.5F, 1.0F), New Vector4(0.0F, 0.0F, 1.0F, 1.0F)}) ' Prepare All the stages _d3d11DevCon.InputAssembler.InputLayout = layout _d3d11DevCon.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList _d3d11DevCon.InputAssembler.SetVertexBuffers(0, New VertexBufferBinding(vertices, 32, 0)) _d3d11DevCon.VertexShader.Set(vertexShader) _d3d11DevCon.Rasterizer.SetViewport(New Viewport(0, 0, m_rendrform.ClientSize.Width, m_rendrform.ClientSize.Height, 0.0F, 1.0F)) _d3d11DevCon.PixelShader.Set(pixelShader) _d3d11DevCon.OutputMerger.SetTargets(_renderTargetView) this simply shows a black screen with a red dot on it (you can hardly see it)   so i have some questions : 1 - how to change location of the dot 2 - how to change color of the dot 3 - what are the pieces of the code that i posted that are responsible for "Drawing" objects 4 - how to change the black background 5 - are there any helpful tutorials for sharpdx with D3D11 ?  
  8. bigworld12

    how to draw points,vectors in a 3d space

    ok found it thanks had to set PrimitiveTopology = PrimitiveTopology.PointList
  9. bigworld12

    how to draw points,vectors in a 3d space

    the part is drawing a single point with X Y Z cords as a single dot but i don't know how
  10. hello every one , i started making a game engine from scratch recently , and to be honest i think i don't know where to start so i started by making a simple Point class that have X Y Z values , all i want to do now is display points in a 3d space i watched like 5 tutorials and i managed to create a window that has a green background (Using SharpDX library in Visual studio 2013)   so how do i exactly make a 3d space to draw points on ?   here is what i am using Public Class RenderingProgram Const Height As Integer = 600 Const Width As Integer = 800 Private _swapChain As SwapChain Private _d3d11Device As D3D11.Device Private _d3d11DevCon As DeviceContext Private _renderTargetView As RenderTargetView Private _backgroundColor As SDX.Color4 Private _colorModR As Integer = 1 Private _colorModG As Integer = 1 Private _colorModB As Integer = 1 Private m_rendrform As RenderForm Public Sub New() m_rendrform = New RenderForm("Render Tests") InitializeD3D11() End Sub Private Sub InitializeD3D11() ' Describe our buffer Dim bufferDescription As New ModeDescription() With {.Width = Width, .Height = Height, .RefreshRate = New Rational(60, 1), .Format = Format.R8G8B8A8_UNorm} ' Describe our swap chain Dim swapChainDescription As New SwapChainDescription() With { .ModeDescription = bufferDescription, .SampleDescription = New SampleDescription(1, 0), .Usage = Usage.RenderTargetOutput, .BufferCount = 1, .OutputHandle = m_rendrform.Handle, .IsWindowed = True} ' Create our device with swap chain and get the device context D3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, swapChainDescription, _d3d11Device, _swapChain) _d3d11DevCon = _d3d11Device.ImmediateContext ' Create our render target view and set it Using backBuffer As Texture2D = _swapChain.GetBackBuffer(Of Texture2D)(0) _renderTargetView = New RenderTargetView(_d3d11Device, backBuffer) End Using _d3d11DevCon.OutputMerger.SetRenderTargets(_renderTargetView) End Sub Private Sub UpdateScene() ' Update the rainbow colored background _backgroundColor.Red += _colorModR * 0.005F _backgroundColor.Green += _colorModG * 0.002F _backgroundColor.Blue += _colorModB * 0.001F If _backgroundColor.Red >= 1.0F OrElse _backgroundColor.Red <= 0.0F Then _colorModR *= -1 End If If _backgroundColor.Green >= 1.0F OrElse _backgroundColor.Green <= 0.0F Then _colorModG *= -1 End If If _backgroundColor.Blue >= 1.0F OrElse _backgroundColor.Blue <= 0.0F Then _colorModB *= -1 End If End Sub Public Sub Run() m_rendrform.ClientSize = New Drawing.Size(Width, Height) m_rendrform.StartPosition = Windows.Forms.FormStartPosition.CenterScreen RenderLoop.Run(m_rendrform, AddressOf OnRender) DisposeObjects() End Sub Public Sub InitScene() End Sub Public Sub DisposeObjects() _swapChain.Dispose() _d3d11Device.Dispose() _d3d11DevCon.Dispose() _renderTargetView.Dispose() End Sub Private Sub DrawScene() ' Clear our backbuffer with the rainbow color _d3d11DevCon.ClearRenderTargetView(_renderTargetView, _backgroundColor) ' Present our drawn scene waiting for one vertical sync _swapChain.Present(1, PresentFlags.None) End Sub Public Sub OnRender() UpdateScene() DrawScene() End Sub End Class
  11. hello every one , i started making a game engine from scratch recently , and to be honest i think i don't know where to start so i started by making a simple Point class that have X Y Z values , all i want to do now is display points in a 3d space i watched like 5 tutorials and i managed to create a window that has a green background (Using SharpDX library in Visual studio 2013)   so how do i exactly make a 3d space to draw points on ?   Edit : i didn't know there is a For beginners forum , so please delete this post
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!