need help with Cinema4D fresnel

Announcements, requests and support regarding the Cinema 4D exporter
User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: need help with Cinema4D fresnel

Post by OnoSendai » Thu Apr 11, 2013 2:00 am

Code: Select all

	<material>
		<name>mat1</name>
		
		<diffuse>
			<texture>
				<path>blackrose_pattern.jpg</path>
				<uv_set>default</uv_set>
				<exponent>2.2</exponent>
			</texture>
			
			<texture>
				<path>../italy_bolsena_flag_flowers_stairs_01.jpg</path>
				<uv_set>default</uv_set>
				<exponent>2.2</exponent>
			</texture>
			
			<albedo>
				<shader>
					<shader>
						<![CDATA[     
def eval(vec3 pos) vec3 :
  let 
    uv = getTexCoords(0)
  in
    lerp(
      sample2DTextureVec3(0, uv),
      sample2DTextureVec3(1, uv),
      minCosTheta()
    )
						]]>
					</shader>
				</shader>
			</albedo>
			<random_triangle_colours>false</random_triangle_colours>
			<layer>0</layer>
		</diffuse>
	</material>

User avatar
N.G.
Posts: 36
Joined: Tue Dec 18, 2012 1:31 am
Location: Russia

Re: need help with Cinema4D fresnel

Post by N.G. » Thu Apr 11, 2013 2:13 am

what did I do wrong?

<material>
<name>mat1</name>

<diffuse>
<texture>
<path>L:\Indigo\tex\14_5_17_d.jpg</path>
<uv_set>default</uv_set>
<exponent>2.2</exponent>
</texture>

<texture>
<path>L:\Indigo\tex\14_5_15_b.jpg</path>
<uv_set>default</uv_set>
<exponent>2.2</exponent>
</texture>

<albedo>
<shader>
<shader>
<![CDATA[
def eval(vec3 pos) vec3 :
let
uv = getTexCoords(0)
in
lerp(
sample2DTextureVec3(0, uv),
sample2DTextureVec3(1, uv),
minCosTheta()
)
]]>
</shader>
</shader>
</albedo>
<random_triangle_colours>false</random_triangle_colours>
<layer>0</layer>
</diffuse>
</material>
Attachments
Снимок111.jpg
error

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

Re: need help with Cinema4D fresnel

Post by Zom-B » Thu Apr 11, 2013 2:32 am

N.G. wrote:what did I do wrong?
You've put IGS code into the ISL Editor :)


Only put that code into the editor:

Code: Select all

def eval(vec3 pos) vec3 :
  let
    uv = getTexCoords(0)
  in
    lerp(
      sample2DTextureVec3(0, uv),
      sample2DTextureVec3(1, uv),
      minCosTheta()
    )
Now define two textures in the first both fields above the Code window.


The Problem about minCosTheta Ono is that the result isn't fresnel but something else...
Attachments
screenshot.13.png
Indigo minCosTheta()
screenshot.12.png
C4D fresnel
polygonmanufaktur.de

User avatar
N.G.
Posts: 36
Joined: Tue Dec 18, 2012 1:31 am
Location: Russia

Re: need help with Cinema4D fresnel

Post by N.G. » Thu Apr 11, 2013 2:44 am

honestly, I realized that nothing I do not understand anything. I need an example. Please give me your shader. :roll:

when I see program code-brain off. :lol:

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

Re: need help with Cinema4D fresnel

Post by Zom-B » Thu Apr 11, 2013 2:48 am

Here you go:
Attachments
screenshot.14.png
polygonmanufaktur.de

User avatar
N.G.
Posts: 36
Joined: Tue Dec 18, 2012 1:31 am
Location: Russia

Re: need help with Cinema4D fresnel

Post by N.G. » Thu Apr 11, 2013 2:55 am

Zom-B wrote:Here you go:
I love you! :lol:

it works!

User avatar
N.G.
Posts: 36
Joined: Tue Dec 18, 2012 1:31 am
Location: Russia

Re: need help with Cinema4D fresnel

Post by N.G. » Thu Apr 11, 2013 3:07 am

YES.

minCosTheta Ono is that the result isn't fresnel but something else...

User avatar
fused
Developer
Posts: 3648
Joined: Fri Sep 22, 2006 7:19 am
Location: Berlin, Germany
3D Software: Cinema 4D

Re: need help with Cinema4D fresnel

Post by fused » Thu Apr 11, 2013 3:08 am

While it looks like it will just work like that, as soon as you add any other texture to that material, it will break.

Unfortunately, due to the way Indigo's material system works, referenceing textures in ISL shaders is a bit tricky (referencing is actually easy, maintaining the reference after changes to materials is where it gets annoying).

In Cindigo, you can work around that by using the placeholders specified in the label of the texture file selector ($tex01$, $tex02$, $tex03$).
It's lame, but works.

