Bright Maps + Shaders

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Bright Maps + Shaders

Re: Bright Maps + Shaders

by Graf Zahl » Sat May 02, 2020 8:50 am

This info is soon to be obsolete, in future versions brightmaps will be independent of the shaders.

Re: Bright Maps + Shaders

by Xabis » Sat May 02, 2020 8:44 am

Thanks for adding this info.

This looks like the correct implementation, and it even supports the Texture/Define props needed for generalizations:

Wiki could probably stand to be updated.

Code: Select all

material texture "TEXNAME"
{
    shader "shaders/SHADERNAME.fp"
    normal "materials/normalmaps/TEXNAME.png"
    specular "materials/specular/TEXNAME.png"
    brightmap "materials/brightmaps/TEXNAME.png"
    Texture masktexture "materials/masks/TEXNAME.png"

    Speed 1
    Define MASKED
    Define AXIS = "x"
    Define DIRECTION = "1.0 -"
    Define COLOR1 = "vec3(0.2, 0.0, 0.0)"
    Define COLOR2 = "vec3(1.0, 0.0, 0.0)"

    glossiness 10.0
    specularlevel 0.5
}

Re: Bright Maps + Shaders

by phantombeta » Tue Apr 21, 2020 12:31 pm

@Xabis
This should be doable with just material block. It supports defining shaders within itself too. Here's a example:

Code: Select all

material texture "TEXNAME"
{
    shader "shaders/SHADERNAME.fp"
    normal "materials/normalmaps/TEXNAME.png"
    specular "materials/specular/TEXNAME.png"
    brightmap "materials/brightmaps/TEXNAME.png"
    glossiness 10.0
    specularlevel 0.5
}

Re: Bright Maps + Shaders

by Major Cooke » Tue Apr 21, 2020 10:50 am

The proper way to do it would be to use the brightmap keyword/option in the material itself now, according to phantombeta.

Re: Bright Maps + Shaders

by Xabis » Sat Apr 11, 2020 12:57 pm

Hello,

Apologies for the necro here, but for anyone else wanting this feature, you can do this with a simple hack. I am unsure what the minimum required gzdoom version is.

Code: Select all

HardwareShader TEXNAME
{
	Shader "shaders/SHADERLUMP"
	Speed 1.0
	Texture brighttexture "brightmaps/BMNAME.png"
	Define BRIGHTMAP
}
Should work with old-style Process and new-style ProcessTexel/ProcessMaterial types.

---------------------------------------------
UPDATE:
---------------------------------------------
If you want to have a shader applied, along with a material and brightmapping, you will need to specify the Material type in GLDEFS that matches what gzdoom selects (e.g. "specular" if using normal/specular without brightmaps; "specularbrightmap", if using bright map; "pbr" if using those). Then define the brightmap & material as you normally would.

In your shader, you will need to define ProcessMaterial, and provide an override that supports all of these, since the default does not for some reason.

EXAMPLE GLDEF ENTRY:

Code: Select all

HardwareShader texture TEXNAME
{
	Shader "shaders/SHADERNAME"
	Material specularbrightmap
}
brightmap texture TEXNAME { map "brightmaps/TEXNAME.png" }
material texture TEXNAME
{
	normal materials/normalmaps/TEXNAME.png
	specular materials/specular/TEXNAME.png

	glossiness 100
	specularlevel 40
}


Then the shader:

Code: Select all

vec4 ProcessTexel()
{
   //this is your shader code here
   return texture(tex, vTexCoord.st);
}

//this is basically a copy of shaders/glsl/func_spec.fp
//note: pbr will need to use whats in shaders/glsl/func_pbr.fp instead, which i didnt add here
Material ProcessMaterial()
{
	Material material;
	material.Base = ProcessTexel();
#ifdef NORMALMAP
	material.Normal = ApplyNormalMap(vTexCoord.st);
#endif
#ifdef SPECULAR
	material.Specular = texture(speculartexture, vTexCoord.st).rgb;
	material.Glossiness = uSpecularMaterial.x;
	material.SpecularLevel = uSpecularMaterial.y;
#endif
#if defined(BRIGHTMAP)
	material.Bright = texture(brighttexture, vTexCoord.st);
#endif
	return material;
}

Re: Bright Maps + Shaders

by Graf Zahl » Thu Nov 01, 2018 1:18 am

This should be doable now with hardware shaders being capable of having multiple layers. Of course it cannot be automatic, the custom shader needs to do the brightmapping itself.

Re: Bright Maps + Shaders

by Xabis » Wed Feb 07, 2018 4:00 pm

That is truly unfortunate.

Re: Bright Maps + Shaders

by dpJudas » Wed Feb 07, 2018 1:02 pm

It is a known limitation, partly due to the way code dealing with subshaders was written. Maybe it can be dealt with after the materials branch is finished, but until then I don't think this issue will be fixed.

Bright Maps + Shaders

by Xabis » Wed Feb 07, 2018 12:57 pm

I created a wall texture (not a sprite) that uses both a bright map and a shader.

So long as the shader is applied to the texture, the bright map is ignored. As soon as the shader is removed, the bright map begins working again. This occurs from at least gzdoom 2.3.2 all the way to 3.2.5.

If this is not a bug, please advise on what steps must be taken to apply both.

Top