Jump to content
The Dark Mod Forums
Sign in to follow this  
duzenko

GLSL custom shaders - a mapper wanted.

Recommended Posts

So GLSL allows mappers to include water that looks like https://www.shadertoy.com/view/Ms2SD1 into their maps?

 

Yes if TDM GLSL version supports those features but i'm sure is not a matter of copy pasting the shader code from shader toy, it needs to be reworked to support TDM engine particularities like lighting, geometry, etc.

 

About shaders one that i would love TDM to have some day is volumetric lighting.

 

https://www.shadertoy.com/view/4dsGRn

 

Fallout4_graph05web.jpg

Edited by HMart
  • Like 3

Share this post


Link to post
Share on other sites

So GLSL allows mappers to include water that looks like https://www.shadertoy.com/view/Ms2SD1 into their maps?

If it's using static vertex data then I think yes. In fact, I would like to work on that demo for TDM as a proof of concept and an engine capability check.

 

 

About shaders one that i would love TDM to have some day is volumetric lighting.

 

https://www.shadertoy.com/view/4dsGRn

 

 

Can you insert a translucent cone in the skybox area? It might look like that.

  • Like 2

Amnesty for Bikerdude!

Share this post


Link to post
Share on other sites

You can put a cone model/brush with translucent textures but it won't look that good. Of note is that the shadertoy link presents volumetric lighting but the screenshot is god rays, which are a post-processing effect (still a shader, but different; they're always based on your view). I (and I know Judith, too) am waiting for the day to come where TDM might have the emissive materials from UE3 so that we may throw the current, ugly particle hacks for faking volumetric lighting away.

  • Like 1

My FMs: The King of Diamonds (2016)



| Visit my Mapbook thread sometimes! | Read my tutorial on Image-Based Lighting Workflows for TDM! |

Share this post


Link to post
Share on other sites

I (and I know Judith, too) am waiting for the day to come where TDM might have the emissive materials from UE3 so that we may throw the current, ugly particle hacks for faking volumetric lighting away.

 

Definitely, although I'm not sure why TDM can't have it already. AFAIK, this is just a posprocess effect. Edit: the main problem with TDM Bloom is that it can't go beyond the bounds of a model, at least not with current postprocess settings. Other engines allow that easily. Maybe it's because other engines have dedicated emissive slot, while TDM just uses blend add mode? No idea.

Edited by Judith

Share this post


Link to post
Share on other sites

I would suggest creating a separate forum thread with a feature request for emissive materials/volumetric lights.

  • Like 1

Amnesty for Bikerdude!

Share this post


Link to post
Share on other sites

You can put a cone model/brush with translucent textures but it won't look that good.

Although it needn't look that bad either: see http://forums.thedarkmod.com/topic/9082-newbie-darkradiant-questions/page-245?do=findComment&comment=375979 for a basic example (easy to set up with func_beam entities). It won't react to the player's view angle or the visibility of the 'light source', though, which I think is the kind of thing Epifire was asking about in http://forums.thedarkmod.com/topic/17301-directional-based-visibility/ -- so it could certainly be improved upon, and I'll be interested in the volumetric lighting thread.


Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Share this post


Link to post
Share on other sites

How did this (the material stage GLSL support) turn out? I see it made it into 2.07 but I don't remember any fanfare for the new feature. (Hence also no documentation I know of, though glsl.h seems to provide clues about available uniforms.) Is it considered available for mapper use, or is it unstable?


Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Share this post


Link to post
Share on other sites
1 hour ago, VanishedOne said:

How did this (the material stage GLSL support) turn out? I see it made it into 2.07 but I don't remember any fanfare for the new feature. (Hence also no documentation I know of, though glsl.h seems to provide clues about available uniforms.) Is it considered available for mapper use, or is it unstable?

The problem is not supporting GLSL shaders, afaik TDM already does, the problem is making the glsl shaders themselves. 

Someone from the team (coders mostly) needs to take some GLSL shaders from shader toy and make them work in TDM engine or make ones from scratch but afaik that requires good trigonometry/math skills.

I converted some post-process GLSL shaders to work in the FHDoom engine but it was, hit and miss because I don't know much about writing shaders from scratch. 

 

