Detail texture splatting is ready!
Moderator: Moderators
Re: Detail texture splatting is ready!
Latest Buildbot Spring does nothing for me over here, on a 9800GT. Where is a working win32 binary?
Re: Detail texture splatting is ready!
Some deeper issues have cropped up, since I know the files get loaded, and the shader gets compiled, but its not the shader doing the actual rendering...
Re: Detail texture splatting is ready!
OK, so I wasn't crazy about that part, either. Anything helpful I can contribute?
Re: Detail texture splatting is ready!
Should work now. Shadows must be ON!
Re: Detail texture splatting is ready!
Nothing happened with the latest buildbot upload (from yesterday, mind you). Doesn't seem to be working over here. Do we get warnings / runtime crashes if that GLSL won't compile?
I'm waiting to see if the latest installer compiles.
I'm waiting to see if the latest installer compiles.
Re: Detail texture splatting is ready!
AHA.
You *must* have a speculartex defined, or it doesn't work. KK. Works here, user error.
You *must* have a speculartex defined, or it doesn't work. KK. Works here, user error.
Re: Detail texture splatting is ready!
Try the map Melt_v1, included in this topic.
Re: Detail texture splatting is ready!
Will do.
Seeing something very odd, though. I darkened the speculartex to a single very dark shade of gray, trying to tone it down, on DreamIsland, and now it's massively overbright.
Everything's clearly working at this point, except however it's arriving at the lit values, so far as I can see.
That, and it appears water4 is currently broken on my hardware. I'll look at fixing that.
Seeing something very odd, though. I darkened the speculartex to a single very dark shade of gray, trying to tone it down, on DreamIsland, and now it's massively overbright.
Everything's clearly working at this point, except however it's arriving at the lit values, so far as I can see.
That, and it appears water4 is currently broken on my hardware. I'll look at fixing that.
Re: Detail texture splatting is ready!
Fixed a few things. Now specular is controllable and natural, and doesn't result in bloom-like overbright unless you want it to; overbright is totally controllable via the RGB values of speculartex.
I think there are a couple of odd lines in the GLSL that may need to get trimmed, but that's pretty close. Note that the area with (small) overbright boost is confined to the sand, based on the color values used, which produces a subtler feel to the lighting (but cranking it up to very plastic-like whites is very easy). For maps where specular isn't all that desirable, you can just use a black speculartex, and the detailmaps still work just fine.
I think there are a couple of odd lines in the GLSL that may need to get trimmed, but that's pretty close. Note that the area with (small) overbright boost is confined to the sand, based on the color values used, which produces a subtler feel to the lighting (but cranking it up to very plastic-like whites is very easy). For maps where specular isn't all that desirable, you can just use a black speculartex, and the detailmaps still work just fine.
- Attachments
-
- springcontent.sdz
- (140.07 KiB) Downloaded 33 times
-
- dreamisland_rework.7z
- (3.84 MiB) Downloaded 49 times
Re: Detail texture splatting is ready!
I had issues with specular overbrightness as well, but dont post springcontent please, post the shader code, preferably diff-ed.
Re: Detail texture splatting is ready!
Sorry, I thought that was the most convenient way to give it to you to test really fast and verify my results (since I'm in ATi-land now, heh). Make sure to use that content, certain things had to be changed in important ways.
Here's the code:
As I said, I think this is "pretty close". Amongst other things, I was thinking that I could change the function of one of the spare channels (IIRC, there are now two that are essentially superfluous) and use it for glow. Heck, if we sent over the reflectioncube, I could also give us reflections... I think.
Here's the code:
Code: Select all
// ARB shader receives groundAmbientColor multiplied
// by this constant; shading-texture intensities are
// also pre-dimmed
#define SMF_INTENSITY_MUL (210 / 255.0)
#define SMF_ARB_LIGHTING 0
uniform vec4 lightDir;
varying vec3 viewDir;
varying vec3 halfDir;
varying float fogFactor;
varying float vertexHeight;
uniform sampler2D diffuseTex;
uniform sampler2D normalsTex;
uniform sampler2DShadow shadowTex;
uniform sampler2D detailTex;
uniform sampler2D specularTex;
uniform mat4 shadowMat;
uniform vec4 shadowParams;
uniform vec3 groundAmbientColor;
uniform vec3 groundDiffuseColor;
uniform vec3 groundSpecularColor;
uniform float groundShadowDensity;
#if (SMF_WATER_ABSORPTION == 1)
uniform vec3 waterMinColor;
uniform vec3 waterBaseColor;
uniform vec3 waterAbsorbColor;
#endif
#if (SMF_DETAIL_TEXTURE_SPLATTING == 1)
uniform sampler2D splatDetailTex;
uniform sampler2D splatDistrTex;
// per-channel splat intensity multipliers
uniform vec4 splatTexMults;
#endif
void main() {
vec2 tc0 = gl_TexCoord[0].st;
vec2 tc1 = gl_TexCoord[1].st;
vec2 tc2 = gl_TexCoord[2].st;
vec2 p17 = vec2(shadowParams.z, shadowParams.z);
vec2 p18 = vec2(shadowParams.w, shadowParams.w);
vec4 vertexShadowPos = shadowMat * gl_TexCoord[3];
vertexShadowPos.st *= (inversesqrt(abs(vertexShadowPos.st) + p17) + p18);
vertexShadowPos.st += shadowParams.xy;
vec3 normal = normalize((texture2D(normalsTex, tc1) * 2.0).rgb - 1.0);
float cosAngleDiffuse = min(max(dot(normalize(lightDir.xyz), normal), 0.0), 1.0);
float cosAngleSpecular = min(max(dot(normalize(halfDir), normal), 0.0), 1.0);
float specularExp = texture2D(specularTex, tc2).a * 16.0;
float specularPow = pow(cosAngleSpecular, specularExp);
vec4 diffuseCol = texture2D(diffuseTex, tc0);
vec3 specularCol = texture2D(specularTex, tc2).rgb;
#if (SMF_DETAIL_TEXTURE_SPLATTING == 0)
vec4 detailCol = normalize((texture2D(detailTex, gl_TexCoord[4].st) * 2.0) - 1.0);
#else
vec4 splatDistr = texture2D(splatDistrTex, tc2);
float detailInt =
(((texture2D(splatDetailTex, gl_TexCoord[4].st) * 2.0).r - 1.0) * (splatTexMults.r * splatDistr.r)) +
(((texture2D(splatDetailTex, gl_TexCoord[5].st) * 2.0).g - 1.0) * (splatTexMults.g * splatDistr.g)) +
(((texture2D(splatDetailTex, gl_TexCoord[6].st) * 2.0).b - 1.0) * (splatTexMults.b * splatDistr.b)) +
(((texture2D(splatDetailTex, gl_TexCoord[7].st) * 2.0).a - 1.0) * (splatTexMults.a * splatDistr.a));
vec4 detailCol = vec4(detailInt, detailInt, detailInt, 1.0);
#endif
// vec4 diffuseInt = texture2D(shadingTex, tc0);
vec4 diffuseInt =
vec4(groundAmbientColor, 1.0) +
vec4(groundDiffuseColor, 1.0) * cosAngleDiffuse;
vec4 ambientInt = vec4(groundAmbientColor, 1.0);
vec3 specularInt = specularCol * specularPow;
vec4 shadowInt = shadow2DProj(shadowTex, vertexShadowPos);
shadowInt.x = 1.0 - shadowInt.x;
shadowInt.x *= groundShadowDensity;
// shadowInt.x *= diffuseInt.w;
shadowInt.x = 1.0 - shadowInt.x;
vec4 shadeInt;
ambientInt.xyz *= SMF_INTENSITY_MUL;
diffuseInt.xyz *= SMF_INTENSITY_MUL;
diffuseInt.a = 1.0;
shadeInt = mix(ambientInt, diffuseInt, shadowInt.x);
#if (SMF_WATER_ABSORPTION == 1)
if (vertexHeight < 0.0) {
int vertexStepHeight = min(1023, int(-vertexHeight));
float waterLightInt = min((cosAngleDiffuse + 0.2) * 2.0, 1.0);
vec4 waterHeightColor = vec4(
max(waterMinColor.r, waterBaseColor.r - (waterAbsorbColor.r * vertexStepHeight)) * SMF_INTENSITY_MUL,
max(waterMinColor.g, waterBaseColor.g - (waterAbsorbColor.g * vertexStepHeight)) * SMF_INTENSITY_MUL,
max(waterMinColor.b, waterBaseColor.b - (waterAbsorbColor.b * vertexStepHeight)) * SMF_INTENSITY_MUL,
max(0.0, (255.0 + int(10.0 * vertexHeight)) / 255.0)
);
if (vertexHeight > -10.0) {
shadeInt.xyz =
(diffuseInt.xyz * (1.0 - (-vertexHeight * 0.1))) +
(waterHeightColor.xyz * (0.0 + (-vertexHeight * 0.1)) * waterLightInt);
} else {
shadeInt.xyz = (waterHeightColor.xyz * waterLightInt);
}
shadeInt.a = waterHeightColor.a;
shadeInt *= shadowInt.x;
}
#endif
gl_FragColor = (diffuseCol * detailCol) * shadeInt;
gl_FragColor.a = (gl_TexCoord[0].q * 0.1) + 1.0;
#if (SMF_ARB_LIGHTING == 0)
// no need to multiply by groundSpecularColor anymore
gl_FragColor.rgb += specularInt;
#endif
gl_FragColor = mix(gl_Fog.color, gl_FragColor, fogFactor);
}
Re: Detail texture splatting is ready!
Hey that's cool! Must take a look at splatting + specular just to try out some maps for Damned... I have made maps with only brown texture but with detail texture giving it the love :)Beherith wrote:Just a small curiosity:
The following map has a completely flat single color brown texture, everything else is splatting+specular.
http://beherith.eat-peet.net/stuff/mudkipz.sd7
Re: Detail texture splatting is ready!
Here is a variant that works if shadows are turned off. Unfortunately, just like sending the reflectioncube, that variable isn't available to the GLSL, but sending that state to this program and making the minor changes needed is trivial.
That said, since shadows are completely broken on ATi atm, it probably makes more sense for me to proceed with this variant and work on a new shadowmapping system via Lua.
Now I'll get back to work on implementing glow and simple map reflections, and re-adjusting to allow for a simpler tweak profile, as this is still a bit too much of a pain in the ass for most people to use, imo.
That said, since shadows are completely broken on ATi atm, it probably makes more sense for me to proceed with this variant and work on a new shadowmapping system via Lua.
Code: Select all
// ARB shader receives groundAmbientColor multiplied
// by this constant; shading-texture intensities are
// also pre-dimmed
#define SMF_INTENSITY_MUL (210 / 255.0)
#define SMF_ARB_LIGHTING 0
uniform vec4 lightDir;
varying vec3 viewDir;
varying vec3 halfDir;
varying float fogFactor;
varying float vertexHeight;
uniform sampler2D diffuseTex;
uniform sampler2D normalsTex;
uniform sampler2DShadow shadowTex;
uniform sampler2D detailTex;
uniform sampler2D specularTex;
uniform mat4 shadowMat;
uniform vec4 shadowParams;
uniform vec3 groundAmbientColor;
uniform vec3 groundDiffuseColor;
uniform vec3 groundSpecularColor;
uniform float groundShadowDensity;
#if (SMF_WATER_ABSORPTION == 1)
uniform vec3 waterMinColor;
uniform vec3 waterBaseColor;
uniform vec3 waterAbsorbColor;
#endif
#if (SMF_DETAIL_TEXTURE_SPLATTING == 1)
uniform sampler2D splatDetailTex;
uniform sampler2D splatDistrTex;
// per-channel splat intensity multipliers
uniform vec4 splatTexMults;
#endif
void main() {
vec2 tc0 = gl_TexCoord[0].st;
vec2 tc1 = gl_TexCoord[1].st;
vec2 tc2 = gl_TexCoord[2].st;
/*vec2 p17 = vec2(shadowParams.z, shadowParams.z);
vec2 p18 = vec2(shadowParams.w, shadowParams.w);
vec4 vertexShadowPos = shadowMat * gl_TexCoord[3];
vertexShadowPos.st *= (inversesqrt(abs(vertexShadowPos.st) + p17) + p18);
vertexShadowPos.st += shadowParams.xy;*/
vec3 normal = normalize((texture2D(normalsTex, tc1) * 2.0).rgb - 1.0);
float cosAngleDiffuse = min(max(dot(normalize(lightDir.xyz), normal), 0.0), 1.0);
float cosAngleSpecular = min(max(dot(normalize(halfDir), normal), 0.0), 1.0);
float specularExp = texture2D(specularTex, tc2).a * 16.0;
float specularPow = pow(cosAngleSpecular, specularExp);
vec4 diffuseCol = texture2D(diffuseTex, tc0);
vec3 specularCol = texture2D(specularTex, tc2).rgb;
#if (SMF_DETAIL_TEXTURE_SPLATTING == 0)
vec4 detailCol = normalize((texture2D(detailTex, gl_TexCoord[4].st) * 2.0) - 1.0);
#else
vec4 splatDistr = texture2D(splatDistrTex, tc2);
float detailInt =
(((texture2D(splatDetailTex, gl_TexCoord[4].st) * 2.0).r - 1.0) * (splatTexMults.r * splatDistr.r)) +
(((texture2D(splatDetailTex, gl_TexCoord[5].st) * 2.0).g - 1.0) * (splatTexMults.g * splatDistr.g)) +
(((texture2D(splatDetailTex, gl_TexCoord[6].st) * 2.0).b - 1.0) * (splatTexMults.b * splatDistr.b)) +
(((texture2D(splatDetailTex, gl_TexCoord[7].st) * 2.0).a - 1.0) * (splatTexMults.a * splatDistr.a));
vec4 detailCol = vec4(detailInt, detailInt, detailInt, 1.0);
#endif
// vec4 diffuseInt = texture2D(shadingTex, tc0);
vec4 diffuseInt =
vec4(groundAmbientColor, 1.0) +
vec4(groundDiffuseColor, 1.0) * cosAngleDiffuse;
vec4 ambientInt = vec4(groundAmbientColor, 1.0);
vec3 specularInt = specularCol * specularPow;
//vec4 shadowInt = shadow2DProj(shadowTex, vertexShadowPos);
//shadowInt.x = 1.0 - shadowInt.x;
//shadowInt.x *= groundShadowDensity;
// shadowInt.x *= diffuseInt.w;
// shadowInt.x = 1.0 - shadowInt.x;
vec4 shadeInt;
ambientInt.xyz *= SMF_INTENSITY_MUL;
diffuseInt.xyz *= SMF_INTENSITY_MUL;
diffuseInt.a = 1.0;
//shadeInt = mix(ambientInt, diffuseInt, shadowInt.x);
shadeInt = diffuseInt;
#if (SMF_WATER_ABSORPTION == 1)
if (vertexHeight < 0.0) {
int vertexStepHeight = min(1023, int(-vertexHeight));
float waterLightInt = min((cosAngleDiffuse + 0.2) * 2.0, 1.0);
vec4 waterHeightColor = vec4(
max(waterMinColor.r, waterBaseColor.r - (waterAbsorbColor.r * vertexStepHeight)) * SMF_INTENSITY_MUL,
max(waterMinColor.g, waterBaseColor.g - (waterAbsorbColor.g * vertexStepHeight)) * SMF_INTENSITY_MUL,
max(waterMinColor.b, waterBaseColor.b - (waterAbsorbColor.b * vertexStepHeight)) * SMF_INTENSITY_MUL,
max(0.0, (255.0 + int(10.0 * vertexHeight)) / 255.0)
);
if (vertexHeight > -10.0) {
shadeInt.xyz =
(diffuseInt.xyz * (1.0 - (-vertexHeight * 0.1))) +
(waterHeightColor.xyz * (0.0 + (-vertexHeight * 0.1)) * waterLightInt);
} else {
shadeInt.xyz = (waterHeightColor.xyz * waterLightInt);
}
shadeInt.a = waterHeightColor.a;
//shadeInt *= shadowInt.x;
}
#endif
gl_FragColor = (diffuseCol * detailCol) * shadeInt;
gl_FragColor.a = (gl_TexCoord[0].q * 0.1) + 1.0;
#if (SMF_ARB_LIGHTING == 0)
// no need to multiply by groundSpecularColor anymore
gl_FragColor.rgb += specularInt;
#endif
gl_FragColor = mix(gl_Fog.color, gl_FragColor, fogFactor);
}