float4x4 worldViewProjection : WorldViewProjection; float4x4 world : World; float4x4 view : View; float3 sunPos; struct a2v { float4 pos : POSITION; float3 normal : NORMAL; }; struct v2f { float4 pos : POSITION; float3 normal : TEXCOORD0; float3 sun : TEXCOORD1; float3 view : TEXCOORD2; }; v2f vsMain(a2v IN) { v2f OUT; OUT.pos = mul(IN.pos, worldViewProjection); OUT.normal = mul(float4(IN.normal, 0), world).xyz; float3 worldPos = mul(IN.pos, world).xyz; OUT.sun = sunPos - worldPos; OUT.view = (view[3] - worldPos); return OUT; } float4 psMain(v2f IN): COLOR { float3 norm = normalize(IN.normal); float3 sun = normalize(IN.sun); float light = dot(norm, sun); float lightSign = sign(light); float dayNight = 1 - sqrt(light); dayNight = dayNight * dayNight; dayNight = (1 - dayNight) * lightSign; dayNight = clamp(dayNight, 0, 1); float3 view = normalize(IN.view); float3 r = normalize(reflect(norm, sun)); float4 litR = lit(light, dot(r, view), 0.0).y; float3 day = float3(0.5, 0.5, 1.0) * litR.y + float3(1,1,1) * litR.z; float3 night = float3(0.2, 0.2, 0.5); return float4(lerp(night, day, dayNight),1); } // #o3d VertexShaderEntryPoint vsMain // #o3d PixelShaderEntryPoint psMain // #o3d MatrixLoadOrder RowMajor
float4x4 worldViewProjection : WorldViewProjection; float4x4 world : World; float4x4 view : View; float3 sunPos; float mix; sampler2D daySampler; struct a2v { float4 pos : POSITION; float3 normal : NORMAL; float2 uv : TEXCOORD0; }; struct v2f { float4 pos : POSITION; float2 uv : TEXCOORD0; float3 normal : TEXCOORD1; float3 sun : TEXCOORD2; float3 view : TEXCOORD3; }; v2f vsMain(a2v IN) { v2f OUT; OUT.pos = mul(IN.pos, worldViewProjection); OUT.uv = IN.uv; OUT.normal = mul(float4(IN.normal, 0), world).xyz; float3 worldPos = mul(IN.pos, world).xyz; OUT.sun = sunPos - worldPos; OUT.view = (view[3] - worldPos); return OUT; } float4 psMain(v2f IN): COLOR { float3 norm = normalize(IN.normal); float3 sun = normalize(IN.sun); float light = dot(norm, sun); float lightSign = sign(light); float dayNight = 1 - sqrt(light); dayNight = dayNight * dayNight; dayNight = (1 - dayNight) * lightSign; dayNight = clamp(dayNight, 0, 1); float3 view = normalize(IN.view); float3 r = normalize(reflect(norm, sun)); float4 litR = lit(light, dot(r, view), 0.0).y; float3 earth = tex2D(daySampler, IN.uv).xyz; float3 day = lerp(float3(0.5, 0.5, 1.0), earth, mix); day = day * litR.y + float3(1,1,1) * litR.z; float3 night = lerp(float3(0.2, 0.2, 0.5), earth * 0.3, mix); return float4(lerp(night, day, dayNight),1); } // #o3d VertexShaderEntryPoint vsMain // #o3d PixelShaderEntryPoint psMain // #o3d MatrixLoadOrder RowMajor
float4x4 worldViewProjection : WorldViewProjection; float4x4 world : World; float4x4 view : View; float3 sunPos; float mix; sampler2D daySampler; sampler2D nightSampler; struct a2v { float4 pos : POSITION; float3 normal : NORMAL; float2 uv : TEXCOORD0; }; struct v2f { float4 pos : POSITION; float2 uv : TEXCOORD0; float3 normal : TEXCOORD1; float3 sun : TEXCOORD2; float3 view : TEXCOORD3; }; v2f vsMain(a2v IN) { v2f OUT; OUT.pos = mul(IN.pos, worldViewProjection); OUT.uv = IN.uv; OUT.normal = mul(float4(IN.normal, 0), world).xyz; float3 worldPos = mul(IN.pos, world).xyz; OUT.sun = sunPos - worldPos; OUT.view = (view[3] - worldPos); return OUT; } float4 psMain(v2f IN): COLOR { float3 norm = normalize(IN.normal); float3 sun = normalize(IN.sun); float light = dot(norm, sun); float lightSign = sign(light); float dayNight = 1 - sqrt(light); dayNight = dayNight * dayNight; dayNight = (1 - dayNight) * lightSign; dayNight = clamp(dayNight, 0, 1); float3 view = normalize(IN.view); float3 r = normalize(reflect(norm, sun)); float4 litR = lit(light, dot(r, view), 0.0).y; float3 earth = tex2D(daySampler, IN.uv).xyz; float3 day = tex2D(daySampler, IN.uv).xyz; float3 night = lerp(day * 0.3, tex2D(nightSampler, IN.uv).xyz, mix); day = day * litR.y + float3(1,1,1) * litR.z; return float4(lerp(night, day, dayNight),1); } // #o3d VertexShaderEntryPoint vsMain // #o3d PixelShaderEntryPoint psMain // #o3d MatrixLoadOrder RowMajor
float4x4 worldViewProjection : WorldViewProjection; float4x4 world : World; float4x4 view : View; float3 sunPos; float mix; sampler2D daySampler; sampler2D nightSampler; sampler2D maskSampler; struct a2v { float4 pos : POSITION; float3 normal : NORMAL; float2 uv : TEXCOORD0; }; struct v2f { float4 pos : POSITION; float2 uv : TEXCOORD0; float3 normal : TEXCOORD1; float3 sun : TEXCOORD2; float3 view : TEXCOORD3; }; v2f vsMain(a2v IN) { v2f OUT; OUT.pos = mul(IN.pos, worldViewProjection); OUT.uv = IN.uv; OUT.normal = mul(float4(IN.normal, 0), world).xyz; float3 worldPos = mul(IN.pos, world).xyz; OUT.sun = sunPos - worldPos; OUT.view = (view[3] - worldPos); return OUT; } float4 psMain(v2f IN): COLOR { float3 norm = normalize(IN.normal); float3 sun = normalize(IN.sun); float light = dot(norm, sun); float lightSign = sign(light); float dayNight = 1 - sqrt(light); dayNight = dayNight * dayNight; dayNight = (1 - dayNight) * lightSign; dayNight = clamp(dayNight, 0, 1); float3 view = normalize(IN.view); float3 r = normalize(reflect(norm, sun)); float4 litR = lit(light, dot(r, view), 0.0).y; float3 earth = tex2D(daySampler, IN.uv).xyz; float4 mask = tex2D(maskSampler, IN.uv); float3 day = lerp(tex2D(daySampler, IN.uv).xyz, mask.xyz, mix); float3 night = tex2D(nightSampler, IN.uv).xyz; day = day * litR.y + float3(1,1,1) * litR.z * (1 - mask.w * mix); float3 color = lerp(night, day, dayNight); return float4(color,1); } // #o3d VertexShaderEntryPoint vsMain // #o3d PixelShaderEntryPoint psMain // #o3d MatrixLoadOrder RowMajor
float4x4 worldViewProjection : WorldViewProjection; float4x4 worldView : WorldView; float3 sunPos; float3 eyePos; struct a2v { float4 pos : POSITION; float3 norm : NORMAL; }; struct v2f { float4 pos : POSITION; float3 normal : TEXCOORD0; }; v2f vsMain(a2v IN) { v2f OUT; OUT.pos = mul(IN.pos, worldViewProjection); OUT.normal = normalize(mul(float4(IN.norm,0), worldView).xyz); return OUT; } float4 psMain(v2f IN): COLOR { float n = 1 - log(2 * normalize(IN.normal).z); return float4(0.3, 0.3, 1, n * n * n * n); } // #o3d VertexShaderEntryPoint vsMain // #o3d PixelShaderEntryPoint psMain // #o3d MatrixLoadOrder RowMajor