mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Fixed bug in calculating the specular component of the color in shaders
This commit is contained in:
		
							parent
							
								
									ce2e53dbfa
								
							
						
					
					
						commit
						0e2fba6d6f
					
				
					 2 changed files with 12 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -65,11 +65,15 @@ void main()
 | 
			
		|||
    intensity.y = 0.0;
 | 
			
		||||
 | 
			
		||||
    if (NdotL > 0.0)
 | 
			
		||||
        intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
 | 
			
		||||
    {    
 | 
			
		||||
        vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz;
 | 
			
		||||
        intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Perform the same lighting calculation for the 2nd light source (no specular applied).
 | 
			
		||||
    NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
 | 
			
		||||
    intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
 | 
			
		||||
    if (NdotL > 0.0)
 | 
			
		||||
        intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
 | 
			
		||||
 | 
			
		||||
    // compute deltas for out of print volume detection (world coordinates)
 | 
			
		||||
    if (print_box.actived)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,12 +35,16 @@ void main()
 | 
			
		|||
    intensity.y = 0.0;
 | 
			
		||||
 | 
			
		||||
    if (NdotL > 0.0)
 | 
			
		||||
        intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
 | 
			
		||||
    {    
 | 
			
		||||
        vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz;
 | 
			
		||||
        intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Perform the same lighting calculation for the 2nd light source (no specular)
 | 
			
		||||
    NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
 | 
			
		||||
    
 | 
			
		||||
    intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
 | 
			
		||||
    if (NdotL > 0.0)
 | 
			
		||||
        intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
 | 
			
		||||
 | 
			
		||||
    // Scaled to widths of the Z texture.
 | 
			
		||||
    if (object_max_z > 0.0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue