## Saturday 3 October 2015

### RGB/HSV in HLSL 7

I got a very kind email from David Schaeffer yesterday with some bug fixes for the shader code I wrote for converting RGB to the HCY colour space.

My original implementation was

float3 RGBtoHCY(in float3 RGB)
{
float3 HCV = RGBtoHCV(RGB);
float Y = dot(RGB, HCYwts);
if (HCV.y != 0)
{
float Z = dot(HUEtoRGB(HCV.x), HCYwts);
if (Y > Z)
{
Y = 1 - Y;
Z = 1 - Z;
}
HCV.y *= Z / Y;
}
return float3(HCV.x, HCV.y, Y);
}

As he points out:
It seems to me that you have an error in your RGB to HCY code, though.  I was having some pixels always saturate to white, and after looking at Kuzma Shapran's original code I don't think the value of Y should actually be changed, only using the adjusted value of Y to calculate HCV.y.  Additionally I think the check for 0 in the original code was meant to prevent divide by 0 errors, so should be using Y instead of HCV.y.
I'll have to bow to David's superior knowledge on HCY usage as I've never actually used it in anger. So here's his improved version:

float3 RGBtoHCY(in float3 RGB)
{
float3 HCV = RGBtoHCV(RGB);
float Y = dot(RGB, HCYwts);
float Z = dot(HUEtoRGB(HCV.x), HCYwts);
if (Y < Z)
{
HCV.y *= Z / (Epsilon + Y);
}
else
{
HCV.y *= (1 - Z) / (Epsilon + 1 - Y);
}
return float3(HCV.x, HCV.y, Y);
}

I've updated the snippets page accordingly.

## Thursday 1 October 2015

### Monsters of the Movies

When I was at primary school, they used to run a book club where you could buy books with your pocket money. One of the purchases I made was Denis Gifford's "Monsters of the Movies" for the princely sum of 45p.

The book fascinated me and probably inspired my love of horror films. However, re-reading the book recently there are a few wrinkles I hadn't noticed.

The book was published in 1977 and had 46 entries:

 The Alligator People in The Alligator People (1959) Certificate X The Ape Man in The Ape Man (1942) Certificate X (now PG) Barnabas Collins in House of Dark Shadows (1970) Certificate X (now 18) The Beast in Beauty and the Beast (1946) Certificate A (now PG) The Blood Beast Terror in The Blood Beast Terror (1967) Certificate X (now 12) The Bride of Frankenstein in The Bride of Frankenstein (1935) Certificate A (now PG) Carmilla in The Vampire Lovers (1969) Certificate X (now 15) The Cat in The Cat and the Canary (1939) Certificate A (now PG) Count Yorga in Count Yorga, Vampire (1970) Certificate X Countess Dracula in Countess Dracula (1971) Certificate X (now 18) The Creature in The Creature from the Black Lagoon (1954) Certificate A (now PG) The Creeper in The Brute Man (1946) Certificate A The Demon in The Curse of the Demon (1958) Certificate X (now PG) Dr Caligari in The Cabinet of Dr Caligari (1919) Certificate A (now U) Dr Jekyll and Mr Hyde in Dr Jekyll and Mr Hyde (1931) Certificate A (now 12A) Dr Moreau in The Island of Lost Souls (1932) Certificate - (now PG) Dr Phibes in The Abominable Dr Phibes (1971) Certificate X (now 15) Dr X in Doctor X (1932) Certificate A Dracula in Dracula (1931) Certificate A (now PG) The Electric Man in Man-Made Monster (1941) Certificate A The Fly in The Fly (1958) Certificate X (now PG) Frankenstein's Monster in Frankenstein (1931) Certificate A (now PG) Fu Manchu in The Mask of Fu Manchu (1932) Certificate A The Ghoul in The Ghoul (1933) Certificate A (now PG) The Golem in The Golem (1920) Certificate - (now PG) The Gorgon in The Gorgon (1964) Certificate X (now 12) The Hunchback of Notre Dame in The Hunchback of Notre Dame (1923) Certificate A (now PG) The Invisible Man in The Invisible Man (1933) Certificate A (now PG) King Kong in King Kong (1933) Certificate A (now PG) The Mad Monster in The Mad Monster (1941) Certificate - The Manster in The Split (1962) Certificate X The Mummy in The Mummy's Hand (1941) Certificate A (now PG) The Munsters in Munster, Go Home! (1966) Certificate U (now U) Nosferatu in Nosferatu (1922) Certificate A (now PG) Orlac in The Hands of Orlac (1935) Certificate A The Phantom of the Opera in The Phantom of the Opera (1925) Certificate U (now PG) The Raven in The Raven (1935) Certificate A (now 15) The Reptile in The Reptile (1966) Certificate X (now 15) Teenage Werewolf in I Was a Teenage Werewolf (1957) Certificate X (now 15) The Walking Dead in The Walking Dead (1936) Certificate A The Werewolf of London in Werewolf of London (1934) Certificate A (now PG) White Zombie in White Zombie (1932) Certificate A (now PG) The Wild Woman in The Jungle Captive (1944) Certificate H The Wolf Man in The Wolf Man (1941) Certificate A (now PG) Zaroff in The Most Dangerous Game (1932) Certificate A (now 12) The Zombie in The Plague of the Zombies (1966) Certificate X (now 12A)

Here are my thoughts:
• The latest films listed were released in 1971, so perhaps Mr Gifford wrote the book a few years before it was finally published.
• The fact that's there 46 entries, as opposed to some nice "round" number like 50 is probably due to the limitations of the cheap printing: there are 48 leaves between the soft covers.
• Some of the films are a bit suspect for a book obviously aimed at children: "The Vampire Lovers" and "The Abominable Dr Phibes" being prime examples.
• "The Island of Lost Souls" was rejected by the BBFC and only given an X certificate in 1958.
• "The Golem" was never release in the UK.
• "The Mad Monster" was initially rejected by the BBFC and only given an X certificate in 1952.
• "Countess Dracula" is currently listed as a 18 certificate, but this is presumably because it hasn't been re-submitted. It's the equivalent of a PG in the USA.
• All the zombies listed are "voodoo zombies"; "Night of the Living Dead" (1968) isn't listed.
• Some of the films aren't even monster films and a few are actually comedies.
• I've managed to see just over half of the films on the list.
• The most obscure is surely "The Split" which I'm dying to see.
If I were going to "round up" the list to 50 by adding four more, which monsters would I choose? Funnily enough, they're all 1950s films (which seems to be under-represented in the original list):
1. "The Thing from Another World" (1951)
2. "The Beast from 20,000 Fathoms" (1953) not because it's a good film, but because of fond memories staying up late to watch it on TV during the school holidays.
3. "Godzilla" (1954) - how did this not get on the list?
4. "The Blob" (1958)
Two films that just missed the cut were "Forbidden Planet" (1956) and "The Day of the Triffids" (1962).

UPDATE 2016-09-03: I've discovered that some of the more esoteric movies are now available at archive.org.