This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit ecfdf315187c07e787f5b28859883b3d98b84982
Author: MAN-AT-ARMS <m4n4t4...@gmail.com>
Date:   Thu Dec 10 11:35:17 2015 -0500

    All: Rend2: Add r_glossIsRoughness
---
 MP/code/rend2/tr_glsl.c   |  3 +++
 MP/code/rend2/tr_init.c   |  2 ++
 MP/code/rend2/tr_local.h  |  1 +
 MP/code/rend2/tr_shade.c  |  3 +--
 MP/code/rend2/tr_shader.c | 49 +++++++++++++++++++++++++++++++++++++++++------
 SP/code/rend2/tr_glsl.c   |  3 +++
 SP/code/rend2/tr_init.c   |  2 ++
 SP/code/rend2/tr_local.h  |  1 +
 SP/code/rend2/tr_shade.c  |  3 +--
 SP/code/rend2/tr_shader.c | 49 +++++++++++++++++++++++++++++++++++++++++------
 10 files changed, 100 insertions(+), 16 deletions(-)

diff --git a/MP/code/rend2/tr_glsl.c b/MP/code/rend2/tr_glsl.c
index 9a10e12..9d87bad 100644
--- a/MP/code/rend2/tr_glsl.c
+++ b/MP/code/rend2/tr_glsl.c
@@ -1043,6 +1043,9 @@ void GLSL_InitGPUShaders(void)
                if (r_specularIsMetallic->value)
                        Q_strcat(extradefines, 1024, "#define 
SPECULAR_IS_METALLIC\n");
 
+               if (r_glossIsRoughness->value)
+                       Q_strcat(extradefines, 1024, "#define 
GLOSS_IS_ROUGHNESS\n");
+
                if (r_dlightMode->integer >= 2)
                        Q_strcat(extradefines, 1024, "#define USE_SHADOWMAP\n");
 
diff --git a/MP/code/rend2/tr_init.c b/MP/code/rend2/tr_init.c
index 42b19b7..0bf2cde 100644
--- a/MP/code/rend2/tr_init.c
+++ b/MP/code/rend2/tr_init.c
@@ -162,6 +162,7 @@ cvar_t  *r_deluxeMapping;
 cvar_t  *r_parallaxMapping;
 cvar_t  *r_cubeMapping;
 cvar_t  *r_specularIsMetallic;
+cvar_t  *r_glossIsRoughness;
 cvar_t  *r_baseNormalX;
 cvar_t  *r_baseNormalY;
 cvar_t  *r_baseParallax;
@@ -1326,6 +1327,7 @@ void R_Register( void ) {
        r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE 
| CVAR_LATCH );
        r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
        r_specularIsMetallic = ri.Cvar_Get( "r_specularIsMetallic", "0", 
CVAR_ARCHIVE | CVAR_LATCH );
+       r_glossIsRoughness = ri.Cvar_Get("r_glossIsRoughness", "0", 
CVAR_ARCHIVE | CVAR_LATCH);
        r_baseNormalX = ri.Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | 
CVAR_LATCH );
        r_baseNormalY = ri.Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | 
CVAR_LATCH );
        r_baseParallax = ri.Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | 
CVAR_LATCH );
diff --git a/MP/code/rend2/tr_local.h b/MP/code/rend2/tr_local.h
index 8d46e50..a0e46c2 100644
--- a/MP/code/rend2/tr_local.h
+++ b/MP/code/rend2/tr_local.h
@@ -1985,6 +1985,7 @@ extern  cvar_t  *r_deluxeMapping;
 extern  cvar_t  *r_parallaxMapping;
 extern  cvar_t  *r_cubeMapping;
 extern  cvar_t  *r_specularIsMetallic;
+extern  cvar_t  *r_glossIsRoughness;
 extern  cvar_t  *r_baseNormalX;
 extern  cvar_t  *r_baseNormalY;
 extern  cvar_t  *r_baseParallax;
diff --git a/MP/code/rend2/tr_shade.c b/MP/code/rend2/tr_shade.c
index abd214e..f4f3bb8 100644
--- a/MP/code/rend2/tr_shade.c
+++ b/MP/code/rend2/tr_shade.c
@@ -484,11 +484,10 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
                || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR)
                || ((blend & GLS_DSTBLEND_BITS) == 
GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);
 
-       qboolean isWorldDraw = !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL);
-
 #if defined(USE_OVERBRIGHT)
        float exactLight = 1.0f;
 #else
+       qboolean isWorldDraw = !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL);
        float exactLight = (isBlend || !isWorldDraw) ? 1.0f : (float)(1 << 
r_mapOverBrightBits->integer);
 #endif
 
