Page 13 of 15

Posted: Thu Sep 25, 2008 2:19 pm
by OnoSendai
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>

Posted: Thu Sep 25, 2008 3:13 pm
by CTZn
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 !

Posted: Thu Sep 25, 2008 4:08 pm
by cpfresh
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.

Posted: Thu Sep 25, 2008 8:20 pm
by cpfresh
heres my go at a marble shader.

Posted: Thu Sep 25, 2008 9:15 pm
by CTZn
It's very good cpfresh, code would be apreciated :) you are using a bitmap too !

Posted: Thu Sep 25, 2008 10:43 pm
by WytRaven
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?

Posted: Fri Sep 26, 2008 7:22 am
by cpfresh
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.

Posted: Fri Sep 26, 2008 8:00 am
by Kram1032
Looks nice, but I'm kinda missing the details in those... marble must be very challenging...

Posted: Fri Sep 26, 2008 8:35 am
by crojack
now mix that with your cmu/brick pattern for marble tiles!

Posted: Fri Sep 26, 2008 8:51 am
by CTZn
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

Posted: Fri Sep 26, 2008 12:43 pm
by OnoSendai
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>

Posted: Fri Sep 26, 2008 1:22 pm
by cpfresh
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.

Posted: Fri Sep 26, 2008 1:37 pm
by OnoSendai
wow, cool render!

Posted: Fri Sep 26, 2008 1:47 pm
by cpfresh
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.

Posted: Fri Sep 26, 2008 2:19 pm
by WytRaven
"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"*

;)