mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 20:09:42 +00:00
Revert "Use raw string literals for shaders"
This reverts commit 0e72055385
.
This commit is contained in:
parent
20abe6dcf5
commit
219b9e7cbf
1 changed files with 110 additions and 142 deletions
|
@ -42,159 +42,127 @@ using namespace SceneUtil;
|
||||||
// fragment shader
|
// fragment shader
|
||||||
//
|
//
|
||||||
#if 0
|
#if 0
|
||||||
const std::string fragmentShaderSource_withBaseTexture = R"glsl(
|
static const char fragmentShaderSource_withBaseTexture[] =
|
||||||
uniform sampler2D baseTexture;
|
"uniform sampler2D baseTexture; \n"
|
||||||
uniform sampler2DShadow shadowTexture;
|
"uniform sampler2DShadow shadowTexture; \n"
|
||||||
|
" \n"
|
||||||
void main(void)
|
"void main(void) \n"
|
||||||
{
|
"{ \n"
|
||||||
vec4 colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor;
|
" vec4 colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor; \n"
|
||||||
vec4 color = texture2D( baseTexture, gl_TexCoord[0].xy );
|
" vec4 color = texture2D( baseTexture, gl_TexCoord[0].xy ); \n"
|
||||||
color *= mix( colorAmbientEmissive, gl_Color, shadow2DProj( shadowTexture, gl_TexCoord[1] ).r );
|
" color *= mix( colorAmbientEmissive, gl_Color, shadow2DProj( shadowTexture, gl_TexCoord[1] ).r ); \n"
|
||||||
gl_FragColor = color;
|
" gl_FragColor = color; \n"
|
||||||
}
|
"} \n";
|
||||||
)glsl";
|
|
||||||
#else
|
#else
|
||||||
const std::string fragmentShaderSource_withBaseTexture = R"glsl(
|
static const char fragmentShaderSource_withBaseTexture[] =
|
||||||
uniform sampler2D baseTexture;
|
"uniform sampler2D baseTexture; \n"
|
||||||
uniform int baseTextureUnit;
|
"uniform int baseTextureUnit; \n"
|
||||||
uniform sampler2DShadow shadowTexture0;
|
"uniform sampler2DShadow shadowTexture0; \n"
|
||||||
uniform int shadowTextureUnit0;
|
"uniform int shadowTextureUnit0; \n"
|
||||||
|
" \n"
|
||||||
|
"void main(void) \n"
|
||||||
|
"{ \n"
|
||||||
|
" vec4 colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor; \n"
|
||||||
|
" vec4 color = texture2D( baseTexture, gl_TexCoord[baseTextureUnit].xy ); \n"
|
||||||
|
" color *= mix( colorAmbientEmissive, gl_Color, shadow2DProj( shadowTexture0, gl_TexCoord[shadowTextureUnit0] ).r ); \n"
|
||||||
|
" gl_FragColor = color; \n"
|
||||||
|
"} \n";
|
||||||
|
|
||||||
void main(void)
|
static const char fragmentShaderSource_withBaseTexture_twoShadowMaps[] =
|
||||||
{
|
"uniform sampler2D baseTexture; \n"
|
||||||
vec4 colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor;
|
"uniform int baseTextureUnit; \n"
|
||||||
vec4 color = texture2D( baseTexture, gl_TexCoord[baseTextureUnit].xy );
|
"uniform sampler2DShadow shadowTexture0; \n"
|
||||||
color *= mix( colorAmbientEmissive, gl_Color, shadow2DProj( shadowTexture0, gl_TexCoord[shadowTextureUnit0] ).r );
|
"uniform int shadowTextureUnit0; \n"
|
||||||
gl_FragColor = color;
|
"uniform sampler2DShadow shadowTexture1; \n"
|
||||||
}
|
"uniform int shadowTextureUnit1; \n"
|
||||||
)glsl";
|
" \n"
|
||||||
|
"void main(void) \n"
|
||||||
const std::string fragmentShaderSource_withBaseTexture_twoShadowMaps = R"glsl(
|
"{ \n"
|
||||||
uniform sampler2D baseTexture;
|
" vec4 colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor; \n"
|
||||||
uniform int baseTextureUnit;
|
" vec4 color = texture2D( baseTexture, gl_TexCoord[baseTextureUnit].xy ); \n"
|
||||||
uniform sampler2DShadow shadowTexture0;
|
" float shadow0 = shadow2DProj( shadowTexture0, gl_TexCoord[shadowTextureUnit0] ).r; \n"
|
||||||
uniform int shadowTextureUnit0;
|
" float shadow1 = shadow2DProj( shadowTexture1, gl_TexCoord[shadowTextureUnit1] ).r; \n"
|
||||||
uniform sampler2DShadow shadowTexture1;
|
" color *= mix( colorAmbientEmissive, gl_Color, shadow0*shadow1 ); \n"
|
||||||
uniform int shadowTextureUnit1;
|
" gl_FragColor = color; \n"
|
||||||
|
"} \n";
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
vec4 colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor;
|
|
||||||
vec4 color = texture2D( baseTexture, gl_TexCoord[baseTextureUnit].xy );
|
|
||||||
float shadow0 = shadow2DProj( shadowTexture0, gl_TexCoord[shadowTextureUnit0] ).r;
|
|
||||||
float shadow1 = shadow2DProj( shadowTexture1, gl_TexCoord[shadowTextureUnit1] ).r;
|
|
||||||
color *= mix( colorAmbientEmissive, gl_Color, shadow0*shadow1 );
|
|
||||||
gl_FragColor = color;
|
|
||||||
}
|
|
||||||
)glsl";
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::string debugVertexShaderSource = R"glsl(
|
std::string debugVertexShaderSource = "void main(void){gl_Position = gl_Vertex; gl_TexCoord[0]=gl_MultiTexCoord0;}";
|
||||||
void main(void)
|
std::string debugFragmentShaderSource =
|
||||||
{
|
"uniform sampler2D texture; \n"
|
||||||
gl_Position = gl_Vertex;
|
" \n"
|
||||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
"void main(void) \n"
|
||||||
}
|
"{ \n"
|
||||||
)glsl";
|
|
||||||
|
|
||||||
const std::string debugFragmentShaderSource = R"glsl(
|
|
||||||
uniform sampler2D texture;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
)glsl"
|
|
||||||
#if 1
|
#if 1
|
||||||
R"glsl(
|
" float f = texture2D(texture, gl_TexCoord[0].xy).r; \n"
|
||||||
float f = texture2D(texture, gl_TexCoord[0].xy).r;
|
" \n"
|
||||||
|
" f = 256.0 * f; \n"
|
||||||
f = 256.0 * f;
|
" float fC = floor( f ) / 256.0; \n"
|
||||||
float fC = floor( f ) / 256.0;
|
" \n"
|
||||||
|
" f = 256.0 * fract( f ); \n"
|
||||||
f = 256.0 * fract( f );
|
" float fS = floor( f ) / 256.0; \n"
|
||||||
float fS = floor( f ) / 256.0;
|
" \n"
|
||||||
|
" f = 256.0 * fract( f ); \n"
|
||||||
f = 256.0 * fract( f );
|
" float fH = floor( f ) / 256.0; \n"
|
||||||
float fH = floor( f ) / 256.0;
|
" \n"
|
||||||
|
" fS *= 0.5; \n"
|
||||||
fS *= 0.5;
|
" fH = ( fH * 0.34 + 0.66 ) * ( 1.0 - fS ); \n"
|
||||||
fH = ( fH * 0.34 + 0.66 ) * ( 1.0 - fS );
|
" \n"
|
||||||
|
" vec3 rgb = vec3( ( fC > 0.5 ? ( 1.0 - fC ) : fC ), \n"
|
||||||
vec3 rgb = vec3( ( fC > 0.5 ? ( 1.0 - fC ) : fC ),
|
" abs( fC - 0.333333 ), \n"
|
||||||
abs( fC - 0.333333 ),
|
" abs( fC - 0.666667 ) ); \n"
|
||||||
abs( fC - 0.666667 ) );
|
" \n"
|
||||||
|
" rgb = min( vec3( 1.0, 1.0, 1.0 ), 3.0 * rgb ); \n"
|
||||||
rgb = min( vec3( 1.0, 1.0, 1.0 ), 3.0 * rgb );
|
" \n"
|
||||||
|
" float fMax = max( max( rgb.r, rgb.g ), rgb.b ); \n"
|
||||||
float fMax = max( max( rgb.r, rgb.g ), rgb.b );
|
" fMax = 1.0 / fMax; \n"
|
||||||
fMax = 1.0 / fMax;
|
" \n"
|
||||||
|
" vec3 color = fMax * rgb; \n"
|
||||||
vec3 color = fMax * rgb;
|
" \n"
|
||||||
|
" gl_FragColor = vec4( fS + fH * color, 1 ); \n"
|
||||||
gl_FragColor = vec4( fS + fH * color, 1 );
|
|
||||||
)glsl"
|
|
||||||
#else
|
#else
|
||||||
R"glsl(
|
" gl_FragColor = texture2D(texture, gl_TexCoord[0].xy); \n"
|
||||||
gl_FragColor = texture2D(texture, gl_TexCoord[0].xy);
|
|
||||||
)glsl"
|
|
||||||
#endif
|
#endif
|
||||||
R"glsl(
|
"} \n";
|
||||||
}
|
|
||||||
)glsl";
|
|
||||||
|
|
||||||
const std::string debugFrustumVertexShaderSource = R"glsl(
|
std::string debugFrustumVertexShaderSource = "varying float depth; uniform mat4 transform; void main(void){gl_Position = transform * gl_Vertex; depth = gl_Position.z / gl_Position.w;}";
|
||||||
varying float depth;
|
std::string debugFrustumFragmentShaderSource =
|
||||||
uniform mat4 transform;
|
"varying float depth; \n"
|
||||||
void main(void)
|
" \n"
|
||||||
{
|
"void main(void) \n"
|
||||||
gl_Position = transform * gl_Vertex;
|
"{ \n"
|
||||||
depth = gl_Position.z / gl_Position.w;
|
|
||||||
}
|
|
||||||
)glsl";
|
|
||||||
|
|
||||||
const std::string debugFrustumFragmentShaderSource = R"glsl(
|
|
||||||
varying float depth;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
)glsl"
|
|
||||||
#if 1
|
#if 1
|
||||||
R"glsl(
|
" float f = depth; \n"
|
||||||
float f = depth;
|
" \n"
|
||||||
|
" f = 256.0 * f; \n"
|
||||||
f = 256.0 * f;
|
" float fC = floor( f ) / 256.0; \n"
|
||||||
float fC = floor( f ) / 256.0;
|
" \n"
|
||||||
|
" f = 256.0 * fract( f ); \n"
|
||||||
f = 256.0 * fract( f );
|
" float fS = floor( f ) / 256.0; \n"
|
||||||
float fS = floor( f ) / 256.0;
|
" \n"
|
||||||
|
" f = 256.0 * fract( f ); \n"
|
||||||
f = 256.0 * fract( f );
|
" float fH = floor( f ) / 256.0; \n"
|
||||||
float fH = floor( f ) / 256.0;
|
" \n"
|
||||||
|
" fS *= 0.5; \n"
|
||||||
fS *= 0.5;
|
" fH = ( fH * 0.34 + 0.66 ) * ( 1.0 - fS ); \n"
|
||||||
fH = ( fH * 0.34 + 0.66 ) * ( 1.0 - fS );
|
" \n"
|
||||||
|
" vec3 rgb = vec3( ( fC > 0.5 ? ( 1.0 - fC ) : fC ), \n"
|
||||||
vec3 rgb = vec3( ( fC > 0.5 ? ( 1.0 - fC ) : fC ),
|
" abs( fC - 0.333333 ), \n"
|
||||||
abs( fC - 0.333333 ),
|
" abs( fC - 0.666667 ) ); \n"
|
||||||
abs( fC - 0.666667 ) );
|
" \n"
|
||||||
|
" rgb = min( vec3( 1.0, 1.0, 1.0 ), 3.0 * rgb ); \n"
|
||||||
rgb = min( vec3( 1.0, 1.0, 1.0 ), 3.0 * rgb );
|
" \n"
|
||||||
|
" float fMax = max( max( rgb.r, rgb.g ), rgb.b ); \n"
|
||||||
float fMax = max( max( rgb.r, rgb.g ), rgb.b );
|
" fMax = 1.0 / fMax; \n"
|
||||||
fMax = 1.0 / fMax;
|
" \n"
|
||||||
|
" vec3 color = fMax * rgb; \n"
|
||||||
vec3 color = fMax * rgb;
|
" \n"
|
||||||
|
" gl_FragColor = vec4( fS + fH * color, 1 ); \n"
|
||||||
gl_FragColor = vec4( fS + fH * color, 1 );
|
|
||||||
)glsl"
|
|
||||||
#else
|
#else
|
||||||
R"glsl(
|
" gl_FragColor = vec4(0.0, 0.0, 1.0, 0.0); \n"
|
||||||
gl_FragColor = vec4(0.0, 0.0, 1.0, 0.0);
|
|
||||||
)glsl"
|
|
||||||
#endif
|
#endif
|
||||||
R"glsl(
|
"} \n";
|
||||||
}
|
|
||||||
)glsl";
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class RenderLeafTraverser : public T
|
class RenderLeafTraverser : public T
|
||||||
|
|
Loading…
Reference in a new issue