material or GLSL compiler not nice behaviour[Remark]

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

material or GLSL compiler not nice behaviour[Remark]

Post by paul424 »

Ogre Version: :1 12 10 :
Operating System: :OpenSuse Tumbleweed:
Render System: :GLSL3Plus:
I wanted to write a message about strange message from Ogre.log, but now I see what it is, but let me say I don't like that behavior of ogre3d :
Hello what happened to command parameter light_specular_colour ? I keep getting errors like

Code: Select all

20:51:51: Error: ScriptCompiler - invalid parameters in DCW0000.material(25): Parameter called lightSpecularColour does not exist. 
20:51:51: Parsing script DCW0100.material
20:51:51: Error: ScriptCompiler - invalid parameters in DCW0100.material(25): Parameter called lightSpecularColour does not exist. 
20:51:51: Parsing script DCW0101.material
20:51:51: Error: ScriptCompiler - invalid parameters in DCW0101.material(25): Parameter called lightSpecularColour does not exist. 
20:51:51: Parsing script DCW0110.material
20:51:51: Error: ScriptCompiler - invalid parameters in DCW0110.material(26): Parameter called lightSpecularColour does not exist. 
20:51:51: Parsing script DCW1110.material
20:51:51: Error: ScriptCompiler - invalid parameters in DCW1110.material(25): Parameter called lightSpecularColour does not exist. 
20:51:51: Parsing script DCW1111.material
20:51:51: Error: ScriptCompiler - invalid parameters in DCW1111.material(26): Parameter called lightSpecularColour does not exist.

Example material code is like that :

Code: Select all

        param_named_auto lightSpecularColour light_specular_colour 0.0 

Example shader :

Code: Select all

#version 330  core


uniform sampler2D decalmap;
uniform sampler2D normalmap;
uniform sampler2D crossmap;
uniform sampler2D shadowmap;

uniform vec4 ambientLightColour;
uniform vec4 lightDiffuseColour; 
uniform vec4 lightSpecularColour;
uniform vec4 lightPos;
uniform vec4 cameraPosition;
uniform vec4 diffuseSurface;
uniform vec4 seatColor;
in vec2 out_UV0;
in vec2 out_UV1;
in vec2 out_UV2;
in vec3 FragPos;
in vec4 VertexPos;
in mat3 TBN;
 
out vec4 color;

void main (void)  
{  

    // compute Normal
    vec3 Normal = texture(normalmap, out_UV1.st).rgb;
    Normal.xyz = 2 * Normal.xyz - (1.0,1.0,1.0);
    Normal =  normalize(TBN * Normal); 
    
    
    vec4 shadow = vec4(1.0, 1.0, 1.0,1.0);
    vec4 tmpVertexPos = VertexPos;
    
    // compute shadowmap
    if(tmpVertexPos.z > 0 ){
        tmpVertexPos /= tmpVertexPos.w;
        shadow = texture(shadowmap, tmpVertexPos.xy); 
    }
    // compute lightDir
    vec3 lightDir =  normalize(lightPos.xyz - FragPos*lightPos.w);
    
    
    // compute Specular
    vec3 viewDirection =  normalize( cameraPosition.xyz - FragPos);
    vec3 reflectedLightDirection =  normalize(reflect(-1.0*lightDir.xyz,Normal));
    float spec =  max(dot(reflectedLightDirection, viewDirection ), 0.0) ;
    spec = pow(spec,16);    
    vec3 specular = spec * lightSpecularColour.rgb; 
    
    
    // compute Diffuse
    float diff = max(dot(lightDir,Normal), 0.0);
    vec3 diffuse = diff * lightDiffuseColour.rgb ;
    
    vec3 result;
        
    // precompute the lighting term
    vec3 lightingTerm =  (diffuse + spec+ ambientLightColour.rgb/2.0 ) * shadow.rgb;
    
    vec4 crossMap = texture(crossmap, out_UV2.st);   
    if(crossMap.r < 0.00005)
    {
        vec3 texelColor = texture(decalmap, out_UV0.st).rgb;
        if(diffuseSurface==vec4(1.0,1.0,1.0,1.0))
            result =  lightingTerm * texelColor;
        else
            result =  lightingTerm * mix(texelColor,diffuseSurface.rgb,0.5);
    }
    else{
        if(diffuseSurface==vec4(1.0,1.0,1.0,1.0))
            result = lightingTerm * crossMap.rgb *  seatColor.rgb;
        else
            result =  lightingTerm * mix( crossMap.rgb * seatColor.rgb,diffuseSurface.rgb,0.5);        

    }
    color  = vec4( result.xyz,  1.0);

       
}    

What is wrong in here, is that specular is not used in outcomimg value of color fragment, instead it uses the spec value ( note the line vec3 lightingTerm = (diffuse + spec+ ambientLightColour.rgb/2.0 ) * shadow.rgb;

That way I got the error above, but shouldn't such a mistake be just a warning or not reported at all ? That way I loose other errors information... why does the GLSL compiler or material compiler ( or both ... ) behave like that --- reporting ONLY the first error ? ..... Whose choice it was ? hmm ;) ?
Post Reply