Jump to content


Photo

fhDOOM engine improvements

engine feature graphics improvement opengl glsl lighting shadows parallax shadowmapping

  • Please log in to reply
77 replies to this topic

#51 HMart

HMart

    Advanced Member

  • Member
  • PipPipPip
  • 539 posts

Posted 14 May 2017 - 04:52 PM

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, 14 May 2017 - 04:52 PM.


#52 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 566 posts

Posted 15 May 2017 - 01:42 AM

It is but glsl is not C.



#53 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 566 posts

Posted 15 May 2017 - 04:32 AM

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.


  • HMart and MirceaKitsune like this

#54 MirceaKitsune

MirceaKitsune

    Advanced Member

  • Member
  • PipPipPip
  • 599 posts

Posted 15 May 2017 - 06:11 AM

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?



#55 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 566 posts

Posted 15 May 2017 - 06:17 AM

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.



#56 New Horizon

New Horizon

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 13766 posts

Posted 15 May 2017 - 07:33 AM

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



#57 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 566 posts

Posted 15 May 2017 - 07:46 AM

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.



#58 New Horizon

New Horizon

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 13766 posts

Posted 15 May 2017 - 08:00 AM

Is 2017 C slower or faster than 1987 assembler?

 

I have no idea to be honest! lol  Not my area, which is why I asked. :)



#59 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7810 posts

Posted 15 May 2017 - 08:03 AM

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.c...ds/the-dark-mod

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

#60 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 566 posts

Posted 15 May 2017 - 08:11 AM

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.



#61 HMart

HMart

    Advanced Member

  • Member
  • PipPipPip
  • 539 posts

Posted 15 May 2017 - 09:10 AM

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, 15 May 2017 - 09:26 AM.


#62 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7810 posts

Posted 15 May 2017 - 09:50 AM

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.c...ds/the-dark-mod

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

#63 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 566 posts

Posted 15 May 2017 - 10:07 AM

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.



#64 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 566 posts

Posted 15 May 2017 - 10:17 AM

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;	
}


#65 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7810 posts

Posted 15 May 2017 - 10:34 AM

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/i.../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.c...ds/the-dark-mod

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

#66 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 566 posts

Posted 15 May 2017 - 10:44 AM

Can we just copy paste glsl from https://github.com/r...se/renderprogs?



#67 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7810 posts

Posted 15 May 2017 - 10:52 AM

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.c...ds/the-dark-mod

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

#68 Arcturus

Arcturus

    Advanced Member

  • Development Role
  • PipPipPip
  • 1579 posts

Posted 15 May 2017 - 03:32 PM

Does it mean we can have PBR now? https://sketchfab.co...ef2eb034fff9fb9


  • Gast likes this

It's only a model... /// My channel on YouTube /// CGtrader , Turbosquid


#69 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 566 posts

Posted 15 May 2017 - 04:05 PM

Lol, a guard wearing rubber gloves...



#70 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7810 posts

Posted 15 May 2017 - 04:11 PM

Does it mean we can have PBR now? https://sketchfab.co...ef2eb034fff9fb9

 

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/R...-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.c...ds/the-dark-mod

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

#71 Arcturus

Arcturus

    Advanced Member

  • Development Role
  • PipPipPip
  • 1579 posts

Posted 16 May 2017 - 11:41 AM

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


  • nbohr1more and Anderson like this

It's only a model... /// My channel on YouTube /// CGtrader , Turbosquid


#72 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7810 posts

Posted 16 May 2017 - 12:47 PM

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/R...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.
  • Anderson likes this
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

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

#73 Arcturus

Arcturus

    Advanced Member

  • Development Role
  • PipPipPip
  • 1579 posts

Posted 16 May 2017 - 01:06 PM

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


  • Anderson likes this

It's only a model... /// My channel on YouTube /// CGtrader , Turbosquid


#74 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 566 posts

Posted 09 September 2017 - 02:57 PM

How do you make a shadow map for a point light?



#75 cabalistic

cabalistic

    Member

  • Member
  • PipPip
  • 80 posts

Posted 10 September 2017 - 10:40 AM

Typically by splitting it into six shadow maps (or a cube map) for each room direction.







Also tagged with one or more of these keywords: engine, feature, graphics, improvement, opengl, glsl, lighting, shadows, parallax, shadowmapping

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users