Jump to content
haki

Working with custom VEX surface shaders

Recommended Posts

Hi,

I've some experience with VEX in SOP land but I'm new to Mantra shading and I want to get better at writing vex shaders. What would be the modern way of doing that?

In particular, I'm not entirely sure if I could simply write my code and hit compile (the way I would with OSL in RenderMan) without ever leaving Houdini or restarting the renderer for that matter.

For instance, I managed to compile the following from a vfl (a modified sidefx example) into an HDA (.\vcc -l "%HOME%\houdini18.5\vex\hcartoon.hda" "%HOME%\houdini18.5\vex\hcartoon.vfl") and it's available under /SHOP/Digital Assets and it works.

#include <shading.h>

#pragma opname		hcartoon
#pragma oplabel		"HCartoon"
#pragma opicon		SHOP_surface

#pragma label	colora	"Color A"
#pragma label	colorb	"Color B"
#pragma hint	colora	color
#pragma hint	colorb	color
#pragma hint	Cd	hidden

surface
hcartoon(
	vector colora={0.2, 0.5, 0};
	vector colorb={0, 0.2, 0.8};
	vector Cd=1;
    )
{
	vector Cx;
	illuminance(P){
		Cx = Cl;
		shadow(Cl);
		if (Cl == Cx){
			Cf = colora;
		} 
		else{
			Cf = colorb;
		}
	}
}

However, isn't there a more straightforward way? Do I always have to compile to HDA and write all those pragmas? I was hoping for something like an attribute wrangler approach.

So, there's the Surface Shader Builder (vopsurface) that I have to admit I don't quite get as far as writing code goes. Snippet? Inline? How about inputs and outputs in it? Surely not with pragmas in there, right? I tried with a snippet, got a compile error 'Invalid return type (surface)'.

If anyone can help me with it, that'd be awesome! Thanks,

Hristo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×