Revision Difference
Shaders/g_sky#562661
<cat>shader</cat>
<title>g_sky</title>
<shader>
<description>This shader was especially designed to be used with maps, in particular the cube maps(up, down, front, back, left, right), they allow to modify the ambiance of a map.</description>
<parameters>
<item name="bottomcolor" type="Vector">The top bottom of the texture(used for gradient)</item>
⤶
<item name="duskcolor" type="Vector">The dusk color</item>
⤶
<item name="duskscale" type="number">The scale of the dusk</item>
⤶
<item name="duskintensity" type="number">The intensity of the dusk</item>
⤶
<item name="fadebias" type="number">The fade bias</item>
⤶
<item name="hdrscale" type="number">The HDR scale</item>
⤶
<item name="suncolor" type="Vector">The color of the sun</item>
⤶
<item name="sunnormal" type="Vector">The normal of the sun</item>
⤶
<item name="sunsize" type="number">The size of the sun</item>
⤶
<item name="topcolor" type="Vector">The top color of the texture(used for gradient)</item>
<item name="bottomcolor" type="Vector">The top bottom of the texture(used for gradient)</item>
⤶
<item name="duskcolor" type="Vector">The dusk color</item>
⤶
<item name="duskscale" type="number">The scale of the dusk</item>
⤶
<item name="duskintensity" type="number">The intensity of the dusk</item>
⤶
<item name="fadebias" type="number">The fade bias</item>
⤶
<item name="hdrscale" type="number">The HDR scale</item>
⤶
<item name="suncolor" type="Vector">The color of the sun</item>
⤶
<item name="sunnormal" type="Vector">The normal of the sun</item>
⤶
<item name="sunsize" type="number">The size of the sun</item>
⤶
<item name="topcolor" type="Vector">The top color of the texture(used for gradient)</item>
⤶
<item name="startexture" type="string">Specifies which star texture will be used</item>⤶
⤶
<item name="starfade" type="number">Determines how visible the stars are</item>⤶
⤶
<item name="starscale" type="number">Determines the scale of the stars</item>⤶
⤶
<item name="starpos" type="number">The scroll position of the star texture. Used for texture scrolling. Can be any value</item>⤶
⤶
<item name="starlayers" type="number">Specifies how many layers of stars should be rendered. Accepts values between 0 and 4. 0 means no stars will be rendered</item>⤶
</parameters>
⤶
</shader>⤶
⤶
</shader>⤶
⤶
<example>⤶
<description>A basic example that shows how to create a material with this shader and render it.⤶
This particular example draws a custom skybox on top of the existing one.⤶
It uses `g_Sky`'s default parameters as an example.</description>⤶
<code>⤶
local sky_material = CreateMaterial("g_Sky_example", "g_Sky", {⤶
["$topcolor"] = "[0 0 1]",⤶
["$bottomcolor"] = "[0 1 1]",⤶
["$fadebias"] = "1.0",⤶
["$hdrscale"] = "1.0",⤶
["$sunnormal"] = "[0 1 0.5]",⤶
["$duskcolor"] = "[1 0.4 0]",⤶
["$duskscale"] = "1",⤶
["$duskintensity"] = "1.0",⤶
["$suncolor"] = "[1 1 1]",⤶
["$sunsize"] = "1",⤶
["$startexture"] = "skybox/starfield",⤶
["$starfade"] = "1",⤶
["$starscale"] = "1",⤶
["$starpos"] = "1",⤶
["$starlayers"] = "0"⤶
})⤶
⤶
local maxs = Vector(64, 64, 64)⤶
local mins = -maxs⤶
⤶
hook.Add("PostDrawTranslucentRenderables", "", function(a, b, c)⤶
if b or c then⤶
local sun_info = util.GetSunInfo()⤶
sky_material:SetVector("$sunnormal", sun_info.direction)⤶
cam.Start3D(vector_origin, EyeAngles())⤶
render.SetMaterial(sky_material)⤶
cam.IgnoreZ(true)⤶
-- Swapped mins and maxs so that the box will render inside out⤶
render.DrawBox(vector_origin, angle_zero, maxs, mins, color_white)⤶
cam.IgnoreZ(false)⤶
cam.End3D()⤶
end⤶
end)⤶
</code>⤶
</example>