Jump to content

Working with custom VEX surface shaders


haki

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...