eiffie
Guest
|
|
« Reply #15 on: June 11, 2013, 06:20:30 PM » |
|
1. Since lightColor is a uniform it can't be changed so add a variable called emColor and change it in your mapL function depending on which light is closer. Then near the end of the scene() routine there is a line like: else tcol=lightColor/... change it to else tcol=emColor/... but be warned adding lights like this will have some new strange effects (maybe some good ones).
2. Yes those are some of the issues I would like to fix and to add the correct selection of diffuse or spec lighting.
|
|
|
Logged
|
|
|
|
vinz
Iterator
Posts: 154
|
|
« Reply #16 on: June 11, 2013, 07:33:38 PM » |
|
Thanks For your Help Eiffie i'm not sure how to do this:"change it in your mapL function depending on which light is closer" as you can imagine there is 90% of the script that i don't understand this is the first time that i code something hahaha ... EDIT: HAHAHAHAH,i've found something , not shure if it's correct but it works float p; p= dot(lightPosition,z); if (p>0) emColor= lightColor2; else emColor=lightColor;
|
|
« Last Edit: June 11, 2013, 08:38:25 PM by vinz, Reason: Parce que je suis un gros noob hahahaha ! »
|
Logged
|
|
|
|
eiffie
Guest
|
|
« Reply #17 on: June 11, 2013, 08:52:22 PM » |
|
Well whatever works! I meant like this: float d=length(z-lightPosition)-lightSize; float d2=min(d,length(z-lightPosition2)-lightSize2); if(d2==d)emColor=lightColor else emColor=lightColor2; Now that I look at it I guess it would make more sense to only do this once in getEmissiveDir not in mapL. And I'm glad your learning some coding - I knew there was a reason for my sketchy coding
|
|
|
Logged
|
|
|
|
vinz
Iterator
Posts: 154
|
|
« Reply #18 on: June 11, 2013, 09:04:08 PM » |
|
HA! Great Thanks Eiffie ... i'm going to do That ! I knew there was a reason for my sketchy coding Hahah, i always dream to understand how render engine works, but i've no mathematical neither programming background, with fragmentarium i found a door, to learn both ( also trying to learn ) with the speed of the gpu hahahaha ! ... the idea to render my own fractal on a render engine that i can custom is simply enormous!!!!! ... and as i love Pathtracing and Gi your "sketchy" code is a gold mine Edit : it works perfectlyThanks Eiffie vec4 getEmissiveDir( in vec3 pos) {//get the direction to a DE based light vec2 vt=vec2(mapL(pos),0.0);//find emissive light dir by triangulating its nearest point
float d=length(pos-lightPosition)-lightSize; float d2=min(d,length(pos-lightPosition2)-lightSize2); if(d2==d) emColor=lightColor; else emColor=lightColor2;
return vec4(-normalize(vec3(-mapL(pos-vt.xyy)+mapL(pos+vt.xyy), -mapL(pos-vt.yxy)+mapL(pos+vt.yxy),-mapL(pos-vt.yyx)+mapL(pos+vt.yyx))),vt.x); }
|
|
« Last Edit: June 11, 2013, 09:30:37 PM by vinz »
|
Logged
|
|
|
|
vinz
Iterator
Posts: 154
|
|
« Reply #19 on: June 12, 2013, 11:22:52 AM » |
|
Hi i'm trying to add a spherical map as sky texture, i've tried for few hours , now i've lost hope. here some code i've tryed: 1. this code seems working well in all others frags that use spherical image, as the dir variable is defined in the 3d.frag it seems i can use it. but the result a brown sky. vec2 spherical(vec3 n) { return vec2 (acos(n.z)/PI, atan(n.y,n.x)/(2.0*PI) ); }
and if(UseBackgroundPicture){ backColor = texture2D(texture,spherical(normalize(dir)).yx).xyz; }
i've also used if(UseBackgroundPicture){ backColor = texture2D(texture,spherical(normalize(rd)).yx).xyz; }
it give a better result but the background is not aligned properly. i also tryed a lot of other things and conversions functions cartesian to spherical to cartesian etc... nothing to do ! do you have any clue ? Many Thanks !!!!!!!!!!!!!!! Edit: i used the equirectangular camera in this screenshot, so i think i should have the equirectangular background if everything is fine. i should have something like that : if(UseBackgroundPicture){ vec2 position = (viewCoord+vec2(1.0))/2.0; position.y = 1.0-position.y; backColor = texture2D( texture, position).xyz; }
but this code is independent/not locked to the camera view
|
|
« Last Edit: June 12, 2013, 11:34:59 AM by vinz »
|
Logged
|
|
|
|
vinz
Iterator
Posts: 154
|
|
« Reply #20 on: June 12, 2013, 11:54:05 PM » |
|
HAHAHAHAHA! i've just found empiricaly that with using the rd variable the background needed a rotation of 90° around x axis, After a lot of search i've for the first time understood how the rotating matrix work ! Excellent so the code is now if(UseBackgroundPicture){ float theta = 1.57079633; backColor = texture2D( texture, spherical(normalize(vec3(rd.x,rd.y*cos(theta)-rd.z*sin(theta), rd.y*sin(theta)+ rd.z*cos(theta) ))).yx).xyz; }
here the result hehehe ! Pfiou that was not easy !! to me and myself
|
|
« Last Edit: June 12, 2013, 11:59:08 PM by vinz »
|
Logged
|
|
|
|
cKleinhuis
|
|
« Reply #21 on: June 13, 2013, 12:08:58 AM » |
|
have fun dude congrats!
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
vinz
Iterator
Posts: 154
|
|
« Reply #22 on: June 13, 2013, 12:13:43 AM » |
|
Hahahaha ! cKleinhuis .... don't laugh at me i never imagine that i was able to do that Thanks for supporting me in this road plenty of fractal traps
|
|
« Last Edit: June 13, 2013, 12:20:12 AM by vinz »
|
Logged
|
|
|
|
cKleinhuis
|
|
« Reply #23 on: June 13, 2013, 12:55:19 AM » |
|
i do not laugh at you, i am enjoying that you are having fun!!! actually this is exactly the feeling when i see that someone has learned something and is having fun with it!
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
vinz
Iterator
Posts: 154
|
|
« Reply #24 on: June 13, 2013, 01:04:27 AM » |
|
Hehe ! you're are seeing the little padawan with the eyes of the master Yoda i am aware of your wisdom .... edit: hahaha i'm a navigator now
|
|
« Last Edit: June 13, 2013, 01:08:52 AM by vinz »
|
Logged
|
|
|
|
|
eiffie
Guest
|
|
« Reply #26 on: June 13, 2013, 06:21:06 PM » |
|
OK vinz I updated the eiffieGI2.zip script in the other thread and now a black object will still have specular reflections. The only change is in the scene function so you should be able to plop that in your script.
|
|
|
Logged
|
|
|
|
vinz
Iterator
Posts: 154
|
|
« Reply #27 on: June 13, 2013, 06:28:26 PM » |
|
YeaHHHHHHHH !!! Thanks you very much Eiffie for taking the time to improve your Script and sharing it ... Excellent , you made my Day and i will have some new clues to understand how the script work...
|
|
|
Logged
|
|
|
|
vinz
Iterator
Posts: 154
|
|
« Reply #28 on: June 13, 2013, 06:47:28 PM » |
|
Nice image effect like in site WWW.PAULBOURKE.NET at chapter "images" and chapter "domes" where is many stereos images and effects.
Hey Hgjf2 , i dind't found what you spoke about
|
|
|
Logged
|
|
|
|
vinz
Iterator
Posts: 154
|
|
« Reply #29 on: June 13, 2013, 09:24:11 PM » |
|
Eiffie, i've just finished adding your new code , and it works very well. it was not easy as i thought, because you have modified a lot of function outside the scene one . i've found a new strange behaviour, at first i though it was my bad code. but i obtain the same result on the lastest version of the script. in fact when i switch off all the light in the scene (emissive,sky,sun etc...) and then i increase the gamma and brigthness the scene appear to be lighten! .. i'm asking to myself where does this light come from.
|
|
|
Logged
|
|
|
|
|