Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #787: IndigoShader, expose ability to add UniformBlocks #790

Merged

Conversation

davesmith00000
Copy link
Member

No description provided.

@davesmith00000
Copy link
Member Author

This works, but I'm still thinking about what I've ended up doing here a bit.

I've realised (as a consequence of this work, wasn't the point of the PR) that you can now use one case class to define the data structure for both the Indigo and Ultraviolet side of passing data from engine to shader. The catch is that your definition must eventually use the few UV types we support for UBOs.

This means that either we allow all the types we can support (as-is, such as Radians) but the user has to know they need two different case classes (class 1 has angle: Radians and class 2 angle: Float), or we reduce support down to the 5 acceptable types and they get an error... but at least it's obvious when there's a problem.

I'm leaning towards the latter with some extension methods to aide conversion.

*/
trait IndigoShader extends GameLauncher[IndigoShaderModel, IndigoShaderModel, Unit] {

given [A](using toUBO: ToUniformBlock[A]): Conversion[A, UniformBlock] with
def apply(value: A): UniformBlock = toUBO.toUniformBlock(value)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be the first and only implicit conversion in Indigo. 😛

Based on the comment above uniformBlocks below, saves the user from doing:

final case class CustomData(color: RGBA, customTime: Seconds) extends FragmentEnvReference derives ToUniformBlock
def uniformBlocks: Batch[UniformBlock] = Batch(
  summon[ToUniformBlock[CustomData]].toUniformBlock(CustomData(RGBA.Magenta, 0.seconds))
)

@davesmith00000
Copy link
Member Author

I'm leaning towards the latter with some extension methods to aide conversion.

I've had a go and the implementation sucks and is quite spectacularly unfriendly to use. I think I'm going to keep it as-is and just recommend sticking with UV types in the examples.

@davesmith00000 davesmith00000 merged commit 6c5e481 into main Nov 19, 2024
2 checks passed
@davesmith00000 davesmith00000 deleted the issue/787/allow-uniform-data-on-shader-entry-point branch November 19, 2024 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant