[Solved] Shader LightBlow and Post-Shadows

So I wanted fog that would change the color of objects far away without changing the color of the skybox. So I used the fog in LightBlow instead of FogFilter. I used the LightBlow j3md for the terrain and trees. However, the trees have shadows on transparent areas. The bucket is set to Transparent and the blend is set to Alpha. I read about a similar problem on the forums and copy-pasted the techniques PostShadow15 and PostShadow and shadow parameters in the LightBlow j3md. I’m still not getting it.

LightBlow (you can kind of see the whitening of the distant trees):



LightBlow with PostShadow15, etc.:

I copy-pasted from a newer version of Lighting.j3md, and I got better results:



But it left an outline like above. I played around with the material, and when I tweaked the “AlphaTestFalloff”, the outlines disappeared (or got smaller). But the trees seemed to have gotten brighter, the shadows are still the same, and I don’t think I see any shadows on the tree.

I copy-pasted from Lighting.j3md from today’s nightly build. It worked.

2 Likes

@seann999 can you provide your modified j3md of the Lightblow? I’ll put it into Lightblow lib.

@mifth Umm sure… but I’m a total noob and had no idea what I was doing; I don’t even know what Techniques are or anything. Again, I just copy-pasted. It just worked. I don’t even know how to share the j3md. Well, here’s it embeded…

