Separate Diffuse and Specular components
This allows to bypass alpha test, and have colored specular lights. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14777 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
5f23483bd9
commit
65b32757f3
@ -1,15 +1,15 @@
|
||||
uniform sampler2D diffuse_and_spec;
|
||||
uniform sampler2D diffuse;
|
||||
uniform sampler2D specular;
|
||||
uniform sampler2D ambient_occlusion;
|
||||
uniform vec3 ambient;
|
||||
//uniform sampler2D spectex;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texc = gl_TexCoord[0].xy;
|
||||
|
||||
vec3 diffuse = texture2D(diffuse_and_spec, texc).xyz;
|
||||
vec3 specular = texture2D(diffuse_and_spec, texc).www;
|
||||
vec3 diffuse = texture2D(diffuse, texc).xyz;
|
||||
vec3 spec = texture2D(specular, texc).xyz;
|
||||
float ao = texture2D(ambient_occlusion, texc).x;
|
||||
|
||||
gl_FragColor = vec4(diffuse + ao * ambient, 1.0);
|
||||
gl_FragColor = vec4(diffuse + spec + ao * ambient, 1.0);
|
||||
}
|
||||
|
@ -25,11 +25,12 @@ void main() {
|
||||
// Light Direction
|
||||
vec3 L = normalize(xpos.xyz - center);
|
||||
|
||||
float NdotL = max(0.0, dot(norm, -L)) * att;
|
||||
float NdotL = max(0.0, dot(norm, -L));
|
||||
// Reflected light dir
|
||||
vec3 R = reflect(-L, norm);
|
||||
float RdotE = max(0.0, dot(R, normalize(xpos.xyz)));
|
||||
float Specular = pow(RdotE, spec);
|
||||
|
||||
gl_FragColor = vec4(NdotL * col, Specular + 0.001); // Irrlicht force alpha test, can't be 0
|
||||
gl_FragData[0] = vec4(NdotL * col * att, 1.);
|
||||
gl_FragData[1] = vec4(Specular * col, 1.);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ void main() {
|
||||
outcol *= cloud;
|
||||
}
|
||||
|
||||
gl_FragData[0] = vec4(NdotL * col, Specular+ 0.001); // Irrlicht force alpha test, can't be 0
|
||||
gl_FragData[1] = vec4(1.0);
|
||||
gl_FragData[0] = vec4(NdotL * col, 1.);
|
||||
gl_FragData[1] = vec4(Specular * col, 1.);
|
||||
gl_FragData[2] = vec4(1.0);
|
||||
}
|
||||
|
@ -343,8 +343,10 @@ void LightBlendProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
srv->setVertexShaderConstant("ambient", ambient, 3);
|
||||
|
||||
int tex = 0;
|
||||
srv->setVertexShaderConstant("diffuse_and_spec", &tex, 1);
|
||||
srv->setVertexShaderConstant("diffuse", &tex, 1);
|
||||
tex = 1;
|
||||
srv->setVertexShaderConstant("specular", &tex, 1);
|
||||
tex = 2;
|
||||
srv->setVertexShaderConstant("ambient_occlusion", &tex, 1);
|
||||
}
|
||||
|
||||
|
@ -670,7 +670,13 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
|
||||
video::SOverrideMaterial &overridemat,
|
||||
int cam)
|
||||
{
|
||||
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_TMP1), true, false,
|
||||
core::array<video::IRenderTarget> rtts;
|
||||
// Diffuse
|
||||
rtts.push_back(m_rtts->getRTT(RTT_TMP1));
|
||||
// Specular
|
||||
rtts.push_back(m_rtts->getRTT(RTT_TMP2));
|
||||
|
||||
m_video_driver->setRenderTarget(rtts, true, false,
|
||||
video::SColor(0, 0, 0, 0));
|
||||
|
||||
const vector3df camcenter = cambox.getCenter();
|
||||
@ -781,9 +787,8 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
|
||||
lightmat.ZBuffer = video::ECFN_ALWAYS;
|
||||
lightmat.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
lightmat.setTexture(0, m_rtts->getRTT(RTT_TMP1));
|
||||
|
||||
// Apply ambient occlusion
|
||||
lightmat.setTexture(1, m_rtts->getRTT(RTT_SSAO));
|
||||
lightmat.setTexture(1, m_rtts->getRTT(RTT_TMP2));
|
||||
lightmat.setTexture(2, m_rtts->getRTT(RTT_SSAO));
|
||||
|
||||
lightmat.MaterialType = m_shaders->getShader(ES_LIGHTBLEND);
|
||||
if (!m_lightviz)
|
||||
|
Loading…
Reference in New Issue
Block a user