diff --git a/MP/code/rend2/tr_shader.c b/MP/code/rend2/tr_shader.c
index c5ba330..075ac71 100644
--- a/MP/code/rend2/tr_shader.c
+++ b/MP/code/rend2/tr_shader.c
@@ -932,17 +932,23 @@ static qboolean ParseStage( shaderStage_t *stage, char 
**text ) {
 
                        exponent = atof( token );
 
-                       // Change shininess to gloss
-                       // FIXME: assumes max exponent of 8192 and min of 1, 
must change here if altered in lightall_fp.glsl
-                       exponent = CLAMP(exponent, 1.0, 8192.0);
-
-                       stage->specularScale[3] = log(exponent) / log(8192.0);
+                       if (r_glossIsRoughness->integer)
+                               stage->specularScale[3] = powf(2.0f / (exponent 
+ 2.0), 0.25);
+                       else
+                       {
+                               // Change shininess to gloss
+                               // Assumes max exponent of 8190 and min of 0, 
must change here if altered in lightall_fp.glsl
+                               exponent = CLAMP(exponent, 0.0f, 8190.0f);
+                               stage->specularScale[3] = (log2f(exponent + 
2.0f) - 1.0f) / 12.0f;
+                       }
                }
                //
                // gloss <value>
                //
                else if (!Q_stricmp(token, "gloss"))
                {
+                       float gloss;
+
                        token = COM_ParseExt(text, qfalse);
                        if ( token[0] == 0 )
                        {
@@ -950,7 +956,38 @@ static qboolean ParseStage( shaderStage_t *stage, char 
**text ) {
                                continue;
                        }
 
-                       stage->specularScale[3] = atof( token );
+                       gloss = atof(token);
+
+                       if (r_glossIsRoughness->integer)
+                               stage->specularScale[3] = exp2f(-3.0f * gloss);
+                       else
+                               stage->specularScale[3] = gloss;
+               }
+               //
+               // roughness <value>
+               //
+               else if (!Q_stricmp(token, "roughness"))
+               {
+                       float roughness;
+
+                       token = COM_ParseExt(text, qfalse);
+                       if (token[0] == 0)
+                       {
+                               ri.Printf(PRINT_WARNING, "WARNING: missing 
parameter for roughness in shader '%s'\n", shader.name);
+                               continue;
+                       }
+
+                       roughness = atof(token);
+
+                       if (r_glossIsRoughness->integer)
+                               stage->specularScale[3] = roughness;
+                       else
+                       {
+                               if (roughness >= 0.125)
+                                       stage->specularScale[3] = log2f(1.0f / 
roughness) / 3.0f;
+                               else
+                                       stage->specularScale[3] = 1.0f;
+                       }
                }
                //
                // parallaxDepth <value>
diff --git a/SP/code/rend2/tr_glsl.c b/SP/code/rend2/tr_glsl.c
index 9a10e12..9d87bad 100644
--- a/SP/code/rend2/tr_glsl.c
+++ b/SP/code/rend2/tr_glsl.c
@@ -1043,6 +1043,9 @@ void GLSL_InitGPUShaders(void)
                if (r_specularIsMetallic->value)
                        Q_strcat(extradefines, 1024, "#define 
SPECULAR_IS_METALLIC\n");
 
+               if (r_glossIsRoughness->value)
+                       Q_strcat(extradefines, 1024, "#define 
GLOSS_IS_ROUGHNESS\n");
+
                if (r_dlightMode->integer >= 2)
                        Q_strcat(extradefines, 1024, "#define USE_SHADOWMAP\n");
 
diff --git a/SP/code/rend2/tr_init.c b/SP/code/rend2/tr_init.c
index 07fce1a..ce992bf 100644
--- a/SP/code/rend2/tr_init.c
+++ b/SP/code/rend2/tr_init.c
@@ -167,6 +167,7 @@ cvar_t  *r_deluxeMapping;
 cvar_t  *r_parallaxMapping;
 cvar_t  *r_cubeMapping;
 cvar_t  *r_specularIsMetallic;
+cvar_t  *r_glossIsRoughness;
 cvar_t  *r_baseNormalX;
 cvar_t  *r_baseNormalY;
 cvar_t  *r_baseParallax;
@@ -1349,6 +1350,7 @@ void R_Register( void ) {
        r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE 
| CVAR_LATCH );
        r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
        r_specularIsMetallic = ri.Cvar_Get( "r_specularIsMetallic", "0", 
CVAR_ARCHIVE | CVAR_LATCH );
+       r_glossIsRoughness = ri.Cvar_Get("r_glossIsRoughness", "0", 
CVAR_ARCHIVE | CVAR_LATCH);
        r_baseNormalX = ri.Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | 
CVAR_LATCH );
        r_baseNormalY = ri.Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | 
CVAR_LATCH );
        r_baseParallax = ri.Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | 
CVAR_LATCH );
diff --git a/SP/code/rend2/tr_local.h b/SP/code/rend2/tr_local.h
index 29048cc..e48ad8e 100644
--- a/SP/code/rend2/tr_local.h
+++ b/SP/code/rend2/tr_local.h
@@ -2005,6 +2005,7 @@ extern  cvar_t  *r_deluxeMapping;
 extern  cvar_t  *r_parallaxMapping;
 extern  cvar_t  *r_cubeMapping;
 extern  cvar_t  *r_specularIsMetallic;
+extern  cvar_t  *r_glossIsRoughness;
 extern  cvar_t  *r_baseNormalX;
 extern  cvar_t  *r_baseNormalY;
 extern  cvar_t  *r_baseParallax;
diff --git a/SP/code/rend2/tr_shade.c b/SP/code/rend2/tr_shade.c
index 6476445..7a0f724 100644
--- a/SP/code/rend2/tr_shade.c
+++ b/SP/code/rend2/tr_shade.c
@@ -478,11 +478,10 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
                || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR)
                || ((blend & GLS_DSTBLEND_BITS) == 
GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);
 