[java]MaterialDef LightBlow {



MaterialParameters {



// Fog

Color FogColor

TextureCubeMap FogSkyBox



// Multiply Color system

Boolean Multiply_Color



// Toon System

Boolean Toon

Color EdgesColor

Float EdgeSize

Boolean Fog_Edges



// Color of RimLighting2

Color RimLighting2



// Color of RimLighting

Color RimLighting



// Light Map

Boolean SeperateTexCoord

Boolean SeperateTexCoord2

Texture2D LightMap

Boolean LightMap_R

Boolean LightMap_G

Boolean LightMap_B

Boolean LightMap_A



// No attenuation increases fps

Boolean No_Attenuation



// Output emission from the diffuse map alpha channel

Boolean EmissiveMap



// Output alpha from the diffuse map

Boolean Alpha_A_Dif



// Output alpha from the diffuse map

Boolean Alpha_A_Nor



// Switch Normal Map xyz(rgb) channels

Boolean Nor_Inv_X

Boolean Nor_Inv_Y

Boolean Nor_Inv_Z



// IBL Map for Image Based Lighting

TextureCubeMap IblMap

Texture2D IblMap_Simple





// Switch Hemispherical Lighting on/off

Boolean Hemi_Lighting_1

Boolean Hemi_Lighting_2



// Specular lighting

Boolean Specular_Lighting

Float Shininess (MaterialShininess) : 1 // Specular power/shininess

Boolean Spec_A_Nor // Output specular from the normal map alpha channel

Boolean Spec_A_Dif // Output specular from the diffuse map alpha channel



// Reflection

TextureCubeMap RefMap // Ref Map for reflection

Boolean Ref_A_Nor // Output reflection from the normal map alpha channel

Boolean Ref_A_Dif // Output reflection from the diffuse map alpha channel

Float RefIntensity : 1 // Reflection Intensity

Boolean AdditiveReflection



// Compute vertex lighting in the shader

// For better performance

Boolean VertexLighting



// Use more efficent algorithms to improve performance

Boolean LowQuality



// Improve quality at the cost of performance

Boolean HighQuality



// Apha threshold for fragment discarding

Float AlphaDiscardThreshold



// Normal map is in BC5/ATI2n/LATC/3Dc compression format

Boolean LATC



// Use the provided ambient, diffuse, and specular colors

Boolean UseMaterialColors



// Activate shading along the tangent, instead of the normal

// Requires tangent data to be available on the model.

Boolean VTangent



// Use minnaert diffuse instead of lambert

Color Minnaert



// Use ward specular instead of phong

Boolean WardIso



// Use vertex color as an additional diffuse color.

Boolean UseVertexColor



// Ambient color

Color Ambient (MaterialAmbient)



// Diffuse color

Color Diffuse (MaterialDiffuse)



// Specular color

Color Specular (MaterialSpecular)





// Texture Mask for texture blending

Texture2D TextureMask



// Diffuse map

Texture2D DiffuseMap

Texture2D DiffuseMap_1

Texture2D DiffuseMap_2

Texture2D DiffuseMap_3



Float uv_0_scale : 1

Float uv_1_scale : 1

Float uv_2_scale : 1

Float uv_3_scale : 1



// Normal map

Texture2D NormalMap

Texture2D NormalMap_1

Texture2D NormalMap_2

Texture2D NormalMap_3



// Specular/gloss map

Texture2D SpecularMap



// Parallax/height map

Texture2D ParallaxMap

Boolean NORMAL_PARALLAX // Output parallax map from the normal map alpha channel

Boolean PackedNormalParallax // Set to true is parallax map is stored in the alpha channel of the normal map

Float ParallaxHeight : 0.05 // Sets the relief height for parallax mapping

Boolean SteepParallax // Set to true to activate Steep Parallax mapping



// Color ramp, will map diffuse and specular values through it.

Texture2D ColorRamp



// Texture of the glowing parts of the material

Texture2D GlowMap



// The glow color of the object

Color GlowColor



// Parameters for fresnel

// X = bias

// Y = scale

// Z = power

// Vector3 FresnelParams



// the ref map is a spheremap and not a cube map

Boolean SphereMap



// Shadows

Int FilterMode

Boolean HardwareShadows



Texture2D ShadowMap0

Texture2D ShadowMap1

Texture2D ShadowMap2

Texture2D ShadowMap3



Float ShadowIntensity

Vector4 Splits



Matrix4 LightViewProjectionMatrix0

Matrix4 LightViewProjectionMatrix1

Matrix4 LightViewProjectionMatrix2

Matrix4 LightViewProjectionMatrix3



Float PCFEdge

}



Technique {



LightMode MultiPass



VertexShader GLSL100: Shaders/LightBlow/LightBlow.vert

FragmentShader GLSL100: Shaders/LightBlow/LightBlow.frag



WorldParameters {

WorldViewProjectionMatrix

NormalMatrix

WorldViewMatrix

ViewMatrix

CameraPosition

WorldMatrix

}



Defines {



RIM_LIGHTING_2 : RimLighting2

RIM_LIGHTING : RimLighting

SEPERATE_TEXCOORD : SeperateTexCoord

SEPERATE_TEXCOORD2 : SeperateTexCoord2

HAS_LIGHTMAP : LightMap

LIGHTMAP_R : LightMap_R

LIGHTMAP_G : LightMap_G

LIGHTMAP_B : LightMap_B

LIGHTMAP_A : LightMap_A

ALPHA_A_DIF : Alpha_A_Dif

ALPHA_A_NOR : Alpha_A_Nor

NO_ATTENUATION : No_Attenuation

EMISSIVEMAP : EmissiveMap

NOR_INV_X : Nor_Inv_X

NOR_INV_Y : Nor_Inv_Y

NOR_INV_Z : Nor_Inv_Z

IBL : IblMap

IBL_SIMPLE : IblMap_Simple

HEMI_LIGHTING_1 : Hemi_Lighting_1

HEMI_LIGHTING_2 : Hemi_Lighting_2

SPECULAR_LIGHTING : Specular_Lighting

SPEC_A_NOR : Spec_A_Nor

SPEC_A_DIF : Spec_A_Dif

REF_A_NOR : Ref_A_Nor

REF_A_DIF : Ref_A_Dif



LATC : LATC

VERTEX_COLOR : UseVertexColor

VERTEX_LIGHTING : VertexLighting

ATTENUATION : Attenuation

MATERIAL_COLORS : UseMaterialColors

V_TANGENT : VTangent

MINNAERT : Minnaert

WARDISO : WardIso

LOW_QUALITY : LowQuality

HQ_ATTENUATION : HighQuality



TEXTURE_MASK : TextureMask

DIFFUSEMAP : DiffuseMap

DIFFUSEMAP_1 : DiffuseMap_1

DIFFUSEMAP_2 : DiffuseMap_2

DIFFUSEMAP_3 : DiffuseMap_3

NORMALMAP : NormalMap

NORMALMAP_1 : NormalMap_1

NORMALMAP_2 : NormalMap_2

NORMALMAP_3 : NormalMap_3

SPECULARMAP : SpecularMap

PARALLAXMAP : ParallaxMap

NORMAL_PARALLAX : NORMAL_PARALLAX

NORMALMAP_PARALLAX : PackedNormalParallax

STEEP_PARALLAX : SteepParallax

COLORRAMP : ColorRamp

REFLECTION : RefMap

ADDITIVE_REFLECTION : AdditiveReflection

SPHERE_MAP : SphereMap

MULTIPLY_COLOR : Multiply_Color

FOG : FogColor

FOG_SKY : FogSkyBox

TOON : Toon

TOON_EDGES : EdgesColor

FOG_EDGES : Fog_Edges



}



}





Technique CartoonEdge {



LightMode MultiPass



VertexShader GLSL100: Shaders/ToonBlow/ToonBlow_Edges.vert

FragmentShader GLSL100: Shaders/ToonBlow/ToonBlow_Edges.frag





WorldParameters {

WorldViewProjectionMatrix

NormalMatrix

WorldViewMatrix

ViewMatrix

CameraPosition

WorldMatrix

}



Defines {



SPHERE_MAP : SphereMap

FOG : FogColor

FOG_SKY : FogSkyBox

TOON_EDGES : EdgesColor

FOG_EDGES : Fog_Edges

}



RenderState {

FaceCull Front

DepthTest On

DepthWrite On

}

}



Technique PreShadow {



VertexShader GLSL100 : Common/MatDefs/Shadow/PreShadow.vert

FragmentShader GLSL100 : Common/MatDefs/Shadow/PreShadow.frag



WorldParameters {

WorldViewProjectionMatrix

WorldViewMatrix

}



Defines {

DIFFUSEMAP : DiffuseMap

}



RenderState {

FaceCull Off

DepthTest On

DepthWrite On

PolyOffset 5 0

ColorWrite Off

}



}





Technique PostShadow15{

VertexShader GLSL150: Common/MatDefs/Shadow/PostShadowPSSM.vert

FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadowPSSM15.frag



WorldParameters {

WorldViewProjectionMatrix

WorldMatrix

}



Defines {

HARDWARE_SHADOWS : HardwareShadows

FILTER_MODE : FilterMode

PCFEDGE : PCFEdge

DIFFUSEMAP : DiffuseMap

}



RenderState {

Blend Alpha

}

}



Technique PostShadow{

VertexShader GLSL100: Common/MatDefs/Shadow/PostShadowPSSM.vert

FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadowPSSM.frag



WorldParameters {

WorldViewProjectionMatrix

WorldMatrix

}



Defines {

HARDWARE_SHADOWS : HardwareShadows

FILTER_MODE : FilterMode

PCFEDGE : PCFEdge

DIFFUSEMAP : DiffuseMap

}



RenderState {

Blend Alpha

}

}



Technique PreNormalPass {



VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert

FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag



WorldParameters {

WorldViewProjectionMatrix

WorldViewMatrix

NormalMatrix

}



Defines {

DIFFUSEMAP_ALPHA : DiffuseMap

}



RenderState {



}



}





Technique FixedFunc {

LightMode FixedPipeline

}



Technique GBuf {



VertexShader GLSL100: Common/MatDefs/Light/GBuf.vert

FragmentShader GLSL100: Common/MatDefs/Light/GBuf.frag



WorldParameters {

WorldViewProjectionMatrix

NormalMatrix

WorldViewMatrix

WorldMatrix

}



Defines {

VERTEX_COLOR : UseVertexColor

MATERIAL_COLORS : UseMaterialColors

V_TANGENT : VTangent

MINNAERT : Minnaert

WARDISO : WardIso



DIFFUSEMAP : DiffuseMap

NORMALMAP : NormalMap

SPECULARMAP : SpecularMap

PARALLAXMAP : ParallaxMap

}

}



Technique FixedFunc {

LightMode FixedPipeline

}



Technique Glow {



VertexShader GLSL100: Common/MatDefs/Misc/Unshaded.vert

FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag



WorldParameters {

WorldViewProjectionMatrix

}



Defines {

HAS_GLOWMAP : GlowMap

HAS_GLOWCOLOR : GlowColor

}

}

}[/java]

1 Like

@seann999 thank you for your post. I added shadows to ShaderBlow shaders. They are in Mercurial repository.