Page 1 of 1

little help with carpaint

Posted: Mon Dec 22, 2008 10:18 pm
by carbon
hi, i am working on carpaint material and i feel discomfort with one texture i used, it is just the noise for blending, would someone of you, who can write shader language, help me? i need something like attached noise texture to be generated with some given size..

here is the material:

Code: Select all

<material>
	<name>carpaint_phong_lowexp</name>
	<phong>
		<exponent>100</exponent>
		<diffuse_albedo_spectrum>
			<rgb>
				<rgb>0.05 0.05 0.05</rgb>
				<gamma>2.2</gamma>
			</rgb>
		</diffuse_albedo_spectrum>
		<ior>1.9</ior>
	</phong>
</material>
<material>
	<name>carpaint_phong_hiexp</name>
	<phong>
		<exponent>100000</exponent>
		<diffuse_albedo_spectrum>
			<rgb>
				<rgb>0.05 0.05 0.05</rgb>
				<gamma>2.2</gamma>
			</rgb>
		</diffuse_albedo_spectrum>
		<ior>2.4</ior>
	</phong>
</material>
<material>
	<name>carpaint_mix1</name>
	<blend>
		<a_name>carpaint_phong_lowexp</a_name>
		<b_name>carpaint_phong_hiexp</b_name>
		<blend_factor>0.5</blend_factor>
	</blend>
</material>
<material>
	<name>carpaint_phong_midexp</name>
	<phong>
		<exponent>2500</exponent>
		<diffuse_albedo_spectrum>
			<rgb>
				<rgb>0.05 0.05 0.05</rgb>
				<gamma>2.2</gamma>
			</rgb>
		</diffuse_albedo_spectrum>
		<ior>1.4</ior>
	</phong>
</material>
<material>
	<name>carpaint_mix2</name>
	<blend>
		<a_name>carpaint_mix1</a_name>
		<b_name>carpaint_phong_midexp</b_name>
		<blend_factor>0.5</blend_factor>
	</blend>
</material>
<material>
	<name>carpaint_metalic_lowexp</name>
	<phong>
		<exponent>50</exponent>
		<nk_data>nkdata\fesi2el2.nk</nk_data>
	</phong>
</material>
<material>
	<name>carpaint_mix3</name>
	<blend>
		<a_name>carpaint_mix2</a_name>
		<b_name>carpaint_metalic_lowexp</b_name>
		<blend_factor>0.07</blend_factor>
	</blend>
</material>
<material>
	<name>carpaint_metalic_hiexp</name>
	<phong>
		<exponent>300</exponent>
		<nk_data>nkdata\Cu.nk</nk_data>
	</phong>
</material>

<material>
	<!--name>carpaint</name-->
	<name>previewmaterial</name>
	<blend>
		<a_name>carpaint_mix3</a_name>
		<b_name>carpaint_metalic_hiexp</b_name>
		<blend_factor>0.07</blend_factor>
	</blend>
	<blend>
		<texture>
			<uv_set>default</uv_set>
			<path>tex/carpaint_noise_blend-preview.jpg</path>
			<exponent>2.2</exponent>
		</texture>
	</blend>
</material>
thanks
c.

Posted: Mon Dec 22, 2008 11:07 pm
by PureSpider
Whats wrong with that texture? =/

Posted: Mon Dec 22, 2008 11:12 pm
by carbon
nothing generally, but i like to have same noise size on all models, independent on model/uv/image size

Posted: Mon Dec 22, 2008 11:17 pm
by PureSpider
carbon wrote:...independent on model/uv/image size
Either one of these is not possible
Model, but not UV or image = world mapping
UV, but not model or image = uv mapping
Image, but not UV or model = not possible, also depends on UV mapping
;)
But anyway, I think a simple noise func will do, find it in the shader test thread.

Posted: Mon Dec 22, 2008 11:18 pm
by fused
erm... what exporter do you use? previewmaterial isnt even using the texture. the syntax is wrong...

wrong:

Code: Select all

<material>
   <!--name>carpaint</name-->
   <name>previewmaterial</name>
   <blend>
      <a_name>carpaint_mix3</a_name>
      <b_name>carpaint_metalic_hiexp</b_name>
      <blend_factor>0.07</blend_factor>
   </blend>
   <blend>
      <texture>
         <uv_set>default</uv_set>
         <path>tex/carpaint_noise_blend-preview.jpg</path>
         <exponent>2.2</exponent>
      </texture>
   </blend>
</material>
right:

Code: Select all

<material>
   <!--name>carpaint</name-->
   <name>previewmaterial</name>
   <blend>
      <texture>
         <uv_set>default</uv_set>
         <path>tex/carpaint_noise_blend-preview.jpg</path>
         <exponent>2.2</exponent>
      </texture>
      <a_name>carpaint_mix3</a_name>
      <b_name>carpaint_metalic_hiexp</b_name>
      <blend>
          <texture><texture_index>0</texture_index></texture>
      </blend>
   </blend>
</material>
for all mats using blend_factor it should be:

Code: Select all

      <blend>
          <constant>0.5</constant>
      </blend>
inatead of blend_factor

Posted: Tue Dec 23, 2008 12:41 am
by carbon
ops :oops: no exporter, it is handcoded, i was thinking i am dong something wrong :) that's happening when i copypaste too much
anyway i am still interested in turning texture into shader..

Posted: Tue Dec 23, 2008 1:34 am
by fused
ill post something soon :)

Posted: Sun Jan 11, 2009 4:19 am
by carbon
fused?? :roll:

Posted: Sun Jan 11, 2009 4:33 am
by fused
oh ^^

gotta go now, ill post a bit of code when i come back.

Posted: Sun Jan 11, 2009 7:04 am
by fused

Code: Select all

<shader>
  <shader>
    <![CDATA[          
      # checkerboard

      def eval(vec3 pos) vec3 :
        vec3(mul(noise(mul(pos,
        #SCALE
        5000.0)),
        #BRIGHTNESS
        0.5))
    ]]>
  </shader>
</shader>
modify scale and brightness to tweak the result as you like :)

Posted: Sun Jan 11, 2009 8:20 am
by carbon
thanks a lot!