Shader tests

General questions about Indigo, the scene format, rendering etc...
Post Reply
223 posts
User avatar
OnoSendai
Developer
Posts: 6182
Joined: Sat May 20, 2006 6:16 pm
Location: Newcastle upon Tyne, UK
Contact:

Post by OnoSendai » Mon Jul 28, 2008 7:17 am

Test using FBM as a bump function:

Don't try this at home, there's a bug in the shader code that means this won't work until the 1.1.8 release.

Code: Select all

<material>
		<name>main_mat</name>

		<phong>
			<exponent>
				<constant>10000</constant>
			</exponent>
			<specular_reflectivity>
				<constant>
					<uniform>
						<value>0.6</value>
					</uniform>
				</constant>
			</specular_reflectivity>
			
			<bump>
				<shader>
					<shader>
						def eval(vec3 pos) real :
							mul(
								fbm(
									mul(getTexCoords(0), 100.0),
									10
								),
								0.001
							)
								
					</shader>
				</shader>
			</bump>
		</phong>
	</material>
Attachments
fbm bump.jpg
fbm bump.jpg (123.15 KiB) Viewed 2988 times

User avatar
Borgleader
Posts: 2149
Joined: Mon Jun 16, 2008 10:48 am

Post by Borgleader » Mon Jul 28, 2008 7:52 am

That looks pretty effing cool tbh :)
benn hired a mercenary to kill my sig...

User avatar
Grimm
Posts: 119
Joined: Sun Dec 09, 2007 7:38 pm
Location: Fairbanks, Alaska, USA

Post by Grimm » Mon Jul 28, 2008 8:53 am

@Ono - Very cool, I can't wait for v1.1.8. 8)

I tried the fbm function, much better, thanks. It doesn't quite give the result I was after though. Here is the expression I was trying to code for, is fbm similar to this?

Image

@Kram - Thanks, this has been a challenge that's for sure. :) Is this test more to your liking?

Image
Grimm

User avatar
Borgleader
Posts: 2149
Joined: Mon Jun 16, 2008 10:48 am

Post by Borgleader » Mon Jul 28, 2008 8:56 am

I like it :)
benn hired a mercenary to kill my sig...

User avatar
Grimm
Posts: 119
Joined: Sun Dec 09, 2007 7:38 pm
Location: Fairbanks, Alaska, USA

Post by Grimm » Mon Jul 28, 2008 9:20 am

Thanks Borgleader, I aim to please. :)
Grimm

User avatar
Grimm
Posts: 119
Joined: Sun Dec 09, 2007 7:38 pm
Location: Fairbanks, Alaska, USA

Post by Grimm » Mon Jul 28, 2008 12:00 pm

Ok, I'm pretty happy with this one. I have included the material for people to play with if they wish. And Ono can laugh at my code. :wink:

Image

Code: Select all

        <material>
                <name>marble</name>
                <diffuse>
                        <albedo>
                        <shader>
                         <shader>
                            <![CDATA[
                            def eval(vec3 pos) vec3 :
                              vec3(
                              abs(sub(1.0,
                              add(mul(0.5,
                                sub(pow(
                                  add(0.5,
                                    mul(0.5,
                                      sin(
                                        mul(0.6,
                                          mul(6.2831853,
                                            add(doti(pos),
                                              mul(2.0,
                                                fbm(pos,20)
                                                )
                                              )
                                            )
                                          )
                                        )
                                      )
                                  ), 2.0), 0.5
                                )
                              ),0.5))),
                              abs(sub(1.0,
                              add(mul(0.55,
                                sub(pow(
                                  add(0.5,
                                    mul(0.5,
                                      sin(
                                        mul(0.6,
                                          mul(6.2831853,
                                            add(doti(pos),
                                              mul(2.0,
                                                fbm(pos,8)
                                              )
                                            )
                                          )
                                        )
                                      )
                                    )
                                  ), 2.0), 0.5
                                )
                              ),0.45))),
                              abs(sub(1.0,
                              add(mul(0.5,
                                sub(pow(
                                  add(0.5,
                                    mul(0.5,
                                      sin(
                                        mul(0.6,
                                          mul(6.2831853,
                                            add(doti(pos),
                                              mul(2.0,
                                                fbm(pos,20)
                                              )
                                            )
                                          )
                                        )
                                      )
                                    )
                                  ), 2.0), 0.5
                                )
                              ),0.5)
                              )))
                            ]]>

                         </shader> 
                        </shader> 
                        </albedo>
                </diffuse>
        </material>