-       qboolean isWorldDraw = !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL);
-
 #if defined(USE_OVERBRIGHT)
        float exactLight = 1.0f;
 #else
+       qboolean isWorldDraw = !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL);
        float exactLight = (isBlend || !isWorldDraw) ? 1.0f : (float)(1 << 
r_mapOverBrightBits->integer);
 #endif
 
diff --git a/SP/code/rend2/tr_shader.c b/SP/code/rend2/tr_shader.c
index 47f9a36..e77f4f6 100644
--- a/SP/code/rend2/tr_shader.c
+++ b/SP/code/rend2/tr_shader.c
@@ -930,17 +930,23 @@ static qboolean ParseStage( shaderStage_t *stage, char 
**text ) {
 
                        exponent = atof( token );
 
-                       // Change shininess to gloss
-                       // FIXME: assumes max exponent of 8192 and min of 1, 
must change here if altered in lightall_fp.glsl
-                       exponent = CLAMP(exponent, 1.0, 8192.0);
-
-                       stage->specularScale[3] = log(exponent) / log(8192.0);
+                       if (r_glossIsRoughness->integer)
+                               stage->specularScale[3] = powf(2.0f / (exponent 
+ 2.0), 0.25);
+                       else
+                       {
+                               // Change shininess to gloss
+                               // Assumes max exponent of 8190 and min of 0, 
must change here if altered in lightall_fp.glsl
+                               exponent = CLAMP(exponent, 0.0f, 8190.0f);
+                               stage->specularScale[3] = (log2f(exponent + 
2.0f) - 1.0f) / 12.0f;
+                       }
                }
                //
                // gloss <value>
                //
                else if (!Q_stricmp(token, "gloss"))
                {
+                       float gloss;
+
                        token = COM_ParseExt(text, qfalse);
                        if ( token[0] == 0 )
                        {
@@ -948,7 +954,38 @@ static qboolean ParseStage( shaderStage_t *stage, char 
**text ) {
                                continue;
                        }
 
-                       stage->specularScale[3] = atof( token );
+                       gloss = atof(token);
+
+                       if (r_glossIsRoughness->integer)
+                               stage->specularScale[3] = exp2f(-3.0f * gloss);
+                       else
+                               stage->specularScale[3] = gloss;
+               }
+               //
+               // roughness <value>
+               //
+               else if (!Q_stricmp(token, "roughness"))
+               {
+                       float roughness;
+
+                       token = COM_ParseExt(text, qfalse);
+                       if (token[0] == 0)
+                       {
+                               ri.Printf(PRINT_WARNING, "WARNING: missing 
parameter for roughness in shader '%s'\n", shader.name);
+                               continue;
+                       }
+
+                       roughness = atof(token);
+
+                       if (r_glossIsRoughness->integer)
+                               stage->specularScale[3] = roughness;
+                       else
+                       {
+                               if (roughness >= 0.125)
+                                       stage->specularScale[3] = log2f(1.0f / 
roughness) / 3.0f;
+                               else
+                                       stage->specularScale[3] = 1.0f;
+                       }
                }
                //
                // parallaxDepth <value>

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/iortcw.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to