diff --git a/components/fx/pass.cpp b/components/fx/pass.cpp index 4b91939e01..daaaf22968 100644 --- a/components/fx/pass.cpp +++ b/components/fx/pass.cpp @@ -190,6 +190,11 @@ mat4 omw_InvProjectionMatrix() #endif } + vec3 omw_GetNormalsWorldSpace(vec2 uv) + { + return (vec4(omw_GetNormals(uv), 0.0) * omw.viewMatrix).rgb; + } + vec3 omw_GetWorldPosFromUV(vec2 uv) { float depth = omw_GetDepth(uv); diff --git a/docs/source/reference/postprocessing/omwfx.rst b/docs/source/reference/postprocessing/omwfx.rst index 2fb21a5162..8ff075bc6d 100644 --- a/docs/source/reference/postprocessing/omwfx.rst +++ b/docs/source/reference/postprocessing/omwfx.rst @@ -189,19 +189,30 @@ The following functions can be accessed in any fragment or vertex shader. +--------------------------------------------------+-------------------------------------------------------------------------------+ | ``vec4 omw_GetLastPass(vec2 uv)`` | Returns RGBA color output of the last pass | +--------------------------------------------------+-------------------------------------------------------------------------------+ -| ``vec3 omw_GetNormals(vec2 uv)`` | Returns normalized worldspace normals [-1, 1] | -| | | -| | The values in sampler are in [0, 1] but are transformed to [-1, 1] | -+--------------------------------------------------+-----------------------+-------------------------------------------------------+ +| ``vec3 omw_GetNormals(vec2 uv)`` | Returns normalized view-space normals [-1, 1] | ++--------------------------------------------------+-------------------------------------------------------------------------------+ +| ``vec3 omw_GetNormalsWorldSpace(vec2 uv)`` | Returns normalized world-space normals [-1, 1] | ++--------------------------------------------------+-------------------------------------------------------------------------------+ | ``vec3 omw_GetWorldPosFromUV(vec2 uv)`` | Returns world position for given uv coordinate. | -+--------------------------------------------------+-----------------------+-------------------------------------------------------+ ++--------------------------------------------------+-------------------------------------------------------------------------------+ | ``float omw_GetLinearDepth(vec2 uv)`` | Returns the depth in game units for given uv coordinate. | -+--------------------------------------------------+-----------------------+-------------------------------------------------------+ ++--------------------------------------------------+-------------------------------------------------------------------------------+ | ``float omw_EstimateFogCoverageFromUV(vec2 uv)`` | Returns a fog coverage in the range from 0.0 (no fog) and 1.0 (full fog) | | | | | | Calculates an estimated fog coverage for given uv coordinate. | -+--------------------------------------------------+-----------------------+-------------------------------------------------------+ - ++--------------------------------------------------+-------------------------------------------------------------------------------+ +| ``int omw_GetPointLightCount()`` | Returns the number of point lights available to sample from in the scene. | ++--------------------------------------------------+-------------------------------------------------------------------------------+ +| ``vec3 omw_GetPointLightWorldPos(int index)`` | Returns the world space position of a point light. | ++--------------------------------------------------+-------------------------------------------------------------------------------+ +| ``vec3 omw_GetPointLightDiffuse(int index)`` | Returns the diffuse color of the point light. | ++--------------------------------------------------+-------------------------------------------------------------------------------+ +| ``int omw_GetPointLightAttenuation(int index)`` | Returns the attenuation values of the point light. | +| | | +| | The XYZ channels hold the constant, linear, and quadratic components. | ++--------------------------------------------------+-------------------------------------------------------------------------------+ +| ``float omw_GetPointLightRadius(int index)`` | Returns the radius of the point light, in game units. | ++--------------------------------------------------+-------------------------------------------------------------------------------+ Special Attributes ################## diff --git a/files/data/l10n/OMWShaders/en.yaml b/files/data/l10n/OMWShaders/en.yaml index 8221be933f..6588591f00 100644 --- a/files/data/l10n/OMWShaders/en.yaml +++ b/files/data/l10n/OMWShaders/en.yaml @@ -34,6 +34,7 @@ DisplayDepthFactorName: "Depth colour factor" DisplayDepthFactorDescription: "Determines correlation between pixel depth value and its output colour. High values lead to brighter image." DisplayDepthName: "Visualize depth buffer" DisplayNormalsName: "Visualize pass normals" +NormalsInWorldSpace: "Show normals in world space" ContrastLevelDescription: "Constrast level." ContrastLevelName: "Constrast" GammaLevelDescription: "Gamma level." diff --git a/files/data/l10n/OMWShaders/ru.yaml b/files/data/l10n/OMWShaders/ru.yaml index b886f72b54..7a2bcfe80d 100644 --- a/files/data/l10n/OMWShaders/ru.yaml +++ b/files/data/l10n/OMWShaders/ru.yaml @@ -33,6 +33,7 @@ DisplayDepthName: "Визуализация буфера глубины" DisplayDepthFactorDescription: "Определяет соотношение между значением глубины пикселя и его цветом. Чем выше значение, тем ярче будет изображение." DisplayDepthFactorName: "Соотношение цвета" DisplayNormalsName: "Визуализация нормалей" +NormalsInWorldSpace: "Показывать нормали мирового пространства" ContrastLevelDescription: "Контрастность изображения" ContrastLevelName: "Контрастность" GammaLevelDescription: "Яркость изображения" diff --git a/files/data/shaders/debug.omwfx b/files/data/shaders/debug.omwfx index 360dfa26cd..a0c8754ec4 100644 --- a/files/data/shaders/debug.omwfx +++ b/files/data/shaders/debug.omwfx @@ -19,6 +19,11 @@ uniform_bool uDisplayNormals { display_name = "#{OMWShaders:DisplayNormalsName}"; } +uniform_bool uNormalsInWorldSpace { + default = false; + display_name = "#{OMWShaders:NormalsInWorldSpace}"; +} + fragment main { omw_In vec2 omw_TexCoord; @@ -30,8 +35,12 @@ fragment main { if (uDisplayDepth) omw_FragColor = vec4(vec3(omw_GetLinearDepth(omw_TexCoord) / omw.far * uDepthFactor), 1.0); #if OMW_NORMALS - if (uDisplayNormals && (!uDisplayDepth || omw_TexCoord.x < 0.5)) - omw_FragColor.rgb = omw_GetNormals(omw_TexCoord) * 0.5 + 0.5; + if (uDisplayNormals && (!uDisplayDepth || omw_TexCoord.x < 0.5)) { + if (uNormalsInWorldSpace) + omw_FragColor.rgb = omw_GetNormalsWorldSpace(omw_TexCoord) * 0.5 + 0.5; + else + omw_FragColor.rgb = omw_GetNormals(omw_TexCoord) * 0.5 + 0.5; + } #endif } }