07th-mod / 07th-mod/higurashi-assembly

Non-zero "originx" argument breaks image scaling

Abierto
#142 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C#
Estrellas
12
Forks
12
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

## Problem Description

I was looking at the code which handles scaling images to fit on the screen (to implement a feature related to letterboxing), and I noticed that there are two "CreateMesh" functions - see this [github code link](https://github.com/07th-mod/higurashi-assembly/blob/c2c64a6b977549efb199a44f726c530a1b0e9f93/Assets.Scripts.Core.Scene/Layer.cs#L873-L897)

### CreateMesh(..., Vector2 origin, ...)

- Used when the draw call is has a valid value for "origin", which boils down to setting the `originx` parameter to a nonzero value in draw calls in the game script.
- I think this function is nearly never used, as we don't ever set `originx` to anything other than zero
- I think this function is broken, due to using integer scaling function rather than float, unless the "only integer scaling" is intentional.
- For example, if the image height is 800, and it gets clamped to 480, then `scaling_factor = 800 / 480 = 0`, so `newWidth = scaling_factor * oldWidth = 0 * oldWidth = 0` and the image doesn't show at all...
- Only certain draw functions are affected. I think these are affected:
- DrawBustshotWithFiltering(...)
- DrawSprite(...)
- MODDrawCharacterWithFiltering(...)

### CreateMesh(..., LayerAlignment alignment, ...)

- Used when the draw call has 'origin' set to null
- Scaling is performed correctly
- This function is used most of the time when drawing everything

Note that the exact implementation of these functions are different depending on the chapter, refer to [#141 - Image letterboxing inconsistent between chapters ](https://github.com/07th-mod/higurashi-assembly/issues/141) for more details. However, all implementations of the `Vector2 origin` have the same integer scaling.

## Testing

I did do a quick test and setting originx non-zero did seem to break the image, but my testing wasn't very thorough.

## TODO

As changing this may affect everything in the whole engine, and we have so many mod options, I probably won't fix it.

- [ ] Ask orian if the `originx` argument is ever deliberately used

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

El issue apunta a las líneas 873-897 de Layer.cs. Examina las dos funciones CreateMesh, centrándote en la que usa Vector2 origin. Comprueba cómo se calcula el scaling_factor (división entera vs. división de punto flotante). Prueba estableciendo originx en un valor distinto de cero en llamadas de dibujo afectadas como DrawBustshotWithFiltering para ver si las imágenes desaparecen. Verifica en diferentes capítulos, ya que las implementaciones varían.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
unity
Área
computer-graphics, game-dev
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.