Page 1 of 15

Shader tests

Posted: Tue Jun 24, 2008 6:44 am
by OnoSendai
Hi all,

Well, when i should have been fixing bugs, adding long-requested features, and replying to emails, I've instead been working on a shader language for Indigo!

*begs forgiveness from exporter writers*

The language is a simple little strongly typed, pure functional language.
It's currently interpreted by a stack-based bytecode VM I hacked up.

I looked around at a few existing languages / VMs, but none of them provided quite what i wanted, or had too much overhead, so I decided to roll my own. Perhaps I'll switch to an existing language later, we'll see.

So here's an example shader used on a diffuse material:

Code: Select all

	<material>
		<name>mat1</name>
		<diffuse>
			<colour>0.7 0.7 0.7</colour>


			<albedo_texture>
				<uv_set>albedo</uv_set>
				<path>colorchecker_srgb_from_ref.jpg</path>
				<exponent>2.2</exponent>
			</albedo_texture>
			
	
			<albedo_shader>
				<![CDATA[
				
				def rgbAlbedo(vec3 pos, vec2 uv) vec3 :
					sample2DTextureVec3(
						0,
						add(
							getTexCoords(0, uv),
							vec2(fbm(pos, 10))
							)
						)
							
				]]>
			</albedo_shader>
		</diffuse>
	</material>
And the result:
http://fatalfantasy6.deviantart.com/art ... 2-89539933

It uses a fractal Brownian motion function to perturb the texture coordinates. (good for making procedural marble :) )

You will be able to write shaders for any material parameter, also for displacement.

Thoughts, ideas, requests, etc..?

Posted: Tue Jun 24, 2008 7:01 am
by PureSpider
/me hears Ono's mama yelling: "NICK! GET BACK TO WORK! NOW!"
:D
Unfair advantage as we can't upload such pictures to deviantART :P

Posted: Tue Jun 24, 2008 7:32 am
by Borgleader
Damn I want to see it but Im at work and deviant art is blocked :( Oh well I'll have to wait 'till I'm home (in 3 hours). Sounds like a great feature to look forward to though

Posted: Tue Jun 24, 2008 8:35 am
by zsouthboy
Ono, you're killing us here, slowly but surely :P

I'm guessing that translating [3d modeller of choice]'s procedurals into the shader language will be fun. (but very powerful)

Posted: Tue Jun 24, 2008 8:40 am
by Kram1032
O.o Great!




are you FatalFantasy6?

Posted: Tue Jun 24, 2008 8:41 am
by OnoSendai
Yup, that's my deviant art page.

Posted: Tue Jun 24, 2008 8:42 am
by Kram1032
ok, adding :)

Posted: Tue Jun 24, 2008 8:43 am
by psor
Just awesome! :shock: 8) :wink:

Posted: Tue Jun 24, 2008 9:24 am
by Whaat
can someone explain what you mean by 'shader'? Does it basically mean that you define material attributes using mathematical functions? Like user customized procedurals?

Posted: Tue Jun 24, 2008 10:07 am
by neepneep
whoaa ... its as if indigo licked the back of a hallucingenic toad :shock:

Posted: Tue Jun 24, 2008 10:30 am
by dougal2
oh fuck.

Posted: Tue Jun 24, 2008 10:47 am
by OnoSendai
Whaat wrote:can someone explain what you mean by 'shader'? Does it basically mean that you define material attributes using mathematical functions? Like user customized procedurals?
Yup, basically you embed a short program in the scene file, that describes the albedo, exponent, blend factor, displacement, etc.. of any material.
The program is executed whenever a ray hits the material, and can therefore use such information as the normal at the hit position, hit position, surface uv coordinates at the hit position etc.. to calculate the final colour or whatever.

The shaders will be a bit more limited than renderman shaders (which more or less the industry standard for non-realtime rendering), as I want to keep the physical plausibility and unbiased properties of Indigo. (in renderman you can do any kind of unphysical shading). So therefore the function of the shaders will be limited to controlling parameters of the existing BRDFs implemented in Indigo (at least for now :) )

Posted: Tue Jun 24, 2008 7:11 pm
by rgigante
Finally it is! That's a big step ahead compared to competitors!

Thanks for sharing.

Posted: Tue Jun 24, 2008 8:07 pm
by suvakas
Cool and complicated. 8)

Posted: Tue Jun 24, 2008 8:19 pm
by Big Fan
when i should have...

*begs forgiveness from exporter writers*
not happy out here :?