From a52858d8e2d071fe880ed68ade478551e5eed7a9 Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 7 Nov 2023 12:42:29 -0800 Subject: [PATCH] PBR renderer: fixed point mode in GLES It requires setting the value of gl_PointSize in the vertex shader --- PBR/src/PBR_Renderer.cpp | 9 +++++++-- Shaders/PBR/private/RenderPBR.vsh | 5 +++++ shaders_inc/RenderPBR.vsh.h | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/PBR/src/PBR_Renderer.cpp b/PBR/src/PBR_Renderer.cpp index 2cd01209..512fa833 100644 --- a/PBR/src/PBR_Renderer.cpp +++ b/PBR/src/PBR_Renderer.cpp @@ -866,8 +866,13 @@ void PBR_Renderer::CreatePSO(PsoHashMapType& PsoHashMap, const GraphicsPipelineD ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; ShaderCI.pShaderSourceStreamFactory = pCompoundSourceFactory; - const auto Macros = DefineMacros(PSOFlags); - ShaderCI.Macros = Macros; + auto Macros = DefineMacros(PSOFlags); + if (GraphicsDesc.PrimitiveTopology == PRIMITIVE_TOPOLOGY_POINT_LIST && m_Device.GetDeviceInfo().IsGLDevice()) + { + // If gl_PointSize is not defined, points are not rendered in GLES + Macros.Add("USE_GL_POINT_SIZE", "1"); + } + ShaderCI.Macros = Macros; RefCntAutoPtr pVS; { diff --git a/Shaders/PBR/private/RenderPBR.vsh b/Shaders/PBR/private/RenderPBR.vsh index f08abdeb..e2ec2f03 100644 --- a/Shaders/PBR/private/RenderPBR.vsh +++ b/Shaders/PBR/private/RenderPBR.vsh @@ -93,4 +93,9 @@ void main(in VSInput VSIn, #if USE_TEXCOORD1 VSOut.UV1 = VSIn.UV1; #endif + +#ifdef USE_GL_POINT_SIZE + // If gl_PointSize is not defined, points are not rendered in GLES + gl_PointSize = 1.0; +#endif } diff --git a/shaders_inc/RenderPBR.vsh.h b/shaders_inc/RenderPBR.vsh.h index 829f51a8..96b220da 100644 --- a/shaders_inc/RenderPBR.vsh.h +++ b/shaders_inc/RenderPBR.vsh.h @@ -93,4 +93,9 @@ "#if USE_TEXCOORD1\n" " VSOut.UV1 = VSIn.UV1;\n" "#endif\n" +"\n" +"#ifdef USE_GL_POINT_SIZE\n" +" // If gl_PointSize is not defined, points are not rendered in GLES\n" +" gl_PointSize = 1.0;\n" +"#endif\n" "}\n"