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>