Jump to content
The Dark Mod Forums

Recommended Posts

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.

 

Btw is not #define just a C/C++ compiler/pre-processor keyword? At lest that was what i learned when learning programming.

Edited by HMart
Link to post
Share on other sites
  • Replies 77
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

I hope this isn't a useless thread, just thought it would be constructive to let everyone know about it. I was looking up some TDM related concerns, and accidentally stumbled across another fork of th

This keyword actually expects a normal map. Conversion is done via another command (normal iirc).   But as he says POM requires a heightmap (so an image that contains information about the height of a

For Reference: Iterative Parallex Mapping (with slope information)   Similar cheap like Parallex mapping, but better in regards to visuals. Fixed amount of iterations, so no branching needed (-> ca

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
Link to post
Share on other sites

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.

Link to post
Share on other sites

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.

Link to post
Share on other sites

Early OpenGL drivers did a poor job of compiling GLSL to assembly. Recent drivers have had years of games with GLSL to work out most

of the kinks and it's even possible that the compiler would do a better job than hand-tuned ARB assembly in some cases (especially with branching and loops).

Too bad that GLSL isn't as elegant as Nvidia's (proprietary) Cg though. It would be nice to have a proper C style High Level language. :(

Some would suggest skipping both and going to OpenCL but there's still not enough support there yet as I recall. And now Vulkan exists to totally

funk up OpenCL's rise in ubiquity.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to post
Share on other sites
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.

Link to post
Share on other sites

GLSL support added.

 

 

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.

 

Fantastic!

 

What kind of documentation i want?

 

Something like:

 

How do you plug a glsl shader into a material? Is it exactly like the ARB ones? For example in fhDoom calling GLSL shaders in materials is not exactly like the ARB way, is similar tho, for example:

 

In ARB you do this:

 

{

program fresnel.vfp

vertexParm 0 .0200593122

fragmentMap 0 _scratch

}

In GLSL you do something like:

 

 

{

vertexShader test.vp
fragmentShader test.fp
shaderParm 0 time * 0.05, time * 0.2, 1.0, 1.0
shaderMap 0 _currentRender
shaderMap 1 textures/rock/zbtest.tga
}

 

Other is, how is GLSL connected to the TDM engine?

 

In ARB we have more or less this globals, took them from a Doom3 ARB shader

 

 

# input:
#
# attrib[8] TEX0 texture coordinates
# attrib[9] TEX1 normal
# attrib[10] TEX2 tangent[0]
# attrib[11] TEX3 tangent[1]
# COL vertex color
#
# c[4] localLightOrigin
# c[5] localViewOrigin
# c[6] lightProjection S
# c[7] lightProjection T
# c[8] lightProjection Q
# c[9] lightFalloff S
# c[10] bumpMatrix S
# c[11] bumpMatrix T
# c[12] diffuseMatrix S
# c[13] diffuseMatrix T
# c[14] specularMatrix S
# c[15] specularMatrix T
# c[16] vertex color modulate
# c[17] vertex color add
#
# c[20] model matrix
# c[21] model matrix
# c[22] model matrix
#
# output:
#
# texture[0] is the ambient cube map (was the normalization cube map)
# texture[1] is the per-surface bump map
# texture[2] is the light falloff texture
# texture[3] is the light projection texture
# texture[4] is the per-surface diffuse map
# texture[5] is empty (was the per-surface specular map)
# texture[6] is empty (was the specular lookup table)
# texcoord[0] is the surface bump map
# texcoord[1] is the surface diffuse map
# texcoord[2] is the light projection
# texcoord[3] is the light falloff
# texcoord[4] is the local normal to global normal transform
# texcoord[5] is the local normal to global normal transform
# texcoord[6] is the local normal to global normal transform

 

How does that relate to GLSL?

 

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.

Edited by HMart
Link to post
Share on other sites

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).

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to post
Share on other sites

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.

Link to post
Share on other sites

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;	
}
Link to post
Share on other sites

 

 

program fresnel

 

Yes, I think that's how it was done elsewhere.

 

Here is an older version of Pat Raynor work for iodoom3 where I think stripped the extensions then read from one folder for ABB (if on the ARB2 renderer)

and the other folder for GLSL:

 

https://github.com/iodoom-gitorious/raynorpats-glsl_iodoom3/commits/master

 

I think that historical stuff is also in the commit log of the other Pat Raynor repo.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to post
Share on other sites

Many are applicable but our Enhanced Interaction and Enhanced Ambient have new features compared to Vanilla Doom 3 versions converted there.

Also, our heathaze shaders sample depth.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to post
Share on other sites

 

Pat Raynor's repo is a hybrid of vanilla Doom 3 and BFG.

 

 

If we moved closer to BFG we could port PBR from Robert Beckeban's BFG repo.

 

https://github.com/RobertBeckebans/RBDOOM-3-BFG/tree/PBR

 

That said, we would need a way to handle existing assets and add new PBR ones.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to post
Share on other sites

I used Substance Painter. Diffusemaps of metals would need to be brighten up. Generally TDM textures are rather dark. And metalness and roughness maps would have to replace specular maps.

 

JrEUkOM.jpg
A96vcqT.png
fXQdUvU.png

  • Like 2

It's only a model...

Link to post
Share on other sites

Hmm, I guess he's packing all the info into the specular image. Probably color channels?

 

https://github.com/RobertBeckebans/RBDOOM-3-BFG/issues/277

 

https://github.com/RobertBeckebans/RBDOOM-3-BFG_assets_mod1

 

 

 
models/mapobjects/materialorb/container
{
    basecolormap models/mapobjects/materialorb/substance/metal006_basecolor.png
    normalmap models/mapobjects/materialorb/substance/metal006_normal.png
    specularmap models/mapobjects/materialorb/substance/metal006_rmao.png
}

models/mapobjects/materialorb/base
{
    basecolormap models/mapobjects/materialorb/substance/metal006_basecolor.png
    normalmap models/mapobjects/materialorb/substance/metal006_normal.png
    specularmap models/mapobjects/materialorb/substance/metal006_rmao.png
}


models/mapobjects/materialorb/pbrspheres
{
    basecolormap _white
    normalmap _flat
    specularmap models/mapobjects/materialorb/images/pbrspheres_rmao.png
}
 
If we wanted to support this we'd probably want to add something like "pbrmap" rather than replacing all speculars.
  • Like 1

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to post
Share on other sites

Hmm, I guess he's packing all the info into the specular image. Probably color channels?

 

 

    specularmap models/mapobjects/materialorb/images/pbrspheres_rmao.png

 

RMAO most likely stands for roughness, metallness and ambient occlusion. I also baked AO and also used SSAO on Sketchfab. Baking AO can be tricky on some meshes where geometry is not suitable, e.g. overlapping polygons. Here I had trouble with belt.

 

nzKoiC1.jpg

  • Like 1

It's only a model...

Link to post
Share on other sites
  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...