Skip to content

Commit

Permalink
PBR renderer: fixed point mode in GLES
Browse files Browse the repository at this point in the history
It requires setting the value of gl_PointSize in the vertex shader
  • Loading branch information
TheMostDiligent committed Nov 7, 2023
1 parent ae53828 commit a52858d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions PBR/src/PBR_Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<IShader> pVS;
{
Expand Down
5 changes: 5 additions & 0 deletions Shaders/PBR/private/RenderPBR.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions shaders_inc/RenderPBR.vsh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit a52858d

Please sign in to comment.