Shader tests

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

Post by OnoSendai » Thu Sep 25, 2008 2:19 pm

Ok, now we're talking:
This is a similar technique to the last shader, but pulls the colours from a 1-D slice of the source texture I've attached.
Also I'm moving the sampling coords with world space position properly now, as opposed to the last shader.

Code: Select all

	<material>
		<name>previewmaterial</name>

		<phong>
			<texture>
				<path>marble_src.jpg</path>
				<exponent>2.2</exponent>
				<uv_set>default</uv_set>
			</texture>
			<diffuse_albedo>
				<shader>
					<shader>
						<![CDATA[
							def col(real x) vec3 :
								sample2DTextureVec3(0, vec2(x, 0.5)) # sample the source texture across a horizontal band
									
							def eval(vec3 pos) vec3 : 
								col(
									add(
										dot(pos, vec3(10.0, 10.0, 10.0)), # the magnitude of the vec3 controls how fast the src texture repeats, and in what direction.
										mul(
											fbm(
												mul(
													pos,
													100.0 # This controls the minimum frequency of the perturbation
												),
												10 # num octaves of noise.
											),
											0.05 # This controls the magnitude of the perturbation
										)
									)
								)
						]]>
					</shader>
				</shader>
			</diffuse_albedo>

			<ior>1.4</ior>

			<exponent>
				<constant>1000.0</constant>
			</exponent>
		</phong>
	</material>
Attachments
marble2.jpg
marble2.jpg (69.15 KiB) Viewed 3107 times
marble_src.jpg
marble_src.jpg (3.09 KiB) Viewed 3106 times

User avatar
CTZn
Posts: 7240
Joined: Thu Nov 16, 2006 4:34 pm
Location: Paris, France

Post by CTZn » Thu Sep 25, 2008 3:13 pm

OnoSendai wrote:Erm, I am already using the FBM to perturb the position that is sampled from the 1-D 'colour function'
Ah well yes you "remapped" the fbm with col, now I understand that. That's not the same than remapping col placement with fbm. The effect is different, but the technique could be the same, using getTexCoords ? I have hard time grabbing ISL flow... will try harder.
Ahw beaten bad, now that's yesss !

Hey that's like a grain sampler !!! Thanks for commenting it, too !
obsolete asset

User avatar
cpfresh
Posts: 501
Joined: Thu Jun 14, 2007 12:20 pm
Location: California, USA
Contact:

Post by cpfresh » Thu Sep 25, 2008 4:08 pm

nice bowling ball!! i think that technique was pretty effective, nice work. one thing i liked about the sample that CTZn posted in his Maya example was how the grain was kind of arced from a center point. i'm not sure this is the best way to explain it but i thought it looked pretty good as opposed to having the stripes running in mostly the same direction.

User avatar
cpfresh
Posts: 501
Joined: Thu Jun 14, 2007 12:20 pm
Location: California, USA
Contact:

Post by cpfresh » Thu Sep 25, 2008 8:20 pm

heres my go at a marble shader.
Attachments
Marble.png
Marble.png (458.64 KiB) Viewed 3067 times

User avatar
CTZn
Posts: 7240
Joined: Thu Nov 16, 2006 4:34 pm
Location: Paris, France

Post by CTZn » Thu Sep 25, 2008 9:15 pm

It's very good cpfresh, code would be apreciated :) you are using a bitmap too !
obsolete asset

User avatar
WytRaven
Indigo 100
Posts: 905
Joined: Mon Aug 27, 2007 8:24 pm
Location: Dubbo, Australia
Contact:

Post by WytRaven » Thu Sep 25, 2008 10:43 pm

This shader stuff is really starting to look interesting. I will have to find the time to sit down and learn it at some point.

@cpfresh: That looks like a lot of that cross sectioned and polished rock you see people collecting...um agate or something like that?
:idea: "A foolish consistency is the hobgoblin of little minds..." - Emerson 1841

User avatar
cpfresh
Posts: 501
Joined: Thu Jun 14, 2007 12:20 pm
Location: California, USA
Contact:

Post by cpfresh » Fri Sep 26, 2008 7:22 am

hiya CTZn! i can post you the code later on. all i did was use Ono's code from above and then added a little noise -- kinda combining one of his very first shader tests (which was posted to his DA page) and this latest one. because like i said before i liked how your marble image had kind of a arced pattern as opposed to a straight line pattern in it. so it turned into another function call before (or after) the color call (i dont recall which.) also i used a different marble image (which i found on the inet) for the coloring. anyways, stay tuned.

Whyt, yea i was thinking of those rocks that have the colored stone (rock-candy like) on the inside. i think the same thing you are refering to. ... well yea on google images it looks the same. :) this would be a cool render challenge or something.

User avatar
Kram1032
Posts: 6649
Joined: Tue Jan 23, 2007 3:55 am
Location: Austria near Vienna

