Skip to content
SiteEmail

cohtml.ViewRenderer

Inherits from IDisposable

Inherited by cohtml.ViewRendererRP

Name
voidUpdateSize(uint width, uint height)
virtual abstract voidDrawFrameOnScreen() =0
Draws the view into the active render target. Must be implemented by derived renderer implementations.
virtual voidDispose()
intGetCohtmlOriginY()
Returns the Y-axis origin convention used by Cohtml for texture UV coordinates.
intGetUnityOriginY()
Returns the Y-axis origin convention used by Unity for texture UV coordinates.
RenderTextureCreateRenderTexture(string name, int width, int height, UnityEngine.Experimental.Rendering.GraphicsFormat format, int depth =0, bool enableRandomWrite =false)
Creates and initializes a new RenderTexture with the specified dimensions and graphics format.
ShaderGetViewShader(CohtmlView view)
voidUpdateFlipKeyword(Material material, bool isFlipped)
voidSetInWorldMaterial(Material material, RenderTexture texture, bool isTransparent)
voidApplyTransparencyBlendModes(Material material, bool isTransparent)
Applies the appropriate blend mode and depth writing (ZWrite) settings to a given material based on whether it should be rendered as transparent or opaque. This updates the hidden _SrcBlend and _DstBlend shader properties used in the material’s shader. Transparent mode: SrcBlend = 5 (SrcAlpha), DstBlend = 10 (OneMinusSrcAlpha). Opaque mode: SrcBlend = 1 (One), DstBlend = 0 (Zero).
Name
ViewRenderer(CohtmlView view)
Initializes the renderer with the specified view. Sets up optional partitioning resources, compute shaders, and filtering materials depending on the current view configuration.
virtual abstract voidApplyCompositorTextures() =0
Renders all composition textures associated with the current CohtmlView onto the given render target. Used for the Surface Partitioning feature.
MeshSetupQuad()
Creates a 1×1 quad mesh with UVs for fullscreen or partitioned UI rendering.
Name
CohtmlViewView
Name
const stringTextureName
const stringMaterialName
const stringBackgroundName
const stringGlobalBackdropOutputName
const stringGlobalBackdropMaskName
const stringIntermediateName
const stringCameraCopyName
IGlobalBackdropFilterGlobalBackdropFilter
readonly intCameraCopy
readonly intMainTexId
readonly intOverlayTexId
readonly intUVOffsetId
readonly intUVScaleId
readonly intSrcBlendId
readonly intDstBlendId
readonly intZWriteId
readonly intTopLeft
readonly intBottomLeft
Name
const stringCohtmlViewName
Meshm_QuadMesh
Matrix4x4m_PixelMatrix
MaterialPropertyBlockm_MaterialPropertyBlock
void UpdateSize(
uint width,
uint height
)
virtual abstract void DrawFrameOnScreen() =0

Draws the view into the active render target. Must be implemented by derived renderer implementations.

Reimplemented by: cohtml.ViewRendererRP.DrawFrameOnScreen

Depending on configuration, this may:

  • Apply composition textures (UISurfacePartitioning)
  • Execute C# backend rendering specific operations
  • Apply global backdrop filter feature
  • Render the final view texture onto the target
virtual void Dispose()

Reimplemented by: cohtml.ViewRendererRP.Dispose

static int GetCohtmlOriginY()

Returns the Y-axis origin convention used by Cohtml for texture UV coordinates.

Return: 1 if Cohtml uses a top-left Y origin; otherwise 0.

static int GetUnityOriginY()

Returns the Y-axis origin convention used by Unity for texture UV coordinates.

Return: 1 if Unity uses a top-left Y origin; otherwise 0.

static RenderTexture CreateRenderTexture(
string name,
int width,
int height,
UnityEngine.Experimental.Rendering.GraphicsFormat format,
int depth =0,
bool enableRandomWrite =false
)

Creates and initializes a new RenderTexture with the specified dimensions and graphics format.

Parameters:

  • name The name to assign to the RenderTexture for debugging purposes.
  • width The width of the texture in pixels.
  • height The height of the texture in pixels.
  • format The graphics format of the texture.
  • depth Optional. Number of bits in depth buffer.
  • enableRandomWrite Optional. Set to true to enable random write access (UAV). Defaults to false.

Return: The successfully created RenderTexture, or null if the creation failed (e.g., due to an unsupported format or memory limits).

static Shader GetViewShader(
CohtmlView view
)
static void UpdateFlipKeyword(
Material material,
bool isFlipped
)
static void SetInWorldMaterial(
Material material,
RenderTexture texture,
bool isTransparent
)
static void ApplyTransparencyBlendModes(
Material material,
bool isTransparent
)

Applies the appropriate blend mode and depth writing (ZWrite) settings to a given material based on whether it should be rendered as transparent or opaque. This updates the hidden _SrcBlend and _DstBlend shader properties used in the material’s shader. Transparent mode: SrcBlend = 5 (SrcAlpha), DstBlend = 10 (OneMinusSrcAlpha). Opaque mode: SrcBlend = 1 (One), DstBlend = 0 (Zero).

Parameters:

  • material The target Material to update.
  • isTransparent If true, configures the material for standard alpha blending and disables ZWrite (0). If false, configures it for opaque rendering and enables ZWrite (1).
ViewRenderer(
CohtmlView view
)

Initializes the renderer with the specified view. Sets up optional partitioning resources, compute shaders, and filtering materials depending on the current view configuration.

Parameters:

  • view The CohtmlView instance controlling rendering behavior.
virtual abstract void ApplyCompositorTextures() =0

Renders all composition textures associated with the current CohtmlView onto the given render target. Used for the Surface Partitioning feature.

Reimplemented by: cohtml.ViewRendererRP.ApplyCompositorTextures

static Mesh SetupQuad()

Creates a 1×1 quad mesh with UVs for fullscreen or partitioned UI rendering.

Return: A newly created quad mesh.

CohtmlView View;
const string TextureName = CohtmlViewName + "Texture";
const string MaterialName = CohtmlViewName + "Material";
const string BackgroundName = CohtmlViewName + "Background";
const string GlobalBackdropOutputName = CohtmlViewName + "GlobalBackdropOutput";
const string GlobalBackdropMaskName = CohtmlViewName + "GlobalBackdropMask";
const string IntermediateName = CohtmlViewName + "Intermediate";
const string CameraCopyName = CohtmlViewName + "CameraCopy";
IGlobalBackdropFilter GlobalBackdropFilter;
static readonly int CameraCopy = Shader.PropertyToID(CameraCopyName);
static readonly int MainTexId = Shader.PropertyToID("_MainTex");
static readonly int OverlayTexId = Shader.PropertyToID("_OverlayTex");
static readonly int UVOffsetId = Shader.PropertyToID("_UVOffset");
static readonly int UVScaleId = Shader.PropertyToID("_UVScale");
static readonly int SrcBlendId = Shader.PropertyToID("_SrcBlend");
static readonly int DstBlendId = Shader.PropertyToID("_DstBlend");
static readonly int ZWriteId = Shader.PropertyToID("_ZWrite");
static readonly int TopLeft = (int)renoir.ImageOrigin.TopLeft;
static readonly int BottomLeft = (int)renoir.ImageOrigin.BottomLeft;
const string CohtmlViewName = "CoherentView_";
Mesh m_QuadMesh;
Matrix4x4 m_PixelMatrix;
MaterialPropertyBlock m_MaterialPropertyBlock;