These placeholders will be replaced with the id the texture actually has on rendering.

your ISL code should look like this:

Code: Select all

def eval(vec3 pos) vec3 :
  let 
    uv = getTexCoords(0)
  in
    lerp(
      sample2DTextureVec3($tex01$, uv),
      sample2DTextureVec3($tex02$, uv),
      minCosTheta()
    )

User avatar
galinette
1st Place Winner
Posts: 923
Joined: Sat Jan 09, 2010 1:39 am
Location: Nantes, France
Contact:

Re: need help with Cinema4D fresnel

Post by galinette » Thu Apr 11, 2013 3:28 am

N.G. wrote:YES.

minCosTheta Ono is that the result isn't fresnel but something else...
For fresnel, as told before, you can try:

1.0 - pow(1.0 - (2.0/(1.0/maxCosTheta() + 1.0/minCosTheta())), 5.0)

or

1.0 - pow(1.0 - (0.5*(maxCosTheta() + minCosTheta()), 5.0)


However, none is 100% identical to the one used in most softwares, which use the cosineTheta of the halfway vector, which is not available in Indigo (subliminal message to Ono ;) )

If this was available, you would use :
1.0 - pow(1.0 - cosThetaHalfway(), 5.0)
Eclat-Digital Research
http://www.eclat-digital.com

User avatar
N.G.
Posts: 36
Joined: Tue Dec 18, 2012 1:31 am
Location: Russia

Re: need help with Cinema4D fresnel

Post by N.G. » Thu Apr 11, 2013 3:34 am

Why should I to score a head program codes? need to make everything easier!!
THANK YOU ALL! :D

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

Re: need help with Cinema4D fresnel

Post by OnoSendai » Thu Apr 11, 2013 3:36 am

galinette wrote:
However, none is 100% identical to the one used in most softwares, which use the cosineTheta of the halfway vector, which is not available in Indigo (subliminal message to Ono ;) )
Good idea :)

User avatar
wlf_alex
Posts: 99
Joined: Tue Aug 28, 2012 9:26 pm
Location: Russia-Moscow, Spain-Alicante
Contact:

Re: need help with Cinema4D fresnel

Post by wlf_alex » Thu Apr 11, 2013 3:46 am

Thank you guys! You are Superman!
ArchiCAD 14, Cinema 4D r13, IndigoRender, VrayforC4D

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

Re: need help with Cinema4D fresnel

Post by Zom-B » Thu Apr 11, 2013 4:02 am

Thanks for the code galinette, its better then pure minCosTheta().

I attached example of fresnel vs ISL
galinette wrote:1.0 - pow(1.0 - (2.0/(1.0/maxCosTheta() + 1.0/minCosTheta())), 5.0)

or

1.0 - pow(1.0 - (0.5*(maxCosTheta() + minCosTheta()), 5.0)
The bottom example misses a ) ;)
N.G. wrote:Why should I to score a head program codes? need to make everything easier!!
THANK YOU ALL! :D
Its NOT about coding at all here, JUST the knowledge what values to EDIT!!
I also don't understand ISL code at all!!!!

here is the code I used for the example, the bold number is the strength of fresnel, value of 1,75 seems to be a good start.
def eval(vec3 pos) vec3 :
let
uv = getTexCoords(0)
in
lerp(
sample2DTextureVec3(0, uv),
sample2DTextureVec3(1, uv),
1.0 - pow(1.0 - (0.5*(maxCosTheta() + minCosTheta())), 1.75)
)
I attached also a example with value of 3 just to show you the result.
OnoSendai wrote:
galinette wrote:However, none is 100% identical to the one used in most softwares, which use the cosineTheta of the halfway vector, which is not available in Indigo (subliminal message to Ono ;) )
Good idea :)
Would be sweeeeeet!!! :D
Attachments
screenshot.16.png
Indigo with value o0f 1.75
screenshot.18.png
Indigo with value of 3.0
screenshot.17.png
C4D fresnel
polygonmanufaktur.de

User avatar
wlf_alex
Posts: 99
Joined: Tue Aug 28, 2012 9:26 pm
Location: Russia-Moscow, Spain-Alicante
Contact:

Re: need help with Cinema4D fresnel

Post by wlf_alex » Thu Apr 11, 2013 4:31 am

Thanks a lot Zom-B !!!
ArchiCAD 14, Cinema 4D r13, IndigoRender, VrayforC4D

User avatar
galinette
1st Place Winner
Posts: 923
Joined: Sat Jan 09, 2010 1:39 am
Location: Nantes, France
Contact:

Re: need help with Cinema4D fresnel

Post by galinette » Thu Apr 11, 2013 4:37 am

Zom-B : which refractive index are you using in the C4D shader?

Etienne
Eclat-Digital Research
http://www.eclat-digital.com

Post Reply
34 posts

Who is online

Users browsing this forum: No registered users and 96 guests