SOLVED Drawing 3D Things Over Everything In Legacy

I wanted to make some d3d drawing operations over any other 3d draws. I want an effect like ESP or something like 'hunter vision' in video games. I've played with depths, d3d_set_depth() and d3d_set_zwriteenable() yet any of them gave the results I wanted. What should I do?
Kind of effect I wanted:
insanity-free-csgo-cheat.png
 
For the clearity: I want this to add new super ability mechanics for my game. I'm not asking for making hacks to other games or anything. Picture I used was for a visualisation for the kind of effect I wanted in my project.
 
After long time researching, I made a HLSL9 shader to manipulate depth of each pixel-fragment. Easiest way to do that was setting output Depth to -1.

Important note here: I use d3d_set_projection_ext function and I put '1' to znear argument. Setting shader output Depth to something above 0 cause shader object to render behind the objects that too close to the projection. After some experiments, I believe best value range for setting Depth in these kind of situations is between -1 and 0.

Probably there's much more easy solution out there but I couldn't find it. This is the only solution I managed to make it work in GMS Legacy.
Sorry for my bad English.

Here's the shader script: (HLSL9)
Vertex Shader
GML:
struct VSInput {
    float3 position: POSITION;
    float2 uv: TEXCOORD0;
    float4 color: COLOR0;
};

struct VSOutput {
    float4 position: SV_POSITION;
    float2 uv: TEXCOORD;
    float4 color: COLOR;
};

VSOutput main(VSInput input) {
    float4 object_space_pos = float4(input.position, 1.);
    float4 final_position = mul(gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION], object_space_pos);
    float4 final_color = input.color;
    float2 final_uv = input.uv;
   
    VSOutput output;
    output.position = final_position;
    output.uv = final_uv;
    output.color = final_color;
   
    return output;
}
Fragment/Pixel Shader
GML:
struct PSInput {
    float4 position: SV_POSITION;
    float2 uv: TEXCOORD;
    float4 color: COLOR;
};

struct PSOutput {//Output struct
    float4 color: SV_TARGET;
    float Depth: DEPTH;
};

PSOutput main(PSInput input) {
    PSOutput output;
    float4 pixColor=tex2D(gm_BaseTexture, input.uv);
    //Below line is for changing nontextured object's colour from black to white so we can make coloured draws
    if(pixColor.r==0.&&pixColor.g==0.&&pixColor.b==0.)
        pixColor=float4(1.,1.,1.,pixColor.a);
    output.color = (input.color * pixColor);
    output.Depth=-1;//Here we change the depth. Recommended maximum value is 0.
   
    return output;
}
 
Update: This solution worked with flat colours with no shading or lighting. But if I set a texture on the model or enable lightning, object looks inside out in some angles. Setting d3d_set_culling() to true fixes d3d cubes. But imported .gmmod models are still broken.

I will keep the post 'Solved' (since I found a solution I wanted), but will keep trying to fix this problem and if I find a solution I'll post it here.


Aadsız.png
 
Top