[quote=“flintza”]I did get a working solution, though it feels like a bit of a hack. I use the lighting pass, but set it to subtractive:
<technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
<pass name="base" vsdefines="ENVCUBEMAP LIGHTMAP" psdefines="ENVCUBEMAP LIGHTMAP" />
<pass name="prepass" psdefines="PREPASS" />
<pass name="light" vsdefines="LIGHTMAP" psdefines="LIGHTMAP" depthtest="equal" depthwrite="false" blend="subtract" />
<pass name="material" vsdefines="ENVCUBEMAP LIGHTMAP" psdefines="MATERIAL ENVCUBEMAP LIGHTMAP" depthtest="equal" depthwrite="false" />
<pass name="deferred" vsdefines="ENVCUBEMAP LIGHTMAP" psdefines="DEFERRED ENVCUBEMAP LIGHTMAP" />
<pass name="depth" vs="Depth" ps="Depth" />
<pass name="shadow" vs="Shadow" ps="Shadow" />
</technique>
And then in the pixel shader I use the LIGHTMAP define to essentially output the inverse of the shadow:
[code]
#if defined(LIGHTMAP) && defined(SHADOW)
float diff = 1-GetShadow(iShadowPos, iWorldPos.w);
finalColor = diff * diffColor.rgb * cAmbientColor;
oColor = float4(GetLitFog(finalColor, fogFactor), diffColor.a);
#else
float diff = GetDiffuse(normal, iWorldPos.xyz, lightDir);
#ifdef SHADOW
diff *= GetShadow(iShadowPos, iWorldPos.w);
#endif
#if defined(SPOTLIGHT)
lightColor = iSpotPos.w > 0.0 ? Sample2DProj(LightSpotMap, iSpotPos).rgb * cLightColor.rgb : 0.0;
#elif defined(CUBEMASK)
lightColor = SampleCube(LightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
#else
lightColor = cLightColor.rgb;
#endif
#ifdef SPECULAR
float spec = GetSpecular(normal, cCameraPosPS - iWorldPos.xyz, lightDir, cMatSpecColor.a);
finalColor = diff * lightColor * (diffColor.rgb + spec * specColor * cLightColor.a);
#else
finalColor = diff * lightColor * diffColor.rgb;
#endif
#ifdef AMBIENT
finalColor += cAmbientColor * diffColor.rgb;
finalColor += cMatEmissiveColor;
oColor = float4(GetFog(finalColor, fogFactor), diffColor.a);
#else
oColor = float4(GetLitFog(finalColor, fogFactor), diffColor.a);
#endif
#endif
[/code][/quote]
First of, welcome! This looks interesting, could you post some screenshots of this result and perhaps a working sample?
Thanks!