Grimm

Deus
Posts: 336
Joined: Sun Feb 04, 2007 3:47 am

Post by Deus » Mon Jul 28, 2008 12:57 pm

Why you use that strange intended syntax? Looks too much for me ;)

User avatar
eman7613
Posts: 597
Joined: Sat Sep 16, 2006 2:52 pm

Post by eman7613 » Mon Jul 28, 2008 4:58 pm

i do belive the syntax would benifit greatly from operators :lol: :shock:

for anyone used to coding in java's horrid bigdecimal *raises hand*, this looks very familure :roll:
Yes i know, my spelling sucks

User avatar
OnoSendai
Developer
Posts: 6182
Joined: Sat May 20, 2006 6:16 pm
Location: Newcastle upon Tyne, UK
Contact:

Post by OnoSendai » Tue Jul 29, 2008 12:58 am

Yeah, at some point in the future, I might add some infix '+', '-', '/' etc.. operators.

User avatar
OnoSendai
Developer
Posts: 6182
Joined: Sat May 20, 2006 6:16 pm
Location: Newcastle upon Tyne, UK
Contact:

Post by OnoSendai » Tue Jul 29, 2008 7:17 am

Grimm:
The usual way to do procedural marble, is, I think, to use FBM noise to perturb texture coordinates into a 1-D texture containing striped marble colours.

User avatar
OnoSendai
Developer
Posts: 6182
Joined: Sat May 20, 2006 6:16 pm
Location: Newcastle upon Tyne, UK
Contact:

Post by OnoSendai » Tue Jul 29, 2008 7:19 am

Another procedural bump test.
Varying the constant vector in this shader allows one to change the direction of groves, and so vary the direction of anisotropy.

Code: Select all

<phong>
			<exponent>
				<constant>10000</constant>
			</exponent>
			<specular_reflectivity>
				<constant>
					<uniform>
						<value>0.6</value>
					</uniform>
				</constant>
			</specular_reflectivity>
			
			<bump>
				<shader>
					<shader>
						<![CDATA[
						def eval() real :
							mul(
								fbm(
									dot(
										vec2(300.0, 300.0),
										getTexCoords(0)
									),
									10
								),
								0.001
							)
						]]>
					</shader>
				</shader>
			</bump>
		</phong>
Attachments
fbm_bump2.jpg
fbm_bump2.jpg (110.26 KiB) Viewed 2811 times

User avatar
OnoSendai
Developer
Posts: 6182
Joined: Sat May 20, 2006 6:16 pm
Location: Newcastle upon Tyne, UK
Contact:

Post by OnoSendai » Tue Jul 29, 2008 7:20 am

eman7613 wrote:i do belive the syntax would benifit greatly from operators :lol: :shock:

for anyone used to coding in java's horrid bigdecimal *raises hand*, this looks very familure :roll:
That's what you get for using a language without operator overloading (Java) :)

User avatar
OnoSendai
Developer
Posts: 6182
Joined: Sat May 20, 2006 6:16 pm
Location: Newcastle upon Tyne, UK
Contact:

Post by OnoSendai » Tue Jul 29, 2008 7:51 am

Another test:
Attachments
fbm_bump3.jpg
fbm_bump3.jpg (107.28 KiB) Viewed 2796 times

StompinTom
Indigo 100
Posts: 1821
Joined: Mon Sep 04, 2006 3:33 pm

Post by StompinTom » Tue Jul 29, 2008 7:52 am

that looks ridiculously nice! and i love how its all procedural :D

this still requires UV coordinates right? i wonder how it would behave with more complex models....

User avatar
OnoSendai
Developer
Posts: 6182
Joined: Sat May 20, 2006 6:16 pm
Location: Newcastle upon Tyne, UK
Contact:

Post by OnoSendai » Tue Jul 29, 2008 7:53 am

Yes, this requires UV coords.

Post Reply
223 posts

Who is online

Users browsing this forum: No registered users and 0 guests