
[REQ] Indigo instance color variation shader
- zeitmeister
- Posts: 2010
- Joined: Tue Apr 22, 2008 4:11 am
- Location: Limburg/Lahn, Germany
- Contact:
Re: [REQ] Indigo instance color variation shader
BUMP!!!
I am not a coder, and I am giving up. Really.
Guys, I need a shader similar to the brick shader. Only for instances.
Variant A:
I provide the shader a number of textures. Each instance (-ID) gets a random texture from the pool.
Variant B:
I provide only one texture to the shader. Each instance gets a slightly gamma- and color shift RANDOMLY by instance-ID.
A shaded parameter should be the gamma shift range and the color shift range.
Could this be soooooooooooo difficult?
I even don't find in ANY ISL documentary how to implement a texture variable into ISL. And if I need vec3 for what I want or not.
Please help me and us for building an easy-to-use Instance Color Variation Shader!!!
Thank you in advance!

I am not a coder, and I am giving up. Really.

Guys, I need a shader similar to the brick shader. Only for instances.
Variant A:
I provide the shader a number of textures. Each instance (-ID) gets a random texture from the pool.
Variant B:
I provide only one texture to the shader. Each instance gets a slightly gamma- and color shift RANDOMLY by instance-ID.
A shaded parameter should be the gamma shift range and the color shift range.
Could this be soooooooooooo difficult?
I even don't find in ANY ISL documentary how to implement a texture variable into ISL. And if I need vec3 for what I want or not.
Please help me and us for building an easy-to-use Instance Color Variation Shader!!!
Thank you in advance!
Cheers, David
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
Re: [REQ] Indigo instance color variation shader
+1
Ono did all the code for me for the brick so I'm afraid I can't help
As an archvizer I think this would prove very useful, I'd particularly love to see galinette's ideas about glass panels implemented.
Ono did all the code for me for the brick so I'm afraid I can't help

As an archvizer I think this would prove very useful, I'd particularly love to see galinette's ideas about glass panels implemented.
- zeitmeister
- Posts: 2010
- Joined: Tue Apr 22, 2008 4:11 am
- Location: Limburg/Lahn, Germany
- Contact:
Re: [REQ] Indigo instance color variation shader
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
Regarding the tex_index I can't simply output a random value of the read NUM_TEXTURE... no chance. Tried everything.
Plus, the "sample2DTextureVec3()" doesn't accept FRACT-modifiers as above at the very end... I am so helpless...
Cheers, David
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
Re: [REQ] Indigo instance color variation shader
Ok, for variant A (random texture per instance) the code looks like this:
NUM_TEXTURES needs to be set to the number of textures in the shader.
NUM_TEXTURES needs to be set to the number of textures in the shader.
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>
Re: [REQ] Indigo instance color variation shader
It occurs to me that a numShaderTextures() ISL function would be handy, will add that in. Won't be available for a while tho.
Re: [REQ] Indigo instance color variation shader
Colour and gamma variation shader:
PIGS attached to play with.
PIGS attached to play with.
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>
- Attachments
-
- objectID_texture_colour_variation_shader.pigs
- (703.67 KiB) Downloaded 413 times
- zeitmeister
- Posts: 2010
- Joined: Tue Apr 22, 2008 4:11 am
- Location: Limburg/Lahn, Germany
- Contact:
Re: [REQ] Indigo instance color variation shader
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
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
Cheers, David
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
Re: [REQ] Indigo instance color variation shader
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
- zeitmeister
- Posts: 2010
- Joined: Tue Apr 22, 2008 4:11 am
- Location: Limburg/Lahn, Germany
- Contact:
Re: [REQ] Indigo instance color variation shader
Indigo GUI:
C4D GUI:
Cheers, David
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
- zeitmeister
- Posts: 2010
- Joined: Tue Apr 22, 2008 4:11 am
- Location: Limburg/Lahn, Germany
- Contact:
[REQ] Indigo instance color variation shader
Works like a charm, Ono!
Got to find out how to setup the Code for c4d...
Got to find out how to setup the Code for c4d...
Cheers, David
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
- zeitmeister
- Posts: 2010
- Joined: Tue Apr 22, 2008 4:11 am
- Location: Limburg/Lahn, Germany
- Contact:
Re: [REQ] Indigo instance color variation shader
Hey Ono,
would a combination work?
I managed to link color variation with your multiple texture setup, but I fail at the gamma_shift...
would a combination work?
I managed to link color variation with your multiple texture setup, but I fail at the gamma_shift...
Cheers, David
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
- zeitmeister
- Posts: 2010
- Joined: Tue Apr 22, 2008 4:11 am
- Location: Limburg/Lahn, Germany
- Contact:
Re: [REQ] Indigo instance color variation shader
Got it! 
First three images ONLY ONE color texture. There are 8 different trees with 8 different alpha leaf blend materials; all accessing the main color changer material.
So this way I got to change/apply/setup the color variation shader ONE TIME, but get 8 different alpha leaf materials out of it.
Last picture using ONLY TWO textures, but color and gamma variation applied.

First three images ONLY ONE color texture. There are 8 different trees with 8 different alpha leaf blend materials; all accessing the main color changer material.
So this way I got to change/apply/setup the color variation shader ONE TIME, but get 8 different alpha leaf materials out of it.
Last picture using ONLY TWO textures, but color and gamma variation applied.
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
Last edited by zeitmeister on Sun Mar 08, 2015 2:02 am, edited 1 time in total.
Cheers, David
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
Re: [REQ] Indigo instance color variation shader
nice, looking good!
- zeitmeister
- Posts: 2010
- Joined: Tue Apr 22, 2008 4:11 am
- Location: Limburg/Lahn, Germany
- Contact:
Re: [REQ] Indigo instance color variation shader
Thank you a lot!
The only knickknack is the fact that setting up the shader is not possible in the C4D exporter.
fused may have to invest work here, so that the C4D Indigo shader window offers the same possibilities as the Indigo standalone GUI shader window. Plus working and exporting things correctly.
BTW: Ono, does that shader "flicker" or sample everything new when rendering an animation?
And if yes, how can we interdict that?
The only knickknack is the fact that setting up the shader is not possible in the C4D exporter.
fused may have to invest work here, so that the C4D Indigo shader window offers the same possibilities as the Indigo standalone GUI shader window. Plus working and exporting things correctly.
BTW: Ono, does that shader "flicker" or sample everything new when rendering an animation?
And if yes, how can we interdict that?
Cheers, David
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.4.15 | Indigo for C4D 4.4.13.1 | C4D R23 | Mac OS X 10.13.6 | Windows 10 Professional x64
Who is online
Users browsing this forum: No registered users and 10 guests