{"action":"created","issue":{"url":"https://api.github.com/repos/mono/MonoGame/issues/4826","repository_url":"https://api.github.com/repos/mono/MonoGame","labels_url":"https://api.github.com/repos/mono/MonoGame/issues/4826/labels{/name}","comments_url":"https://api.github.com/repos/mono/MonoGame/issues/4826/comments","events_url":"https://api.github.com/repos/mono/MonoGame/issues/4826/events","html_url":"https://github.com/mono/MonoGame/issues/4826","id":153415199,"number":4826,"title":"RasterizerState.DepthBias not working as expected","user":{"login":"SeriousMartin","id":9325330,"avatar_url":"https://avatars.githubusercontent.com/u/9325330?v=3","gravatar_id":"","url":"https://api.github.com/users/SeriousMartin","html_url":"https://github.com/SeriousMartin","followers_url":"https://api.github.com/users/SeriousMartin/followers","following_url":"https://api.github.com/users/SeriousMartin/following{/other_user}","gists_url":"https://api.github.com/users/SeriousMartin/gists{/gist_id}","starred_url":"https://api.github.com/users/SeriousMartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SeriousMartin/subscriptions","organizations_url":"https://api.github.com/users/SeriousMartin/orgs","repos_url":"https://api.github.com/users/SeriousMartin/repos","events_url":"https://api.github.com/users/SeriousMartin/events{/privacy}","received_events_url":"https://api.github.com/users/SeriousMartin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mono/MonoGame/labels/Help%20Wanted","name":"Help Wanted","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/mono/MonoGame/milestones/9","html_url":"https://github.com/mono/MonoGame/milestones/3.6%20Release","labels_url":"https://api.github.com/repos/mono/MonoGame/milestones/9/labels","id":1441958,"number":9,"title":"3.6 Release","description":"More unit tests, running unit tests on Mac and Linux, SDL2 replacing OpenTK.","creator":{"login":"dellis1972","id":810617,"avatar_url":"https://avatars.githubusercontent.com/u/810617?v=3","gravatar_id":"","url":"https://api.github.com/users/dellis1972","html_url":"https://github.com/dellis1972","followers_url":"https://api.github.com/users/dellis1972/followers","following_url":"https://api.github.com/users/dellis1972/following{/other_user}","gists_url":"https://api.github.com/users/dellis1972/gists{/gist_id}","starred_url":"https://api.github.com/users/dellis1972/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dellis1972/subscriptions","organizations_url":"https://api.github.com/users/dellis1972/orgs","repos_url":"https://api.github.com/users/dellis1972/repos","events_url":"https://api.github.com/users/dellis1972/events{/privacy}","received_events_url":"https://api.github.com/users/dellis1972/received_events","type":"User","site_admin":false},"open_issues":93,"closed_issues":51,"state":"open","created_at":"2015-12-03T11:17:13Z","updated_at":"2016-05-06T15:46:10Z","due_on":"2016-06-13T07:00:00Z","closed_at":null},"comments":3,"created_at":"2016-05-06T09:37:36Z","updated_at":"2016-05-06T20:32:52Z","closed_at":null,"body":"The DepthBias in MonoGame is not working the same way as in XNA.\r\nI'm not 100% sure, but it looks like XNA is applying the DepthBias value set in RasterizerState in a way that matches the depth buffer format.\r\n\r\nIn XNA I have used a value of -0.0004f (this is quite much) to offset a transparent area border above the landscape.\r\n\r\nThis didn't work at all in MonoGame and after some investigation I found out that MonoGame just passes the value to DirectX without modification and DirectX applies it as a factor to a very small number that is calculated based on the depth buffer format.\r\n\r\nMy theory now is that XNA does some math with the DepthBias value to make it easier for the developer to deal with it.\r\n\r\nIn my case (24bit depth buffer) the following formula gives exactly the same visual result as -0.0004f in XNA:\r\n`state.DepthBias = (float)(-0.0004f / (1 / Math.Pow(2, 24)))`\r\n"},"comment":{"url":"https://api.github.com/repos/mono/MonoGame/issues/comments/217551036","html_url":"https://github.com/mono/MonoGame/issues/4826#issuecomment-217551036","issue_url":"https://api.github.com/repos/mono/MonoGame/issues/4826","id":217551036,"user":{"login":"flibitijibibo","id":1396814,"avatar_url":"https://avatars.githubusercontent.com/u/1396814?v=3","gravatar_id":"","url":"https://api.github.com/users/flibitijibibo","html_url":"https://github.com/flibitijibibo","followers_url":"https://api.github.com/users/flibitijibibo/followers","following_url":"https://api.github.com/users/flibitijibibo/following{/other_user}","gists_url":"https://api.github.com/users/flibitijibibo/gists{/gist_id}","starred_url":"https://api.github.com/users/flibitijibibo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flibitijibibo/subscriptions","organizations_url":"https://api.github.com/users/flibitijibibo/orgs","repos_url":"https://api.github.com/users/flibitijibibo/repos","events_url":"https://api.github.com/users/flibitijibibo/events{/privacy}","received_events_url":"https://api.github.com/users/flibitijibibo/received_events","type":"User","site_admin":false},"created_at":"2016-05-06T20:32:52Z","updated_at":"2016-05-06T20:32:52Z","body":"Here's the GL depth bias work if you want to nab it:\r\n\r\nhttps://github.com/FNA-XNA/FNA/blob/master/src/Graphics/OpenGLDevice.cs#L1566\r\nhttps://github.com/FNA-XNA/FNA/blob/master/src/Graphics/OpenGLDevice.cs#L4030"}}