Re: [REQ] Indigo instance color variation shader
Posted: Tue Aug 05, 2014 7:19 am
Ok, now I got it
https://indigorenderer.com/forum/
Code: Select all
def eval(vec3 pos) vec3 :
let
r = real(objectId())
base_col = vec3(0.6, 0.4, 0.4)
# Get UV coords
uv = getTexCoords(0)
# Pick a random texture index
NUM_TEXTURES = 3
# tex_index = floorToInt(gridNoise(vec2(x(uv) + 100000.0, y(uv) + 1000000.0)) * real(NUM_TEXTURES))
tex_index = floorToInt(noise(vec2(x(uv), y(uv))) * real(NUM_TEXTURES))
random_scale = 2
in
sample2DTextureVec3(tex_index, uv) * random_scale
#base_col + vec3(
#fract(r * 45.345),
#fract(r * 4.57),
#fract(r * 908.3)
#) * random_scale
Code: Select all
<material>
<uid>4</uid>
<name>ball</name>
<phong>
<diffuse_albedo>
<shader>
<shader>
<![CDATA[
def eval(vec3 pos) vec3 :
let
NUM_TEXTURES = 3
tex_index = floorToInt(gridNoise(real(objectId())) * NUM_TEXTURES)
in
sample2DTextureVec3(tex_index, getTexCoords(0))
]]></shader>
<texture>
<uv_set_index>0</uv_set_index>
<path>indigo_logo.png</path>
<exponent>2.2</exponent>
</texture>
<texture>
<uv_set_index>0</uv_set_index>
<path>tester.png</path>
<exponent>2.2</exponent>
</texture>
<texture>
<uv_set_index>0</uv_set_index>
<path>blackrose_pattern.jpg</path>
<exponent>2.2</exponent>
</texture>
</shader>
</diffuse_albedo>
<exponent>
<constant>100</constant>
</exponent>
<layer>0</layer>
<ior>1.2</ior>
<nk_data></nk_data>
</phong>
</material>
Code: Select all
<material>
<uid>4</uid>
<name>ball</name>
<phong>
<diffuse_albedo>
<shader>
<shader>
<![CDATA[
def eval(vec3 pos) vec3 :
let
c = sample2DTextureVec3(0, getTexCoords(0))
id = real(objectId())
gamma_var = paramGammaRandomAmount()
shift_gamma = max(0.0, (1 - gamma_var) + gridNoise(id) * gamma_var * 2.0)
colour_var = paramColorVariationAmount()
colour_shift = (vec3(-0.5) + vec3(gridNoise(id), gridNoise(id + 34534), gridNoise(id + 9876465))) * (colour_var * 2.0)
in
vec3(pow(c.x, shift_gamma), pow(c.y, shift_gamma), pow(c.z, shift_gamma)) + colour_shift
]]></shader>
<param>
<real>
<name>GammaRandomAmount</name>
<description>Amount of variation of texture gamma</description>
<min>0</min>
<max>2.0</max>
<value>0.3</value>
</real>
</param>
<param>
<real>
<name>ColorVariationAmount</name>
<description>Amount of colour variation of texture</description>
<min>0</min>
<max>0.5</max>
<value>0.04</value>
</real>
</param>
<texture>
<uv_set_index>0</uv_set_index>
<path>ColorChecker_sRGB_from_Ref_CMYK.jpg</path>
<exponent>2.2</exponent>
</texture>
</shader>
</diffuse_albedo>
<exponent>
<constant>100</constant>
</exponent>
<layer>0</layer>
<ior>1.2</ior>
<nk_data></nk_data>
</phong>
</material>
what do you mean by the shader input fields?zeitmeister wrote:Wow Ono, thank you very much!!
Do you think it would be possible to Access the Shader Input fields 1:1 in the plugin exporters? That would save a lot of time.
Cheers, zeiti
Code: Select all
def eval(vec3 pos) vec3 :
let
NUM_TEXTURES = 2
tex_index = floorToInt(gridNoise(real(objectId())) * NUM_TEXTURES)
c = sample2DTextureVec3(tex_index, getTexCoords(0))
id = real(objectId())
gamma_var = paramGammaRandomAmount()
shift_gamma = max(0.0, (1 - gamma_var) + gridNoise(id) * gamma_var * 2.0)
colour_var = paramColorVariationAmount()
colour_shift = (vec3(-0.5) + vec3(gridNoise(id), gridNoise(id + 34534), gridNoise(id + 9876465))) * (colour_var * 2.0)
in
vec3(pow(c.x, shift_gamma), pow(c.y, shift_gamma), pow(c.z, shift_gamma)) + colour_shift