Jump to content
The Dark Mod Forums

duzenko

Active Developer
  • Posts

    4159
  • Joined

  • Last visited

  • Days Won

    50

Posts posted by duzenko

  1. Here's an example of my depth shader, for reference. You might want to start with it and build on it.

    //layout (location=1) uniform vec4 clipPlane;
    uniform vec4 clipPlane;
    
    //layout (location=8) in vec2 tc0;
    in vec2 tc0;
    
    varying float clipPlaneDist; 
    
    void main() {
    	gl_TexCoord[0] = vec4(tc0, 0, 0);
    	gl_FrontColor = gl_Color;
    	clipPlaneDist = dot(gl_Vertex, clipPlane);
    	gl_Position = ftransform();
    }
    
    uniform sampler2D tex0;
    //layout (location=2) uniform float alphaTest;
    uniform float alphaTest;
    
    varying float clipPlaneDist; 
    
    void main() {
    	if (clipPlaneDist < 0.0)
    		discard;
    	vec4 tex = texture2D(tex0, gl_TexCoord[0].st);
    	if (tex.a <= alphaTest)
    		discard;
    	gl_FragColor = tex*gl_Color;	
    }
    
  2. How do you plug a glsl shader into a material? Is it exactly like the ARB ones?

    You or someone could also take a idtech ARB shader convert it into the GLSL version and explain all the steeps needed to do that.

     

    Btw i'm not asking for you or someone to teach how to convert ARB into GLSL per se, what i'm asking is more how the conections to the engine render and materials are between the ARB and the GLSL version.

    I have not done any material shader but for now let's assume it's going to be the same as existing darkmod ARB shaders.

    Are you looking to create a new shader or convert an existing one?

     

    I think attrib[8] could be TexCoord1, etc.

    Env[16] - Env16, etc.

     

    I don't think user-supplied per material support for GLSL has been added yet based on a quick survey of the code.

    It looks we just have backend GLSL right now (which is still quite useful).

    There has been no requests yet but it's already technically possible.

    Just let's agree to call a glsl shader by file name with no extension, i.e.

    program   fresnel

    This way the engine knows it's a glsl program located in two files: fresnel.vp and fresnel.fp. Compare to fresnel.vfp that contains both shaders in ARB assembly.

  3. Some would suggest skipping both and going to OpenCL but there's still not enough support there yet as I recall.

    One thing I always wondered is - can we use OpenCL to get rid of near clipping plane in projection matrix similar to how the far plane became obsolete a decade ago.

    The GPU only works in 4-coordinate space, and does a non-optional hardware w-division.

    If only there was a way to work around that.

  4. Does GLSL improve or heaven forbid, degrade performance? :)

    Is 2017 C slower or faster than 1987 assembler?

    For me, the main difference is support of branches (and loops) that ARB assembly is missing. Other than that I was very happy with it.

    Then, there's the deprecated stuff issue. I want to get rid of TexGens, etc.

  5. Wow... I did not expect my thread to inspire anyone to do any engine changes so quickly. That's awesome to hear, thank you duzenko! Can you post any screenshots please?

    It looks exactly the same as before, which is good. I only replaced existing fixed pipeline/arb with glsl. Adding eye-candies is not my specialty.

  6. GLSL support added.

     

    I will try write glsl shaders if it ever gets implemented in TDM, but good documentation needs to be made by who implements a GLSL render, about how all of it is connected into the engine and how shaders are plugged into materials, etc.

     

    What kind of documentation would you like?

    Assets svn now has depthAlpha.vp/fp GLSL shader as proof of concept. It's already used by the svn exe.

    • Like 2
  7. Curious: first thing I looked at the depth shader on things I did recently.

    1) can't see code that would clip a mirror near plane.

    2) can't see where the referenced clip() function is defined

    3) how is #define implemented? AFAIK it's not standard GLSL

    4) is there support for vegetation LOD alpha-test? Can't see it.

     

    Git status is WIP but last change was year ago. How finished is it generally?

  8. I would like to see the glsl support very much. Porting ARB to glsl can't be too hard.

    Correct me if I'm wrong but the real problem is going to be replacing all legacy stuff like modelview and texture matrixes, texgens, global vs per vertex colors and normals, etc. I presume that GLSL backend includes all of that?

  9. Anyone ever used cameras in TDM missions?

    In terms of performance, do you think it is going to be faster? I think camera is being updated each frame so one way or another it is always drawing everything.

    Does the camera still work after save/load? It does not for me.

    ...

    Regarding your problem (parasite pixels in the skybox).

    I think it's caused by the water shader in the camera view. It requires to save the current frame to the texture that is also used by the skybox pass.

    What you could try here is use a simpler, non-post-processing material for water in the camera area.

×
×
  • Create New...