[REQ] Indigo instance color variation shader

Feature requests, bug reports and related discussion
User avatar
Zom-B
1st Place 100
Posts: 4700
Joined: Tue Jul 04, 2006 4:18 pm
Location: ´'`\_(ò_Ó)_/´'`
Contact:

Re: [REQ] Indigo instance color variation shader

Post by Zom-B » Tue Aug 05, 2014 7:19 am

Ok, now I got it :oops:
polygonmanufaktur.de

User avatar
zeitmeister
2nd Place 100
Posts: 2010
Joined: Tue Apr 22, 2008 4:11 am
Location: Limburg/Lahn, Germany
Contact:

Re: [REQ] Indigo instance color variation shader

Post by zeitmeister » Sat Mar 07, 2015 1:59 am

BUMP!!! :evil:

I am not a coder, and I am giving up. Really. :shock:
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

User avatar
bubs
2nd Place Winner
Posts: 620
Joined: Fri Jul 22, 2011 8:46 pm
Location: UK

Re: [REQ] Indigo instance color variation shader

Post by bubs » Sat Mar 07, 2015 2:10 am

+1
Ono did all the code for me for the brick so I'm afraid I can't help :oops:
As an archvizer I think this would prove very useful, I'd particularly love to see galinette's ideas about glass panels implemented.

User avatar
zeitmeister
2nd Place 100
Posts: 2010
Joined: Tue Apr 22, 2008 4:11 am
Location: Limburg/Lahn, Germany
Contact:

Re: [REQ] Indigo instance color variation shader

Post by zeitmeister » Sat Mar 07, 2015 3:49 am

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
Really NO IDEA what is going on here.
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

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: [REQ] Indigo instance color variation shader

Post by OnoSendai » Sat Mar 07, 2015 4:14 am

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.

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>
Attachments
objectID_texture_variation_shader.jpg

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: [REQ] Indigo instance color variation shader

Post by OnoSendai » Sat Mar 07, 2015 4:16 am

It occurs to me that a numShaderTextures() ISL function would be handy, will add that in. Won't be available for a while tho.

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: [REQ] Indigo instance color variation shader

Post by OnoSendai » Sat Mar 07, 2015 4:43 am

Colour and gamma variation shader:

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 308 times
objectID_texture_colour_variation_shader.png

User avatar
zeitmeister
2nd Place 100
Posts: 2010
Joined: Tue Apr 22, 2008 4:11 am
Location: Limburg/Lahn, Germany
Contact:

Re: [REQ] Indigo instance color variation shader

Post by zeitmeister » Sat Mar 07, 2015 5:00 am

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
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

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: [REQ] Indigo instance color variation shader

Post by OnoSendai » Sat Mar 07, 2015 5:03 am

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
what do you mean by the shader input fields?

User avatar
zeitmeister
2nd Place 100
Posts: 2010
Joined: Tue Apr 22, 2008 4:11 am
Location: Limburg/Lahn, Germany
Contact:

Re: [REQ] Indigo instance color variation shader

Post by zeitmeister » Sat Mar 07, 2015 5:29 am

Indigo GUI:
Bildschirmfoto 2015-03-06 um 18.27.46.png
C4D GUI:
Bildschirmfoto 2015-03-06 um 18.27.31.png
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

User avatar
zeitmeister
2nd Place 100
Posts: 2010
Joined: Tue Apr 22, 2008 4:11 am
Location: Limburg/Lahn, Germany
Contact:

[REQ] Indigo instance color variation shader

Post by zeitmeister » Sat Mar 07, 2015 6:19 am

Works like a charm, Ono!
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

User avatar
zeitmeister
2nd Place 100
Posts: 2010
Joined: Tue Apr 22, 2008 4:11 am
Location: Limburg/Lahn, Germany
Contact:

Re: [REQ] Indigo instance color variation shader

Post by zeitmeister » Sat Mar 07, 2015 7:53 pm

Hey Ono,
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

User avatar
zeitmeister
2nd Place 100
Posts: 2010
Joined: Tue Apr 22, 2008 4:11 am
Location: Limburg/Lahn, Germany
Contact:

Re: [REQ] Indigo instance color variation shader

Post by zeitmeister » Sun Mar 08, 2015 1:58 am

Got it! :D
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.
trees1.jpg
1 texture:
gamma variation + color variation
trees2.jpg
1 texture:
stronger gamma variation + color variation
trees3.jpg
closeup
screenshot_shader.jpg

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
trees4.jpg
2 textures:
gamma variation + color variation
leaf_color_variation.igm
(2.24 KiB) Downloaded 496 times
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

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: [REQ] Indigo instance color variation shader

Post by OnoSendai » Sun Mar 08, 2015 2:00 am

nice, looking good!

User avatar
zeitmeister
2nd Place 100
Posts: 2010
Joined: Tue Apr 22, 2008 4:11 am
Location: Limburg/Lahn, Germany
Contact:

Re: [REQ] Indigo instance color variation shader

Post by zeitmeister » Sun Mar 08, 2015 2:06 am

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?
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

Post Reply
54 posts

Who is online

Users browsing this forum: No registered users and 9 guests