During this season’s penultimate episode of “His Dark Materials,” Carlo Boreal met his demise.

The character’s fate wasn’t a surprise to those familiar with Philip Pullman’s fantasy novels, as the HBO series that recently finished its second season did not stray too far from the source material for this part of Boreal’s story.

But the Boreal of the TV show, portrayed by actor Ariyon Bakare, was distinct from the Boreal of the book: He played a much larger role onscreen, for one. And he has also generally been perceived as white.

Lord Boreal “is written in the book as a character who’s older with silver gray hair,” Bakare said. But “Pullman never actually says what color he is. … People assume, because of his status and his class, that he would be an older white man.”

For Bakare, who read the books to prepare for the role, Boreal’s race wasn’t an aspect of the character that stood out to him.

“I didn’t see color about the part,” he said. “I actually just saw what he was driven by — his motivations and how he moves within the world. And I was like, ‘Well, how could I interpret that to make a three-?dimensional character?’ ”

It has frequently been noted that mainstream fantasy fiction, especially titles set in worlds inspired by Western Europe, have historically fallen short when it comes to diverse representation. And in films and TV series from “The Lord of the Rings” to “Game of Thrones,” the onscreen inhabitants of these worlds have been predominantly white, a creative decision often justified by claims of historical or cultural “realism” — despite such worlds being populated with a cornucopia of magical beings.

Fantasy isn’t alone among popular storytelling genres: Sci-fi, horror and superhero shows also have a history of telling stories involving predominantly white protagonists in predominantly white worlds. Lately, though, projects such as “Watchmen” and “Lovecraft Country” have directly confronted racism through a genre lens in a way that has yet to be seen in fantasy television. Similarly, space-set projects such as “Star Trek: Discovery” and “The Mandalorian” have recently featured inclusive casting in their adventures, though without explicit reference to real-life historical moments or cultures.

Based on a series of books set in a world where all people are accompanied by animal partners that represent a part of their soul, “His Dark Materials” is the notable fantasy series that features a more racially inclusive cast than its source material indicates. Along with shows such as Netflix’s “Bridgerton,” and “The Witcher,” it’s showing how even Eurocentric fantasy can be more intentional in its approach to diverse representation.

According to “His Dark Materials” showrunner Jack Thorne, some of the earliest conversations he had with executive producer Jane Tranter about casting focused on ensuring the show reflected the diversity of the real world.

“I think the idea of colorblind casting is really problematic, and I don’t think we did that,” said Thorne. “We always thought about, ‘What are the possibilities of diversity here?’ And because we were casting quite a way before filming, we were able to then accommodate any gems that came out of the casting process and write to them.”

One of these gems was Bakare, whose casting led to further expansion of Boreal’s role.

For Tranter, the most important factor in casting a book adaptation is capturing the spirit of the character “rather than the shape of the character.” She doesn’t try to exactly match the character’s written description, she said.

“As soon as we knew we were writing for Ariyon, we then had to think very carefully about what that would mean for Boreal to be Black,” said Thorne. “We constructed a history for Boreal about where he came from and what he’d done to get where he had and what it was like for him in a Magisterial world, which is otherwise all white, and how that ended up being a key factor in his relationship with Mrs. Coulter” — Ruth Wilson’s character.

“Bridgerton” creator and executive producer Chris Van Dusen explained that his Netflix series took a color-conscious approach to casting. “I think ‘colorblind’ implies that color and race aren’t considered, and I don’t think that’s true for ‘Bridgerton,’ ” he said. “Color and race are a part of the show and as much of a part of the conversation as things like class and gender and sexuality are.”

Set in a fantasy version of Regency England, the world of “Bridgerton” is not only more inclusive in its casting — race is something that is addressed directly within the story.

“We wanted to go beyond mere representation — we wanted race to be a part of our text,” said Van Dusen. “The world of ‘Bridgerton’ is a world where we’re very clear about how the color of your skin doesn’t determine whether you’re high- or low-born.”

Indeed, Queen Charlotte, the real-life monarch at the series’ center, is believed to be descended from a Portuguese branch of nobility with African ancestry.

“There’s one possible fact, which is this idea that Queen Charlotte was England’s first queen of mixed race,” said Van Dusen. “It’s something that a lot of historians firmly believe there’s evidence for today. That idea really struck me and resonated with me because it made me wonder, ‘What could that world have looked like? Could this queen of England have used her power to elevate other people of color in society and given them things like titles and lands and dukedoms?’ That’s really how our particular Duke of Hastings came to be.”

For Tranter, the only way to ensure inclusion in the cast is to create inclusive hiring processes across the board. “It really is down to having the right conversations early on that set out the declaration of intent for what it is we need to do,” she said.

Ultimately, as Van Dusen points out, genuine inclusivity allows for the unexpected — and serendipitous — to occur, provided those in charge are willing to embrace it. While characters such as Queen Charlotte (Golda Rosheuvel) and Simon Bassett, the Duke of Hastings (Regé-Jean Page), were always meant to be played by Black actors, “Bridgerton’s” commitment to casting the best actors for certain roles led to finds such as Ruby Barker, who portrays Marina Thompson.

“We cast her, and we looked at whether it could have made sense,” said Van Dusen. “And we made it make sense.”