<commit_before>#include <d3d/VertexCommon.hlsl>
#include <game/rendering/RenderingConstants.hlsl>
#include "RefinedVertex.hlsl"

cbuffer bar : register(b1) {
	float4x4 worldMatrix;
	float3x3 worldMatrixInverseTranspose;
}

static const float DepthBias = -0.02;

float4 applyDepthBias(float4 screenPosition, float bias, float near, float far) {
	float z = -screenPosition.w;
	float zProjBiased = (far*(bias + near + z)) / ((far - near)*(bias + z));
	float zScreenBiased = zProjBiased * screenPosition.w;

	return float4(screenPosition.x, screenPosition.y, zScreenBiased, screenPosition.w);
}

float4 main(RefinedVertex vIn) : SV_POSITION{
	float3 worldPosition = mul(float4(vIn.position, 1), worldMatrix).xyz;
	float4 screenPosition = calculateScreenPosition(worldPosition);
	float4 biasedScreenPosition = applyDepthBias(screenPosition, DepthBias, znear, zfar);
	return biasedScreenPosition;
}<commit_msg>Fine tune figure false depth<commit_after>#include <d3d/VertexCommon.hlsl>
#include "RefinedVertex.hlsl"

cbuffer bar : register(b1) {
	float4x4 worldMatrix;
	float3x3 worldMatrixInverseTranspose;
}

static const float DepthBias = 0.5; //in centimeters

float4 main(RefinedVertex vIn) : SV_POSITION {
	float3 position = vIn.position;
	float3 worldPosition = mul(float4(position, 1), worldMatrix).xyz;
	float4 screenPosition = calculateScreenPosition(worldPosition);

	float3 erodedPosition = vIn.position - DepthBias * vIn.normal;
	float3 erodedWorldPosition = mul(float4(erodedPosition, 1), worldMatrix).xyz;
	float4 erodedScreenPosition = calculateScreenPosition(erodedWorldPosition);
	
	float4 combinedScreenPosition = float4(
		screenPosition.x,
		screenPosition.y,
		min(screenPosition.z, erodedScreenPosition.z / erodedScreenPosition.w * screenPosition.w),
		screenPosition.w);
	return combinedScreenPosition;
}
{'fraction_non_alphanumeric': 0.10049423393739704, 'fraction_numerical': 0.0214168039538715, 'mean_word_length': 6.497942386831276, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6197725', 'n_tokens_mistral': 612, 'n_tokens_neox': 588, 'n_words': 129}