Daily Archives

Articles indexed Wednesday August 20 2014

Page 12/19 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Which parallel pattern to use?

    - by Wim Van Houts
    I need to write a server application that fetches mails from different mail servers/mailboxes and then needs to process/analyze these mails. Traditionally, I would do this multi-threaded, launching a thread for fetching mails (or maybe one per mailbox) and then process the mails. We are moving more and more to servers where we have 8+ cores, so I would like to make use of these cores as much as possible (and not use 1 at 100% and leave the seven others untouched). So conceptually, as an example, it would be nice that I could write the application in such a way that two cores are "continuously" fetching emails and four cores are "continuously" processing/analyzing the emails (since processing and analyzing mails is more CPU intensive than fetching mails). This seems like a good concept, but after studying some parallel patterns, I'm not really sure how this is best implemented. None of the patterns really fit. I'm working in VS2012, native C++, but I guess from a design point of view this does not really matter and just some pointers on how to organize this would be great!

    Read the article

  • What are the pros and cons of Coffeescript?

    - by Philip
    Of course one big pro is the amount of syntactic sugar leading to shorter code in a lot of cases. On http://jashkenas.github.com/coffee-script/ there are impressive examples. On the other hand I have doubts that these examples represent code of complex real world applications. In my code for instance I never add functions to bare objects but rather to their prototypes. Moreover the prototype feature is hidden from the user, suggesting classical OOP rather than idiomatic Javascript. The array comprehension example would look in my code probably like this: cubes = $.map(list, math.cube); // which is 8 characters less using jQuery...

    Read the article

  • Ubuntu 12.04 PXELINUX does not boot RHEL Kernel and Initrd

    - by utpal
    I have successfully setup PXE server on Ubuntu 12.04 with DNSMASQ for DHCP Proxy Service, TFTPD-HPA for TFTP service, NFS-KERNEL-SERVER, APACHE2 and SYSLINUX for pxelinux.0 bootloaded needed for pxe boot using the following POST: http://ubuntuforums.org/showthread.php?t=1606910 I was successfully able to pxe boot a client to a Ubuntu 12.04 LIVE CD. Next, I want to PXE boot a client to a RHEL 6.5 x64 Kernel and initrd image. I dont want to install, just boot a client so that it mounts initrd and I can get a minimal filesystem on the client. How can I do that? Please Help!!

    Read the article

  • Using "MTNL 3G Jadoo" data card on Ubuntu

    - by amolbk
    I am trying to use "MTNL 3G Jadoo" data card (Teracom LW272) with Ubuntu 12.04. On connecting, it gets mounted as a drive containing the client installation .deb file. I opened the .deb file in Ubuntu Software Center and installed it. I searched for "MTNL" in Ubuntu search and found "MTNL 3G Modem" application. But it won't run. I found it is installed in /opt/MTNL-3GModem. I tried running it from the terminal as: sudo /opt/MTNL-3GModem/ModemClient, but no luck. Any idea how to get it working?

    Read the article

  • How can I run Tellme more software on Ubuntu 14.04 LTS?

    - by Alex Walker
    I'm new to Ubuntu and I've been loving it so far, I have it on my 2 computers and I think everyone should try it. I run an English Laboratory in a University (Our PC's are old and slow) so I want to install Ubuntu on all of them so the students can have a better experience here, the problem is tha we NEED Tell me more Software which I believe it's only for windiws. How can I install it in ubuntu? do I need wine or a virtual machine with Windows? please help! and thank you so much!!

    Read the article

  • Why is my LAN not working properly ?

    - by ps06756
    I am using Ubuntu 12.04 as my OS. Till yesterday, my LAN was working fine , but after that my LAN is not working properly. What I mean is that it shows that the LAN wire is connected properly, but when I try to open a website it gets stuck on resolving host. I am using the web browser as Google-chrome. Now, when I manually switch off the wired connection and turn it on again, the LAN works perfectly till I open one or two webpages. After that the same problem repeats again. Can anybody, help me with a solution to this problem.

    Read the article

  • Why doesn't lsof show localhost TCP connections in 14.04?

    - by sfussenegger
    I have two servers running 12.04.4 and 14.04.1 respectively. Both have nginx (port 80) and a Java process (port 8080). As expected, the lsof output for the Java process on the 12.04 machine shows a couple of established connections for port 8080 (e.g. TCP 127.0.0.1:8080->127.0.0.1:58067 (ESTABLISHED)) The 14.04 machine however does not. It only shows the listening port (TCP *:8080 (LISTEN)). I'm sure there are active connections though (confirmed by access logs, Java process status output, etc). What has changed from 12.04 to result in this behavior? Can this change be the cause for the "Too many open files" errors I'm getting since moving from 12.04 to 14.04? 12.04: $ dpkg -l lsof linux-image-virtual openjdk-7-jre nginx ||/ Name Version +++-===========================================-=========================================== ii linux-image-virtual 3.2.0.59.70 ii lsof 4.81.dfsg.1-1build1 ii nginx 1.6.1-1~precise ii openjdk-7-jre 7u65-2.5.1-4ubuntu1~0.12.04.1 14.04: $ dpkg -l lsof linux-image-virtual openjdk-7-jre nginx-full ||/ Name Version Architecture Description +++-=====================================-=======================-======================= ii linux-image-virtual 3.13.0.32.38 amd64 ii lsof 4.86+dfsg-1ubuntu2 amd64 ii nginx-full 1.4.6-1ubuntu3 amd64 ii openjdk-7-jre:amd64 7u65-2.5.1-4ubuntu1~0.1 amd64

    Read the article

  • How can I remove a Unity window entry?

    - by Pol Delgado Martin
    I installed Eclipse long time ago from the Software Center, but recently I needed a newer version than the repo one. Then I removed it via Software Center and installed Eclipse Kepler in /opt. However, the window opened is not called Eclipse, it is the name of an old program I made (Eclipse- GMM). However, that's not the main issue, but that even if I created a .desktop file it launches the same, having "two" eclipses in the dock, the actual program and the launcher. How can I remove Unity .desktop cache or wathever it is this?

    Read the article

  • help configuring my samba file server

    - by user281745
    Hello everyone I have installed all the files I needed for my samba file server. I have also installed the gadmin-samba 0.3.2. I am trying to set a user-name and password also I would like to know how to ad my laptops I own to the machines allowed to connect to it. it can be in terminal but preferably in gadmin-samba which is like a GUI. please be very descriptive my systems is Ubuntu 14.04 and Gadmin-Samba 0.3.2

    Read the article

  • Standby Problem, PC can not enter Standby mode

    - by Leon95
    I have a problem with the Standby function: My Computer does not enter the Standby mode with Ubuntu 14.04LTS. If I remeber me right it, works with Ubuntu 13.10 but this Version was not long installed on this PC. Now when i press Standby in the menu or on my Keyboard the Display turns black for a few seconds, then some messages appear for a very short moment on the screen. After that, the the log-in screen appear. Two times I was able to enter Standby but the other times it fails. Tecnical Data about my PC: Ubuntu 14.04 with all Updates main storage: 3,8GiBprocessor: Intel® Core™ i3-2330M CPU @ 2.20GHz × 4 graphic: Intel® Sandybridge Mobile graphic board: NVIDA GEFORCE GT 555M CUDA 1GB Dual Boot System with win7 x64Bit Medion P6812 Laptop Here is the message output: Usally I got only a half of the screen filled with messages like that. When I filmed it it was much more. I dont know, maybe this is a Bug.

    Read the article

  • No Windows Option on Boot

    - by Okoning
    I've installed Ubuntu alongside Windows but at first didn't have a boot option menu. So, I installed bootrepair and ran it. This succeeded in granting me a GRUB boot option menu, but Windows isn't on it. Here is the bootrepair report: http://paste.ubuntu.com/8098527 Can anyone tell me what might be wrong? EDIT: I ran sudo fdisk -l and this is the output: Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00023fe0 Device Boot Start End Blocks Id System /dev/sda1 * 2048 960096255 480047104 83 Linux /dev/sda2 960098302 976771071 8336385 5 Extended /dev/sda5 960098304 976771071 8336384 82 Linux swap / Solaris Disk /dev/sdb: 32.0 GB, 32015679488 bytes 255 heads, 63 sectors/track, 3892 cylinders, total 62530624 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdb1 * 32 62530623 31265296 c W95 FAT32 (LBA)

    Read the article

  • Google Chrome proxy settings?

    - by becko
    When I try to set Google Chrome's proxy settings (on chrome://linux-proxy-config/), I get the following message: When running Google Chrome under a supported desktop environment, the system proxy settings will be used. However, either your system is not supported or there was a problem launching your system configuration. But you can still configure via the command line. Please see man google-chrome-stable for more information on flags and environment variables. I need to set proxy settings to use Chrome, but I don't want to be setting them in the command line every time I use Chrome. Is there a way to set these settings permanently? Also, is there an option in Chrome so that it doesn't use proxy for specific domains (analogous to the No proxy for setting in Firefox)?

    Read the article

  • Completely unable to install python2.7-dev

    - by gath
    Am totally stuck! Am unable completely to install python2.7-dev on my Ubuntu13.04. I have tried all the tricks mentioned on this site (askubuntu.com) and many other sites on the web but still nothing! Am running Ubuntu 13.04 64bit on a virtualbox, but every time I run sudo apt-get install python2.7-dev, I get the following error; python2.7-dev : Depends: python2.7 (= 2.7.3-0ubuntu3.5) but 2.7.4-2ubuntu3 is to be installed Depends: libpython2.7 (= 2.7.3-0ubuntu3.5) but 2.7.4-2ubuntu3 is to be installed Depends: libexpat1-dev but it is not going to be installed Depends: libssl-dev but it is not going to be installed E: Unable to correct problems, you have held broken packages. I've tried to do apt-get update, but still nothing! I've even tried installing Python2.7 from sources, but still nothing doing! Is there a single package with all the dependencies I can download, that can just install everything (Python2.7-dev) or is there another trick I can use to get the Python-dev headers installed on my machine. Hint: I've noticed when I run sudo apt-get update , somewhere along the updates I've seen some errors; ... Get:1 http://us.archive.ubuntu.com precise-updates Release.gpg [198 B] Ign http://us.archive.ubuntu.com raring Release Ign http://us.archive.ubuntu.com raring-updates Release Ign http://us.archive.ubuntu.com raring-backports Release Ign http://us.archive.ubuntu.com raring-security Release Get:2 http://us.archive.ubuntu.com precise-updates Release [98.7 kB] Err http://extras.ubuntu.com raring/main Sources 404 Not Found Err http://extras.ubuntu.com raring/main amd64 Packages 404 Not Found Err http://extras.ubuntu.com raring/main i386 Packages 404 Not Found Ign http://extras.ubuntu.com raring/main Translation-en_US Ign http://extras.ubuntu.com raring/main Translation-en ... On my precise-updates.list file is a single entry; deb http://us.archive.ubuntu.com/ubuntu/ precise-updates main restricted I don't know if that might help Help! Paul

    Read the article

  • OpenSSL installed, but Ruby unable to require it

    - by uomoinverde
    I'm trying to setup github-pages on my Ubuntu laptop, and following the guide provided by Github I have to install the bundler package; giving the command ~$ gem install bundler returns me this error. ERROR: While executing gem ... (Gem::Exception) Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources Then I have installed OpenSSL, launched the command to update software and stuff and tried again to install bundler, but the error kept showing. How can I fix this? Is there any specific command to rebuild ruby making it aware about the fact that openSSL is now installed?

    Read the article

  • Creating an install drive - can not open output file autorun.inf

    - by user226881
    I am trying to make an install/boot drive for a computer that has no operating system and no optical drive. I used the ISO from Ubuntu.com and the burner from pendrivelinux.com. When the program starts writing to the flash drive, there is an error displayed that says : "0 can not open output file E:\autorun.inf" But continues to write data. After it has finished, I remove the drive and insert to the other computer and turn it on, but it never finds a drive to boot from. What is causing this problem and how can I fix it ?

    Read the article

  • How can I prevent VirtualBox from changing the permissions on the .vbox File?

    - by KevinC
    I'm currently running Ubuntu 13.04, and I've got a Windows 8 VirtualBox VM installed. I put the VM's folder in a shared folder (/home/sharedHome/) that has read and write permissions assigned to the vboxusers group. This allows me to launch the VM from my account and my wife can launch it from hers. The only problem is that when you launch the VM from either account, the permissions get changed so that only that user has read and write privileges on the .vbox file. After this happens, the other account can't launch the VM unless I go in and change the permissions again. Does anyone know how to prevent VirtualBox from changing the permissions? Is there a better way to share a VM between users? Thanks!

    Read the article

  • How do I combine all lines in a text file into a single line?

    - by John
    I want to get all lines in a text into one line. I'm a beginner at coding trying to learn by doing. I've spent four hours trying to solve this problem. I know there's a simple solution to this problem. Here's what I've been trying. sed -e 'N;s/\n//' myfile.txt #Does nothing sed -e :a -e N -e 's/\n/ /' -e ta myfile.txt #output all messed up and I can't make head nor tail of the syntax cat myfile.txt | tr -d '\n' myfile.txt # Deletes all lines Here's the text file: 500212 262578-4-4 23200 GRIFFITH LABORATORIES LTD GRIFFITH LABORATORIES SOUTH DUBLIN COUNTY COUNCIL OFFICE OFFICE (INDUSTRIAL) List Rateable 2 Pineview Industrial Estate Firhouse Road Knocklyon 31 Dec 2007 01 Jan 2008" I can't figure out where I've gone wrong....

    Read the article

  • Apache2 and FTP

    - by Jo Colina
    I just set up an Apache web server on my Raspberry Pi, along with MySQL and PHP5, and to upload files i set up vsftpd. The thing is that the ftp connection sent me to my pi user home directory, instead of /var/www . So i changed Pi home directory to /var/www and changed it again to it's previous home. FTP now sends me to /var/www but whenever I upload files other rights are null. (Apache sends a 403 Forbidden every time unless I manually chmod the files inside /var/www uploaded via ftp) Does anyuone know how to fix this? Thanks!

    Read the article

  • phpBB - Reducing Spam

    - by user44175
    I've installed phpBB Forums last week and the past 2 days I've been getting users sign up and posting spam chinese emails on each topic. I have:- Added captcha on registration Made sure users have to verify subscription by email before allowing to post What else can I do to stop this from happening? I've banned their IP addresses but this doesn't stop them from using a proxy to keep spamming the forums. I've read I can block all chinese IP addresses through ACP but is this the best step to block all this? Seems to be all chinese spam at the minute, any help would be much appreciated.

    Read the article

  • Facebook: Sending private messages to FB profile from a static website [migrated]

    - by Frondor
    I need to setup a static website for people to: Complete a form. And using anything from Facebook API, GET the form output via message to a Facebook Profile. I've been punching my head against "facebook developers" page all night long and can't find out how to do it. Seems quite easy, but the problem is that I don't know if you'll get my point :) Like the Send Dialog feature, you can set a certain user as recipient which will be displayed on the "To:" field once the dialog appears. FB.ui({ method: 'send', to: 'UserID', link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html', }); Ok, All I need is to be able to use the same behavior but instead of setting a "to:" parameter, I'd like to set a "message:" parameter. I don't know how I can solve this becuase there's no parameter like this on the API actually. This is what I need to build (It's a prototype, this code won't work) <form action="mysite.com" id="order"> <input type="radio" name="chocolate" value="white">White <br/> <input type="radio" name="chocolate" value="black">Black <br/> <input type="submit" value="Order" /> </form> jQuery gets the values $(document).ready(function() { $("#order").on("submit", function(e) { e.preventDefault(); var formOutput = $(this).serialize(); var order = "I'd like to eat" + formOutput + "chocolate"; }); }); Facebook sdk sends this output ('order' string) FB.ui({ method: 'send', //or whatever to: 'UserID', message: order, //Its just an example, note the variable coming from the form link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html', }); As we all know, what I wrote isn't possible, so I'm asking for any alternative solution if somebody can give me, I'm not very friendly with facebook APIs :) I though in another solution which consist in using the form output directly on the 'link:' parameter of FB.ui and then reading it with jQuery on some landing page. For example, on the message sent, the linked content redirects to this URL: http://mysite.com/dashboard.html?chocolate=white and the dashboard page source code: <script> var choco = getUrlParameter('chocolate'); $("#dashboard").text("This person wants" + choco + "chocolate") </script> <div id="dashboard"></div> And this way, I will be able to see which kind of chocolate the person selected by parsing some parameters on the URL when clicking on the link section of the message: using a code like this: FB.ui({ method: 'send', //or whatever to: 'MyUserID', link: 'http://mysite.com/dashboard.html?chocolate=white', }); But no this try, my biggest problem is that I don't know how to dynamically "customize" that "link:" paramenter with jQuery. I think the best solution is to use a code like this along with the dashboard page in order to "translate" the shared URLs and see what kind of chocolate people are demanding xD FB.ui({ //declaring a variable (example) var string = getFormData().serialize; var orderString = "mysite.com/dashboard.html?" + string; // end the variables // start facebook API code method: 'send', //or whatever to: 'MyUserID', link: orderString, }); I was working here until I gave up and started to post this http://jsfiddle.net/Frondor/sctepn06/2/ Thanks in advance, I'll love you for ever if you help me solving this :D

    Read the article

  • What is the best way to have the same website in multiple domains?

    - by Daniel Magliola
    I would like to have the same website to sell a specific product, in multiple domains , to take advantage of keywords matching the domain name, for several different searches. However, I understand that having the same content in multiple sites will unleash the wrath of Google. If I have a redirect from all domains minus one, to that last one, do I still get any bonus for the "magic exact domain match jackpot"? Same question applies to canonical URLs... What's the best way to approach this? Thanks!

    Read the article

  • OpenGL directional light creating black spots

    - by AnonymousDeveloper
    I probably ought to start by saying that I suspect the problem is that one of my vectors is not in the correct "space", but I don't know for sure. I am having a strange problem with a directional light. When I move the camera away from (0.0, 0.0, 0.0) it creates tiny black spots that grow larger as the distance increases. I apologize ahead of time for the length of the code. Vertex shader: #version 410 core in vec3 vf_normal; in vec3 vf_bitangent; in vec3 vf_tangent; in vec2 vf_textureCoordinates; in vec3 vf_vertex; out vec3 tc_normal; out vec3 tc_bitangent; out vec3 tc_tangent; out vec2 tc_textureCoordinates; out vec3 tc_vertex; uniform mat3 vf_m_normal; uniform mat4 vf_m_model; uniform mat4 vf_m_mvp; uniform mat4 vf_m_projection; uniform mat4 vf_m_view; uniform float vf_te_inner; uniform float vf_te_outer; void main() { tc_normal = vf_normal; tc_bitangent = vf_bitangent; tc_tangent = vf_tangent; tc_textureCoordinates = vf_textureCoordinates; tc_vertex = vf_vertex; gl_Position = vf_m_mvp * vec4(vf_vertex, 1.0); } Tessellation Control shader: #version 410 core layout (vertices = 3) out; in vec3 tc_normal[]; in vec3 tc_bitangent[]; in vec3 tc_tangent[]; in vec2 tc_textureCoordinates[]; in vec3 tc_vertex[]; out vec3 te_normal[]; out vec3 te_bitangent[]; out vec3 te_tangent[]; out vec2 te_textureCoordinates[]; out vec3 te_vertex[]; uniform float vf_te_inner; uniform float vf_te_outer; uniform vec4 vf_l_color; uniform vec3 vf_l_position; uniform mat4 vf_m_depthBias; uniform mat4 vf_m_model; uniform mat4 vf_m_mvp; uniform mat4 vf_m_projection; uniform mat4 vf_m_view; uniform sampler2D vf_t_diffuse; uniform sampler2D vf_t_normal; uniform sampler2DShadow vf_t_shadow; uniform sampler2D vf_t_specular; #define ID gl_InvocationID float getTessLevelInner(float distance0, float distance1) { float avgDistance = (distance0 + distance1) / 2.0; return clamp((vf_te_inner - avgDistance), 1.0, vf_te_inner); } float getTessLevelOuter(float distance0, float distance1) { float avgDistance = (distance0 + distance1) / 2.0; return clamp((vf_te_outer - avgDistance), 1.0, vf_te_outer); } void main() { te_normal[gl_InvocationID] = tc_normal[gl_InvocationID]; te_bitangent[gl_InvocationID] = tc_bitangent[gl_InvocationID]; te_tangent[gl_InvocationID] = tc_tangent[gl_InvocationID]; te_textureCoordinates[gl_InvocationID] = tc_textureCoordinates[gl_InvocationID]; te_vertex[gl_InvocationID] = tc_vertex[gl_InvocationID]; float eyeToVertexDistance0 = distance(vec3(0.0), vec4(vf_m_view * vec4(tc_vertex[0], 1.0)).xyz); float eyeToVertexDistance1 = distance(vec3(0.0), vec4(vf_m_view * vec4(tc_vertex[1], 1.0)).xyz); float eyeToVertexDistance2 = distance(vec3(0.0), vec4(vf_m_view * vec4(tc_vertex[2], 1.0)).xyz); gl_TessLevelOuter[0] = getTessLevelOuter(eyeToVertexDistance1, eyeToVertexDistance2); gl_TessLevelOuter[1] = getTessLevelOuter(eyeToVertexDistance2, eyeToVertexDistance0); gl_TessLevelOuter[2] = getTessLevelOuter(eyeToVertexDistance0, eyeToVertexDistance1); gl_TessLevelInner[0] = getTessLevelInner(eyeToVertexDistance2, eyeToVertexDistance0); } Tessellation Evaluation shader: #version 410 core layout (triangles, equal_spacing, cw) in; in vec3 te_normal[]; in vec3 te_bitangent[]; in vec3 te_tangent[]; in vec2 te_textureCoordinates[]; in vec3 te_vertex[]; out vec3 g_normal; out vec3 g_bitangent; out vec4 g_patchDistance; out vec3 g_tangent; out vec2 g_textureCoordinates; out vec3 g_vertex; uniform float vf_te_inner; uniform float vf_te_outer; uniform vec4 vf_l_color; uniform vec3 vf_l_position; uniform mat4 vf_m_depthBias; uniform mat4 vf_m_model; uniform mat4 vf_m_mvp; uniform mat3 vf_m_normal; uniform mat4 vf_m_projection; uniform mat4 vf_m_view; uniform sampler2D vf_t_diffuse; uniform sampler2D vf_t_displace; uniform sampler2D vf_t_normal; uniform sampler2DShadow vf_t_shadow; uniform sampler2D vf_t_specular; vec2 interpolate2D(vec2 v0, vec2 v1, vec2 v2) { return vec2(gl_TessCoord.x) * v0 + vec2(gl_TessCoord.y) * v1 + vec2(gl_TessCoord.z) * v2; } vec3 interpolate3D(vec3 v0, vec3 v1, vec3 v2) { return vec3(gl_TessCoord.x) * v0 + vec3(gl_TessCoord.y) * v1 + vec3(gl_TessCoord.z) * v2; } float amplify(float d, float scale, float offset) { d = scale * d + offset; d = clamp(d, 0, 1); d = 1 - exp2(-2*d*d); return d; } float getDisplacement(vec2 t0, vec2 t1, vec2 t2) { float displacement = 0.0; vec2 textureCoordinates = interpolate2D(t0, t1, t2); vec2 vector = ((t0 + t1 + t2) / 3.0); float sampleDistance = sqrt((vector.x * vector.x) + (vector.y * vector.y)); sampleDistance /= ((vf_te_inner + vf_te_outer) / 2.0); displacement += texture(vf_t_displace, textureCoordinates).x; displacement += texture(vf_t_displace, textureCoordinates + vec2(-sampleDistance, -sampleDistance)).x; displacement += texture(vf_t_displace, textureCoordinates + vec2(-sampleDistance, sampleDistance)).x; displacement += texture(vf_t_displace, textureCoordinates + vec2( sampleDistance, sampleDistance)).x; displacement += texture(vf_t_displace, textureCoordinates + vec2( sampleDistance, -sampleDistance)).x; return (displacement / 5.0); } void main() { g_normal = normalize(interpolate3D(te_normal[0], te_normal[1], te_normal[2])); g_bitangent = normalize(interpolate3D(te_bitangent[0], te_bitangent[1], te_bitangent[2])); g_patchDistance = vec4(gl_TessCoord, (1.0 - gl_TessCoord.y)); g_tangent = normalize(interpolate3D(te_tangent[0], te_tangent[1], te_tangent[2])); g_textureCoordinates = interpolate2D(te_textureCoordinates[0], te_textureCoordinates[1], te_textureCoordinates[2]); g_vertex = interpolate3D(te_vertex[0], te_vertex[1], te_vertex[2]); float displacement = getDisplacement(te_textureCoordinates[0], te_textureCoordinates[1], te_textureCoordinates[2]); float d2 = min(min(min(g_patchDistance.x, g_patchDistance.y), g_patchDistance.z), g_patchDistance.w); d2 = amplify(d2, 50, -0.5); g_vertex += g_normal * displacement * 0.1 * d2; gl_Position = vf_m_mvp * vec4(g_vertex, 1.0); } Geometry shader: #version 410 core layout (triangles) in; layout (triangle_strip, max_vertices = 3) out; in vec3 g_normal[3]; in vec3 g_bitangent[3]; in vec4 g_patchDistance[3]; in vec3 g_tangent[3]; in vec2 g_textureCoordinates[3]; in vec3 g_vertex[3]; out vec3 f_tangent; out vec3 f_bitangent; out vec3 f_eyeDirection; out vec3 f_lightDirection; out vec3 f_normal; out vec4 f_patchDistance; out vec4 f_shadowCoordinates; out vec2 f_textureCoordinates; out vec3 f_vertex; uniform vec4 vf_l_color; uniform vec3 vf_l_position; uniform mat4 vf_m_depthBias; uniform mat4 vf_m_model; uniform mat4 vf_m_mvp; uniform mat3 vf_m_normal; uniform mat4 vf_m_projection; uniform mat4 vf_m_view; uniform sampler2D vf_t_diffuse; uniform sampler2D vf_t_normal; uniform sampler2DShadow vf_t_shadow; uniform sampler2D vf_t_specular; void main() { int index = 0; while (index < 3) { vec3 vertexNormal_cameraspace = vf_m_normal * normalize(g_normal[index]); vec3 vertexTangent_cameraspace = vf_m_normal * normalize(f_tangent); vec3 vertexBitangent_cameraspace = vf_m_normal * normalize(f_bitangent); mat3 TBN = transpose(mat3( vertexTangent_cameraspace, vertexBitangent_cameraspace, vertexNormal_cameraspace )); vec3 eyeDirection = -(vf_m_view * vf_m_model * vec4(g_vertex[index], 1.0)).xyz; vec3 lightDirection = normalize(-(vf_m_view * vec4(vf_l_position, 1.0)).xyz); f_eyeDirection = TBN * eyeDirection; f_lightDirection = TBN * lightDirection; f_normal = normalize(g_normal[index]); f_patchDistance = g_patchDistance[index]; f_shadowCoordinates = vf_m_depthBias * vec4(g_vertex[index], 1.0); f_textureCoordinates = g_textureCoordinates[index]; f_vertex = (vf_m_model * vec4(g_vertex[index], 1.0)).xyz; gl_Position = gl_in[index].gl_Position; EmitVertex(); index ++; } EndPrimitive(); } Fragment shader: #version 410 core in vec3 f_bitangent; in vec3 f_eyeDirection; in vec3 f_lightDirection; in vec3 f_normal; in vec4 f_patchDistance; in vec4 f_shadowCoordinates; in vec3 f_tangent; in vec2 f_textureCoordinates; in vec3 f_vertex; out vec4 fragColor; uniform vec4 vf_l_color; uniform vec3 vf_l_position; uniform mat4 vf_m_depthBias; uniform mat4 vf_m_model; uniform mat4 vf_m_mvp; uniform mat4 vf_m_projection; uniform mat4 vf_m_view; uniform sampler2D vf_t_diffuse; uniform sampler2D vf_t_normal; uniform sampler2DShadow vf_t_shadow; uniform sampler2D vf_t_specular; vec2 poissonDisk[16] = vec2[]( vec2(-0.94201624, -0.39906216), vec2( 0.94558609, -0.76890725), vec2(-0.09418410, -0.92938870), vec2( 0.34495938, 0.29387760), vec2(-0.91588581, 0.45771432), vec2(-0.81544232, -0.87912464), vec2(-0.38277543, 0.27676845), vec2( 0.97484398, 0.75648379), vec2( 0.44323325, -0.97511554), vec2( 0.53742981, -0.47373420), vec2(-0.26496911, -0.41893023), vec2( 0.79197514, 0.19090188), vec2(-0.24188840, 0.99706507), vec2(-0.81409955, 0.91437590), vec2( 0.19984126, 0.78641367), vec2( 0.14383161, -0.14100790) ); float random(vec3 seed, int i) { vec4 seed4 = vec4(seed,i); float dot_product = dot(seed4, vec4(12.9898, 78.233, 45.164, 94.673)); return fract(sin(dot_product) * 43758.5453); } float amplify(float d, float scale, float offset) { d = scale * d + offset; d = clamp(d, 0, 1); d = 1 - exp2(-2.0 * d * d); return d; } void main() { vec3 lightColor = vf_l_color.xyz; float lightPower = vf_l_color.w; vec3 materialDiffuseColor = texture(vf_t_diffuse, f_textureCoordinates).xyz; vec3 materialAmbientColor = vec3(0.1, 0.1, 0.1) * materialDiffuseColor; vec3 materialSpecularColor = texture(vf_t_specular, f_textureCoordinates).xyz; vec3 n = normalize(texture(vf_t_normal, f_textureCoordinates).rgb * 2.0 - 1.0); vec3 l = normalize(f_lightDirection); float cosTheta = clamp(dot(n, l), 0.0, 1.0); vec3 E = normalize(f_eyeDirection); vec3 R = reflect(-l, n); float cosAlpha = clamp(dot(E, R), 0.0, 1.0); float visibility = 1.0; float bias = 0.005 * tan(acos(cosTheta)); bias = clamp(bias, 0.0, 0.01); for (int i = 0; i < 4; i ++) { float shading = (0.5 / 4.0); int index = i; visibility -= shading * (1.0 - texture(vf_t_shadow, vec3(f_shadowCoordinates.xy + poissonDisk[index] / 3000.0, (f_shadowCoordinates.z - bias) / f_shadowCoordinates.w))); }\n" fragColor.xyz = materialAmbientColor + visibility * materialDiffuseColor * lightColor * lightPower * cosTheta + visibility * materialSpecularColor * lightColor * lightPower * pow(cosAlpha, 5); fragColor.w = texture(vf_t_diffuse, f_textureCoordinates).w; } The following images should be enough to give you an idea of the problem. Before moving the camera: Moving the camera just a little. Moving it to the center of the scene.

    Read the article

  • How add fog with pixel shader (HLSL) XNA?

    - by Mehdi Bugnard
    I started to make a small game in XNA . And recently i tried to add a "fog" on "pixel shader HLSL" with the class Effect from XNA . I search online about some tutorial and found many sample. But nothing want work on my game :-( . Before i already add a "fog" effect in my game and everything work, because i used the class "BasicEffect" but with the class "Effect" and HLSL, it's really more complicated. If somebody have an idea, it's will be wonderfull. Thanks again. Here is my code HLSL, i use. // Both techniques share this same pixel shader. float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 { //return tex2D(Sampler, input.TextureCoordinate) * input.Color; float d = length(input.TextureCoordinate - cameraPos); float l = saturate((d-fogNear)/(fogFar-fogNear)); float fogFactory = clamp((d - fogNear) / (fogFar - fogNear), 0, 1) * l; return tex2D(Sampler, input.TextureCoordinate) * lerp(input.Color, fogColor, fogFactory); } Here is the screenShot With effect Without effect

    Read the article

  • Calculating angle a segment forms with a ray

    - by kr1zz
    I am given a point C and a ray r starting there. I know the coordinates (xc, yc) of the point C and the angle theta the ray r forms with the horizontal, theta in (-pi, pi]. I am also given another point P of which I know the coordinates (xp, yp): how do I calculate the angle alpha that the segment CP forms with the ray r, alpha in (-pi, pi]? Some examples follow: I can use the the atan2 function.

    Read the article

  • How to configure background image to be at the bottom OpenGL Android

    - by Maxim Shoustin
    I have class that draws white line: public class Line { //private FloatBuffer vertexBuffer; private FloatBuffer frameVertices; ByteBuffer diagIndices; float[] vertices = { -0.5f, -0.5f, 0.0f, -0.5f, 0.5f, 0.0f }; public Line(GL10 gl) { // a float has 4 bytes so we allocate for each coordinate 4 bytes ByteBuffer vertexByteBuffer = ByteBuffer.allocateDirect(vertices.length * 4); vertexByteBuffer.order(ByteOrder.nativeOrder()); // allocates the memory from the byte buffer frameVertices = vertexByteBuffer.asFloatBuffer(); // fill the vertexBuffer with the vertices frameVertices.put(vertices); // set the cursor position to the beginning of the buffer frameVertices.position(0); } /** The draw method for the triangle with the GL context */ public void draw(GL10 gl) { gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glVertexPointer(2, GL10.GL_FLOAT, 0, frameVertices); gl.glColor4f(1.0f, 1.0f, 1.0f, 1f); gl.glDrawArrays(GL10.GL_LINE_LOOP , 0, vertices.length / 3); gl.glLineWidth(5.0f); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); } } It works fine. The problem is: When I add BG image, I don't see the line glView = new GLSurfaceView(this); // Allocate a GLSurfaceView glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); glView.setRenderer(new mainRenderer(this)); // Use a custom renderer glView.setBackgroundResource(R.drawable.bg_day); // <- BG glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); glView.getHolder().setFormat(PixelFormat.TRANSLUCENT); How to get rid of that?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >