Skip to content

Commit

Permalink
Add custom_ps_output_types with examples
Browse files Browse the repository at this point in the history
  • Loading branch information
darksylinc committed Feb 27, 2025
1 parent d5effe0 commit 586e4e9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Docs/src/manual/Rendering/hlms.md
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,45 @@ customized:
| custom_ps_uv_modifier_macros | PBS specific. Allows you to override the macros defined in Samples/Media/Hlms/Pbs/Any/UvModifierMacros_piece_ps.any so you can apply custom transformations to each UV. e.g. `#undef UV_DIFFUSE #define UV_DIFFUSE( x ) ((x) * 2.0)` |
| custom_ps_functions | Used to declare functions outside the main body of the shader |
| custom_ps_pixelData | Declare additional data in `struct PixelData` from Pixel Shader |
| custom_ps_output_types | Declare additional outputs for MRT (Multiple Render Targets). The variable rtv_target can be used to continue where standard Hlms left off (almost always 1). You don't have to use it if you are certain you aren't using features that required rtv_target to go > 1. |
### Examples:
```
// Add an extra float output (e.g. to be used with PFG_R32_FLOAT).
@piece( custom_ps_output_types )
@property( syntax == glsl || syntax == glslvk )
layout(location = @counter(rtv_target)) out float outPs_colour@counter(rtv_target);
@end
@property( syntax == hlsl )
float outPs_colour@counter(rtv_target) : SV_Target@counter(rtv_target);
@end
@property( syntax == metal )
float outPs_colour@counter(rtv_target) : [[ color(@counter(rtv_target)) ]];
@end
@end
```
```
// Alternatively just assume it's always 1, since you're in control of the compositor.
@piece( custom_ps_output_types )
@property( syntax == glsl || syntax == glslvk )
layout(location = 1) out float outPs_colour1;
@end
@property( syntax == hlsl )
float outPs_colour1 : SV_Target1;
@end
@property( syntax == metal )
float outPs_colour1 : [[ color(1) ]];
@end
@end
```
See ScreenSpaceReflections on how to setup an MRT compositor. Or see this [forum post reply](https://forums.ogre3d.org/viewtopic.php?p=557199#p557199).
# Run-time rendering {#HlmsRuntimeRendering}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
@end

@insertpiece( ExtraOutputTypes )
@insertpiece( custom_ps_output_types )
};
@end
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
@end

@insertpiece( ExtraOutputTypes )
@insertpiece( custom_ps_output_types )
};
@end
2 changes: 2 additions & 0 deletions Samples/Media/Hlms/Pbs/GLSL/PixelShader_ps.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ layout(std140) uniform;
@end
@end

@insertpiece( custom_ps_output_types )

@property( hlms_use_prepass )
@property( !hlms_use_prepass_msaa )
vulkan_layout( ogre_t@value(gBuf_normals) ) uniform texture2D gBuf_normals;
Expand Down
2 changes: 2 additions & 0 deletions Samples/Media/Hlms/Terra/GLSL/PixelShader_ps.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ in block
@end
@end

@insertpiece( custom_ps_output_types )

@property( !hlms_shadowcaster )

@property( hlms_use_prepass )
Expand Down
2 changes: 2 additions & 0 deletions Samples/Media/Hlms/Unlit/GLSL/PixelShader_ps.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ layout(location = FRAG_COLOR, index = 0) out midf4 outColour;
layout(location = FRAG_COLOR, index = 0) out midf outColour;
@end

@insertpiece( custom_ps_output_types )

// START UNIFORM DECLARATION
@insertpiece( custom_ps_uniformDeclaration )
// END UNIFORM DECLARATION
Expand Down

0 comments on commit 586e4e9

Please sign in to comment.