Jump to content
  • Advertisement

gomidas

Member
  • Content Count

    25
  • Joined

  • Last visited

Community Reputation

162 Neutral

About gomidas

  • Rank
    Member

Personal Information

  • Interests
    Art
    Design
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hello, I want to add a directional light calculation to my HLSL code. What is the correct calculation of that, please somebody explain it to me !
  2. Hello, I made a directional light with diffuse. Now If I rotate my camera I see changes. Some parts naturally becomes darker. I did not pass parameters from variables I directly put them to see if that works. My problem, if I rotate or move cam I see changes but if I rotate or move mesh I cant see changes. What should I add to see the differences when mesh rotated ? Texture2D ShaderTexture : register(t0); Texture2D ShaderTextureNormal : register(t1); SamplerState Sampler : register(s0); cbuffer CBufferPerFrame{ float4 AmbientColor = float4(1.0f,1.0f,1.0f,0.0f); float4 LightColor = float4(1.0f,1.0f,1.0f,1.0f); float3 lightDirection = float3(0.0f,0.0f,-1.0f); } cbuffer CBufferPerObject{ float4x4 worldViewProj; float4x4 world; } struct VS_IN { float4 pos : POSITION; float3 normal : NORMAL; // Normal - for lighting float4 col : COLOR; float2 TextureUV: TEXCOORD0; // Texture UV coordinate }; struct PS_IN { float4 pos : SV_POSITION; float4 col : COLOR; float2 TextureUV: TEXCOORD; float3 normal : NORMAL; float3 tangent : TANGENT; float3 binormal : BINORMAL; float3 lightDirection:LIGHT; float3 WorldPos:POSITION1; }; PS_IN VS( VS_IN input ) { PS_IN output = (PS_IN)0; output.pos = mul(input.pos, worldViewProj); output.col = 1.0f-((input.pos.w /* * input.col*/) / (input.pos.z /* *input.col*/)); output.TextureUV = input.TextureUV; output.normal = normalize(mul(float4(input.normal,0), world).xyz); output.lightDirection=float3(0.0f,0.0f,-1.0f); output.tangent = CalculateTangent(input.normal); output.col = input.col; output.WorldPos = mul( input.pos, world ); return output; } float4 PS( PS_IN input ) : SV_Target { float3 sampledNormal = (2*ShaderTextureNormal.Sample(Sampler,input.TextureUV).xyz) - 1.0f; float3x3 tbn = float3x3(input.tangent, input.binormal, input.normal); sampledNormal = mul(sampledNormal, tbn); float4 N = ShaderTextureNormal.Sample(Sampler, input.TextureUV)*2.0f-1.0f; float4 D = ShaderTexture.Sample(Sampler, input.TextureUV); float3 lightDirection = normalize(-1*input.lightDirection); float n_dot_1 = dot (lightDirection, input.normal); float3 ambient = D.rgb * float3(1.0f,1.0f,1.0f) * 0; float3 diffuse=(float3)0; if( N.x == -1 && N.y == -1 && N.z == -1 && N.w == -1) { //HERE if(n_dot_1>0){ diffuse = D.rgb* float3(1,1,1) * 1 * n_dot_1; } input.col.rgb=(ambient+ diffuse); input.col.a = D.a; } else { //Not used for now. //input.col = saturate(dot(N,input.lightDirection)); } return input.col; }
  3. I get something wrong about the setting file I think. public Texture2D T2D_DiffuseMap = "File.png"; public ShaderResourceView textureView; textureView = new ShaderResourceView(device, T2D_DiffuseMap); device.ImmediateContext.PixelShader.SetShaderResource(0, textureView); So will I have a Texture2D array that keeps multiple files diffuse.png and normal.png then I will do it like : new ShaderResourceView(device, TextureData); //diffuse.png and normal.png ??? Then I will modifyshader file. Or I am getting it wrong ? I am asking because there is no source for c#.
  4. alright if unreal engine does it too no problem for me.
  5. I do not know. Seriously I do not know.
  6. IT IS GOD DAMN HARD. I have to study history. I do not have that time. If I use hlsl sided one can I stay away from all of those calculations ? If I do it, will it work same about quality ?
  7. I am trying to add normal map to my project I have an example of a cube: I have normal in my shader I think. Then I set shader resource view for texture (NOT BUMP) device.ImmediateContext.PixelShader.SetShaderResource(0, textureView); device.ImmediateContext.Draw(VerticesCount,0); What should I do to set my normal map or how it is done in dx11 generally example c++?
  8. I want to rotate my camera around the target horizontally and vertically. Example if q-e pressed only horizontally rotated. And when 1-2 pressed vertically rotated around its direction Example Cameraview : public Matrix View { get; set; } public Vector3 eye { get; set; } = new Vector3(0, 0, -5); public Vector3 target { get; set; } = new Vector3(0, 0, 0); public Vector3 Translation = new Vector3(0, 0, 0); View = Matrix.Translation(Translation.X, Translation.Y, Translation.Z)* Matrix.LookAtLH(eye, target, Vector3.UnitY); I think rotation must be based on target point not the camera itself.
  9. var rasterizerStateDescription1 = new RasterizerStateDescription { CullMode =CullMode.Front, FillMode = FillMode.Solid, IsFrontCounterClockwise =true,IsAntialiasedLineEnabled=true, IsMultisampleEnabled=true }; Multisampling must be enabled too.
  10. gomidas

    Culling in SharpDX

    thanks for the answer, I got it and used well. I used it to check edges if one of their triangle is back facing and the other one is front facing. But another question in my mind is : Is it possible to turn back face culling on only single area of the model when mouse over example Draw a virtual circle around mouse (2D coord) and make only that part back face when mouse is moving on model. Just like in the sims series I remember there was something like that. Shortly, that will show whats inside in buildings. If it is possible I will open a new topic. Thank You.
  11. gomidas

    Culling in SharpDX

    can anyone tell what it does if back face culling or front face culling set.
  12. I render it by clearing context.ClearDepthStencilView(depthView, DepthStencilClearFlags.Depth, 1.0f, 0); And also I did it larger but I did those already problem is when I have a mesh backwards front mesh's outline stays backward other mesh here is the result and issue :
  13. I am trying to render outline for my mesh. I basicly re-render the mesh without texture and put color. My problem is I want to show the outline topmost. When I clear depthview after rendering outline mesh my outline stays background of target mesh but also background of other meshes. I want to show outline top of other meshes but behind of my target mesh ? Is that possible ? If I clear depthview for mesh and outline at this time my mesh will be top of other meshes which I do not want.
  14. Hmm, I am going to check that thank you very much.
  15. Alright, that would be perfect if there was an example usage about how will I put them inside. Buf for retriving existing cooords I do not have use that I can get correct positions over matrix and pass transformed coords to VertexData instead of it huh ? I think access is for animations (?)
  • 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!