mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-25 15:15:40 +00:00
Updated Fragment_NoSpotlight.glsl (fragment shader for legacy engine without spot light)
This commit is contained in:
parent
732bff2769
commit
0ab486645c
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
** Supermodel
|
** Supermodel
|
||||||
** A Sega Model 3 Arcade Emulator.
|
** A Sega Model 3 Arcade Emulator.
|
||||||
** Copyright 2011 Bart Trzynadlowski, Nik Henson
|
** Copyright 2011-2016 Bart Trzynadlowski, Nik Henson
|
||||||
**
|
**
|
||||||
** This file is part of Supermodel.
|
** This file is part of Supermodel.
|
||||||
**
|
**
|
||||||
|
@ -20,31 +20,30 @@
|
||||||
**/
|
**/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fragment_NoSpotlight.glsl
|
* Fragment.glsl
|
||||||
*
|
*
|
||||||
* Fragment shader for 3D rendering. Spotlight effect removed. Fixes fragment
|
* Fragment shader for 3D rendering.
|
||||||
* shader link errors on older ATI Radeon GPUs.
|
|
||||||
*
|
|
||||||
* To load external fragment shaders, use the -frag-shader=<file> option when
|
|
||||||
* starting Supermodel.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#version 120
|
#version 120
|
||||||
|
|
||||||
// Global uniforms
|
// Global uniforms
|
||||||
uniform sampler2D textureMap; // complete texture map, 2048x2048 texels
|
uniform sampler2D textureMap; // complete texture map, 2048x2048 texels
|
||||||
uniform vec4 spotEllipse; // spotlight ellipse position: .x=X position (screen coordinates), .y=Y position, .z=half-width, .w=half-height)
|
uniform vec4 spotEllipse; // spotlight ellipse position: .x=X position (screen coordinates), .y=Y position, .z=half-width, .w=half-height)
|
||||||
uniform vec2 spotRange; // spotlight Z range: .x=start (viewspace coordinates), .y=limit
|
uniform vec2 spotRange; // spotlight Z range: .x=start (viewspace coordinates), .y=limit
|
||||||
uniform vec3 spotColor; // spotlight RGB color
|
uniform vec3 spotColor; // spotlight RGB color
|
||||||
|
uniform vec3 lighting[2]; // lighting state (lighting[0] = sun direction, lighting[1].x,y = diffuse, ambient intensities from 0-1.0)
|
||||||
uniform float mapSize; // texture map size (2048,4096,6144 etc)
|
uniform float mapSize; // texture map size (2048,4096,6144 etc)
|
||||||
|
|
||||||
// Inputs from vertex shader
|
// Inputs from vertex shader
|
||||||
varying vec4 fsSubTexture; // .x=texture X, .y=texture Y, .z=texture width, .w=texture height (all in texels)
|
varying vec4 fsSubTexture; // .x=texture X, .y=texture Y, .z=texture width, .w=texture height (all in texels)
|
||||||
varying vec4 fsTexParams; // .x=texture enable (if 1, else 0), .y=use transparency (if > 0), .z=U wrap mode (1=mirror, 0=repeat), .w=V wrap mode
|
varying vec4 fsTexParams; // .x=texture enable (if 1, else 0), .y=use transparency (if > 0), .z=U wrap mode (1=mirror, 0=repeat), .w=V wrap mode
|
||||||
varying float fsTexFormat; // .x=T1RGB5 contour texture (if > 0)
|
varying float fsTexFormat; // T1RGB5 contour texture (if > 0)
|
||||||
|
varying float fsTexMap; // texture map number
|
||||||
varying float fsTransLevel; // translucence level, 0.0 (transparent) to 1.0 (opaque)
|
varying float fsTransLevel; // translucence level, 0.0 (transparent) to 1.0 (opaque)
|
||||||
varying vec3 fsLightIntensity; // lighting intensity
|
varying vec3 fsLightIntensity; // lighting intensity
|
||||||
varying float fsFogFactor; // fog factor
|
varying float fsSpecularTerm; // specular highlight
|
||||||
|
varying float fsFogFactor; // fog factor
|
||||||
varying float fsViewZ; // Z distance to fragment from viewpoint at origin
|
varying float fsViewZ; // Z distance to fragment from viewpoint at origin
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -87,12 +86,6 @@ vec4 WrapTexelCoords(vec4 texCoord, vec4 texOffset, vec4 texSize, vec4 mirrorEna
|
||||||
(vec4(1.0,1.0,1.0,1.0)-mirror)*clampedCoord +
|
(vec4(1.0,1.0,1.0,1.0)-mirror)*clampedCoord +
|
||||||
texOffset
|
texOffset
|
||||||
) / mapSize;
|
) / mapSize;
|
||||||
/*
|
|
||||||
glTexCoord = ( mirror*(texSize-vec4(1.0,1.0,1.0,1.0)-clampedCoord) +
|
|
||||||
(vec4(1.0,1.0,1.0,1.0)-mirror)*clampedCoord +
|
|
||||||
texOffset
|
|
||||||
) / mapSize;
|
|
||||||
*/
|
|
||||||
return glTexCoord;
|
return glTexCoord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +103,7 @@ void main(void)
|
||||||
vec2 ellipse;
|
vec2 ellipse;
|
||||||
vec3 lightIntensity;
|
vec3 lightIntensity;
|
||||||
float insideSpot;
|
float insideSpot;
|
||||||
|
int x;
|
||||||
|
|
||||||
// Get polygon color for untextured polygons (textured polygons will overwrite)
|
// Get polygon color for untextured polygons (textured polygons will overwrite)
|
||||||
if (fsTexParams.x < 0.5)
|
if (fsTexParams.x < 0.5)
|
||||||
|
@ -175,27 +169,27 @@ void main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If contour texture and not discarded, force alpha to 1.0 because will later be modified by polygon translucency
|
// If contour texture and not discarded, force alpha to 1.0 because will later be modified by polygon translucency
|
||||||
if (fsTexFormat < 0.5) // contour (T1RGB5) texture map
|
if (fsTexFormat < 0.5) // contour (T1RGB5) texture
|
||||||
fragColor.a = 1.0;
|
fragColor.a = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute spotlight and apply lighting
|
// Compute spotlight and apply lighting
|
||||||
/***
|
/*
|
||||||
ellipse = (gl_FragCoord.xy-spotEllipse.xy)/spotEllipse.zw;
|
ellipse = (gl_FragCoord.xy-spotEllipse.xy)/spotEllipse.zw;
|
||||||
insideSpot = dot(ellipse,ellipse);
|
insideSpot = dot(ellipse,ellipse);
|
||||||
if ((insideSpot <= 1.0) && (fsViewZ>=spotRange.x) && (fsViewZ<spotRange.y))
|
if ((insideSpot <= 1.0) && (fsViewZ>=spotRange.x) && (fsViewZ<spotRange.y))
|
||||||
lightIntensity = fsLightIntensity+(1.0-insideSpot)*spotColor;
|
lightIntensity = fsLightIntensity+(1.0-insideSpot)*spotColor;
|
||||||
else
|
else
|
||||||
lightIntensity = fsLightIntensity;
|
lightIntensity = fsLightIntensity;
|
||||||
fragColor.rgb *= lightIntensity;
|
*/
|
||||||
***/
|
|
||||||
fragColor.rgb *= fsLightIntensity;
|
fragColor.rgb *= fsLightIntensity;
|
||||||
|
fragColor.rgb += vec3(fsSpecularTerm,fsSpecularTerm,fsSpecularTerm);
|
||||||
|
|
||||||
// Translucency (modulates existing alpha channel for RGBA4 texels)
|
// Translucency (modulates existing alpha channel for RGBA4 texels)
|
||||||
fragColor.a *= fsTransLevel;
|
fragColor.a *= fsTransLevel;
|
||||||
|
|
||||||
// Apply fog under the control of fog factor setting from polygon header
|
// Apply fog
|
||||||
fragColor.rgb = mix(gl_Fog.color.rgb, fragColor.rgb, fsFogFactor );
|
fragColor.rgb = mix(fragColor.rgb, gl_Fog.color.rgb, fsFogFactor);
|
||||||
|
|
||||||
// Store final color
|
// Store final color
|
||||||
gl_FragColor = fragColor;
|
gl_FragColor = fragColor;
|
||||||
|
|
Loading…
Reference in a new issue