Here is a post-process noise shader that I converted and know it works, in the FHDoom engine, don't know how shaders are written for TDM...

 

vertex shader

#include "global.inc"

layout(location = 0) in vec3 vertex_position;
layout(location = 1) in vec2 vertex_texcoord;

out vs_output
{
  vec2 texcoord;
} result;

void main()
{
	gl_Position = rpProjectionMatrix * rpModelViewMatrix * vec4(vertex_position, 1.0);  
  result.texcoord = vertex_texcoord;
}

fragment shader (pixel shader)

#include "global.inc"

layout(binding = 0) uniform sampler2D InputTexture;

// vec4 shaderParm0 timer;   
// vec4 shaderParm1 amount;

in vs_output
{
  vec2 texcoord;
} frag;

out vec4 FragColor;

void main()
{
	vec2 texSize = textureSize(InputTexture, 0);

	vec2 uv = frag.texcoord;
    uv *=  1.0 - uv.yx;

	vec4 src = texture(InputTexture, frag.texcoord);
	vec4 c = vec4(src.rgb, 1.0);
	
	float mDot = dot( frag.texcoord.xy , vec2(12.9898,78.233) + shaderParm0.x );
	float mFract = fract(sin(mDot) * 43758.5453);
	
	c += (mFract - 0.5)*shaderParm1.x;
	
    FragColor = vec4(c);
}

 

shader material

textures/glsltest/debugNoiseShader
{
    noshadows
    translucent
    sort postProcess
    {
		blend 	add
		
        vertexShader    noise.vp
        fragmentShader  noise.fp
		
        shaderParm 0     time * 0.05 // timer
        shaderParm 1 	 0.1 // amount
		
        shaderMap 0     _currentRender
    }
}

c++ code  called in the playerView.cpp file inside the SingleView() function...

if ( !pm_thirdPerson.GetBool() && !g_skipViewEffects.GetBool() ) {

        ...

		const idMaterial *mtr = declManager->FindMaterial("textures/glsltest/debugNoiseShader", false);
		if (pp_noise.GetBool())
		{
			renderSystem->SetColor4(1.0f, 1.0f, 1.0f, 1.0f);
			renderSystem->DrawStretchPic(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 1, 1, mtr);
		}


		player->DrawHUD( hud );

        ...

Right now I have a problem rendering more than one post-process effect at the same time, this indicates to me that this is not the best way to render them but my knowledge on this is limited. Any idea would be welcomed.

Edited by HMart

Share this post


Link to post
Share on other sites
12 hours ago, VanishedOne said:

How did this (the material stage GLSL support) turn out? I see it made it into 2.07 but I don't remember any fanfare for the new feature. (Hence also no documentation I know of, though glsl.h seems to provide clues about available uniforms.) Is it considered available for mapper use, or is it unstable?

Mappers are welcome to try it

  • Like 1

Amnesty for Bikerdude!

Share this post


Link to post
Share on other sites
On 8/20/2019 at 12:12 AM, VanishedOne said:

How did this (the material stage GLSL support) turn out? I see it made it into 2.07 but I don't remember any fanfare for the new feature. (Hence also no documentation I know of, though glsl.h seems to provide clues about available uniforms.) Is it considered available for mapper use, or is it unstable?

The thing I am really worried about is supporting custom GLSL shaders. We have discussed it a bit without any conclusion.

Imagine some mapper creates a custom GLSL shader for his material and it works. Then developers have to change something, e.g. move to newer GL version. Suddenly these custom shaders stop working because something also changes on GLSL side and the syntax must be changed. It is not clear how this could be resolved, aside from developers converting all such custom shaders and repacking missions.

In case of ARB shaders, it turned out that there is only one custom shader in all the FMs ever created, and it is used only on one TV box. No player would notice it if it stops working. But GLSL is much easier to use than ARB, so it is much more likely that mappers would use it.

This is probably the only reason for weak public exposure.

  • Thanks 1

Share this post


Link to post
Share on other sites

I see you found metaball.vfp. :)

Apparently neither of these ARB shaders has ever been used in a released FM, then:

(Though some FMs do pack versions of shaders in the HeatHaze family that presumably weren't yet in core when they were released.)

  • Like 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

×
×
  • Create New...