Page 1 of 1

External texture support for texture shaders

PostPosted: Thu Feb 22, 2018 7:20 am
by Marisa Kirisame
We already have this for screen shaders and it's all good, but I've been thinking that this could also get some use on texture shaders. Overlays, distortions, all sorts of stuff.

Re: External texture support for texture shaders

PostPosted: Thu Feb 22, 2018 8:16 am
by dpJudas
You will probably not see any improvements in this area until after the materials branch.

User shaders for materials are complicated. The light code needs to cooperate with the output of the shader. For example, if you want to use a brightmap, the shader needs to output both the primary texture color and the emissive color.

The current internal brightmap shader looks like this:

Code: Select allExpand view
vec4 ProcessTexel()
{
   return getTexel(vTexCoord.st);
}

vec4 ProcessLight(vec4 color)
{
   vec4 brightpix = desaturate(texture(texture2, vTexCoord.st));
   return vec4(min (color.rgb + brightpix.rgb, 1.0), color.a);
}

As you can see, there's two outputs. ProcessTexel and ProcessLight. For a material with a normal map and specular there's need for an additional ProcessNormal and ProcessSpecular. For PBR there's ProcessRoughness and ProcessMetallic. All of this needs to be set up in GLDEFS so that GZDoom knows what kind of output is implemented in the shader.

That in turn affects texture binding as each of those needs a place to sample from. Should that always be custom textures for custom shaders? There's a bunch of stuff like this that needs to be thought through. A premature quick fix for the current hardware shaders will only cause cursing down the road.

TL;DR: Don't expect to get this feature for some time. It isn't as simple to add as for the screen shaders.

Re: External texture support for texture shaders

PostPosted: Thu Feb 22, 2018 5:36 pm
by Marisa Kirisame
TBH I only wanted these for the diffuse...

Re: External texture support for texture shaders

PostPosted: Thu Feb 22, 2018 5:47 pm
by dpJudas
With a reply like that I guess you'll have to file the PR yourself..

Re: External texture support for texture shaders

PostPosted: Thu Feb 22, 2018 6:09 pm
by Marisa Kirisame
I'll try to figure out how. I haven't really touched graphics-related gzdoom code yet.

Edit: What have I gotten into...

Re: External texture support for texture shaders

PostPosted: Thu Jun 14, 2018 9:39 am
by Major Cooke
This would also be greatly appreciated for models.

Re: External texture support for texture shaders

PostPosted: Thu Jun 14, 2018 10:27 am
by Graf Zahl
Not before Vulkan is working.

Re: External texture support for texture shaders

PostPosted: Thu Jun 14, 2018 10:31 pm
by Pixel Eater
Dangit! I literally just ran into this problem :tongue:

Re: External texture support for texture shaders

PostPosted: Thu Jul 05, 2018 7:49 am
by UsernameAK

Re: External texture support for texture shaders

PostPosted: Thu Jul 05, 2018 8:21 am
by Pixel Eater
Thanks UsenameAK!

I'll be using this for making alpha maps :)

Re: External texture support for texture shaders

PostPosted: Sun Jul 08, 2018 2:23 pm
by Talon1024
Is this the kind of thing that would make this effect possible in GZDoom? That would be really awesome.

Re: External texture support for texture shaders

PostPosted: Sat Jul 21, 2018 3:21 pm
by Diode
It looks like there's progress on this on github. Is this slated for the next version?

Re: External texture support for texture shaders

PostPosted: Sat Jul 21, 2018 3:41 pm
by Graf Zahl
Yes.