Post by Kram1032 » Fri Sep 26, 2008 8:00 am

Looks nice, but I'm kinda missing the details in those... marble must be very challenging...

crojack
Posts: 396
Joined: Tue Dec 04, 2007 1:48 pm
Location: Portland, Oregon
Contact:

Post by crojack » Fri Sep 26, 2008 8:35 am

now mix that with your cmu/brick pattern for marble tiles!

User avatar
CTZn
Posts: 7240
Joined: Thu Nov 16, 2006 4:34 pm
Location: Paris, France

Post by CTZn » Fri Sep 26, 2008 8:51 am

cpfresh: ok, you did right; until now I wasn't sure what arced meant, now I get it :)

I'll try to add my contribution any soon now that I can read ISL :D
obsolete asset

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

Post by OnoSendai » Fri Sep 26, 2008 12:43 pm

A grid shader, using fract(x) which is defined as x - floor(x):

Code: Select all

<shader>
						<![CDATA[
							def eval(vec3 pos) vec3 : 
								if(
									lt(
										min(
											fract(dot(vec2(10.0, 0.0), getTexCoords(0))),
											fract(dot(vec2(0.0, 10.0), getTexCoords(0)))
										),
										0.1
									),
									vec3(0.0), # Black stripe
									vec3(0.8) # White
								)
						]]>
					</shader>
Attachments
grid.jpg
grid.jpg (83.39 KiB) Viewed 2961 times

User avatar
cpfresh
Posts: 501
Joined: Thu Jun 14, 2007 12:20 pm
Location: California, USA
Contact:

Post by cpfresh » Fri Sep 26, 2008 1:22 pm

oh man that grid code is so much nicer than mine :O Ono, is fract() going to be a permanent addition to the ISL? also, i see you used min in the grid shader, how are min and max defined?

below find my code for the last bit of marble i put up, im sure there is a better way to do the little distort function i made, suggestions? the base portion of that was taken from one of Ono's very early tests.

in general i just tweaked Ono's code.

Code: Select all

    <material>
        <name>Marble</name>
        <phong>
            <layer>0</layer>
            <texture>
                <uv_set>default</uv_set>
                <path>marble_src_432.jpg</path>
                <a>0.0</a>
                <b>1.0</b>
                <c>0.0</c>
                <exponent>2.2</exponent>
            </texture>
            <diffuse_albedo>
                <shader>
                    <shader>
                        <![CDATA[
                            def distort(real y) real :
                            pow(
                                dotj(
                                    add(
                                        getTexCoords(0),
                                        vec2(
                                            noise(y)
                                        )
                                    )
                                ),
                                doti(
                                    getTexCoords(0)
                                )
                            )

                            def getColor(real x) vec3 :
                            sample2DTextureVec3(
                                0,
                                vec2(x,0.80)
                            )

                            def eval(vec3 pos) vec3 :
                            getColor(
                                distort(
                                    add(
                                        dot(
                                            pos,
                                            vec3(5.0,5.0,5.0)
                                        ),
                                        mul(
                                            fbm(
                                                mul(pos,100.0),10
                                            ),0.1
                                        )
                                    )
                                )
                            )
                        ]]>
                    </shader>
                 </shader>
            </diffuse_albedo>
            <ior>1.4</ior>
            <exponent>
                <constant>3000.0</constant>
            </exponent>
        </phong>
    </material>
i'll also attached the reference image i used for the color sampling.
Attachments
marble_src_432.jpg
the marble
marble_src_432.jpg (81.96 KiB) Viewed 2959 times
im1222330669.png
another sample
im1222330669.png (424.18 KiB) Viewed 2957 times

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

Post by OnoSendai » Fri Sep 26, 2008 1:37 pm

wow, cool render!

User avatar
cpfresh
Posts: 501
Joined: Thu Jun 14, 2007 12:20 pm
Location: California, USA
Contact:

Post by cpfresh » Fri Sep 26, 2008 1:47 pm

thanks Ono! I was just thinking to myself, "i wonder when we'll be able to use shaders on internal medium?" ... will that sort of thing be possible? like for better fog, or for some kind of partially separated liquid solution, old old window glazing ... i'm sure there are more.

User avatar
WytRaven
Indigo 100
Posts: 905
Joined: Mon Aug 27, 2007 8:24 pm
Location: Dubbo, Australia
Contact:

Post by WytRaven » Fri Sep 26, 2008 2:19 pm

"i wonder when we'll be able to use shaders on internal medium?"
*holds breath* Could this finally mean the possibility for non-uniform density volumes?? So we could actually do participating media effects like whispy ground fog or just simply non-uniform dusty air??

*stops holding breath and waits for "no"*

;)
:idea: "A foolish consistency is the hobgoblin of little minds..." - Emerson 1841

Post Reply
223 posts

Who is online

Users browsing this forum: No registered users and 1 guest