Translate

Monday, 26 November 2018

Libgdx shaders : Passing multiple shaders in one shader

When using shaders in 3D libgdx we encounter an issue of binding textures to models. Sometimes all environment and 3d models used in game use same textures , specially when you are working with multiple models.

Following codes is used in this example

Vetex Shader 

attribute vec3 a_position;
 attribute vec3 a_normal;
 attribute vec2 a_texCoord0;
 uniform mat4 u_worldTrans;
 uniform mat4 u_projTrans;
 varying vec2 v_texCoord0;
 void main() 

{
 v_texCoord0 = a_texCoord0; gl_Position = u_projTrans * u_worldTrans * vec4(a_position, 1.0);

}



Fragment Shader

#ifdef GL_ES precision mediump float;
 #endif uniform vec3 u_colorU;
 uniform vec3 u_colorV;
 varying vec2 v_texCoord0;
 uniform sampler2D u_texture;
 void main() { 
  gl_FragColor = texture2D(u_texture , v_texCoord0); 
}


In start of render


Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); // Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0); // texture.bind(); Gdx.gl20.glEnable(GL20.GL_TEXTURE_2D); Gdx.gl20.glEnable(GL20.GL_BLEND);





And here is Working multi texture binding with single shader


import com.badlogic.gdx.Gdx;import com.badlogic.gdx.graphics.Camera;import com.badlogic.gdx.graphics.Color;import com.badlogic.gdx.graphics.GL20;import com.badlogic.gdx.graphics.GLTexture;import com.badlogic.gdx.graphics.g3d.Renderable;import com.badlogic.gdx.graphics.g3d.Shader;import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute;import com.badlogic.gdx.graphics.g3d.utils.RenderContext;import com.badlogic.gdx.graphics.glutils.ShaderProgram;import com.badlogic.gdx.utils.GdxRuntimeException;
import screens.PlayScreen;
public class TestShader implements Shader {
    ShaderProgram program;
    Camera camera;
    RenderContext context;
    int u_projTrans;
    int u_worldTrans;
    int u_colorU;
    int u_colorV;

    PlayScreen playScreen;

    public TestShader(PlayScreen playScreen) {
        this.playScreen =  playScreen;
    }

    @Override    public void init() {
        String vert = Gdx.files.internal("shaders/uvcolor.vertex.glsl").readString();
        String frag = Gdx.files.internal("shaders/uvcolor.fragment.glsl").readString();
        System.out.println("hello shader" + vert);
        program = new ShaderProgram(vert, frag);
        program.pedantic = false;
        if (!program.isCompiled())
            throw new GdxRuntimeException(program.getLog());
        u_projTrans = program.getUniformLocation("u_projTrans");
        u_worldTrans = program.getUniformLocation("u_worldTrans");
        u_colorU = program.getUniformLocation("u_colorU");
        u_colorV = program.getUniformLocation("u_colorV");
    }

    @Override    public void dispose() {
        program.dispose();
    }

    @Override    public void begin(Camera camera, RenderContext context) {
        this.camera = camera;
        this.context = context;
        program.begin();
        program.setUniformMatrix(u_projTrans, camera.combined);
        context.setDepthTest(GL20.GL_LEQUAL);
        context.setCullFace(GL20.GL_BACK);
        

    }

    @Override    public void render(Renderable renderable) {
        program.setUniformMatrix(u_worldTrans, renderable.worldTransform);
        Color colorU = ((ColorAttribute)renderable.material.get(ColorAttribute.Diffuse)).color;
        Color colorV = ((ColorAttribute)renderable.material.get(ColorAttribute.Diffuse)).color;

        program.setUniformf(u_colorU, colorU.r, colorU.g, colorU.b);
        program.setUniformf(u_colorV, colorV.r, colorV.g, colorV.b);

        ((TextureAttribute)renderable.material.get(TextureAttribute.Diffuse)).textureDescription.texture.bind();

        renderable.meshPart.render(program);
    }

    @Override    public void end() {
        program.end();
    }

    @Override    public int compareTo(Shader other) {
        return 0;
    }
    @Override    public boolean canRender(Renderable renderable) {
        return renderable.material.has(ColorAttribute.Diffuse);
    }
}


Happy coding :P. Please let me know in comments if this helps :D

Monday, 2 February 2015

iRedmail installation: Please configure a fully qualified domain name

ERROR : Please configure a fully qualified domain name

Solution :
1)set hostname in /etc/host (e.g. 127.0.0.1    mail.ubuntu.com      mail      localhost )
2)And also by using command line
       hostname mail.ubuntu.com 


*************************************************************************
***************************** WARNING ***********************************
*************************************************************************
*                                                                       *
* Below file contains sensitive infomation (username/password), please  *
* do remember to *MOVE* it to a safe place after installation.          *
*                                                                       *
*   * /home/user/iredmail/iRedMail-0.8.7/config
*                                                                       *
*************************************************************************
 

  Would you like to use firewall rules provided by iRedMail now?
Select no : it is not recommended link .

Thursday, 14 August 2014

ant taskdef class org.apache.catalina.ant.installtask cannot be found

While using Apache Ant with Apache Tomcat  with if this error appears

ant taskdef class org.apache.catalina.ant.installtask cannot be found

Solution:
If you are using tomcat version 7 then add this to your build.xml file.
<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
 
instead of 
 
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
 


Thursday, 7 August 2014

Maven org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved

Solution :

1)Set your proxy settings if any. Set proxy property in Setting.xml in maven Folder. link
2)run mvn --version to check if all paths are correct
3)create new mvn project using command line and build it. if build is successful then is may be cache problem. Delete all folders form .m2 local repository folder and recreate project and let it download all dependencies again. To create new project visit link. To compile run mvn compile in project folder.

Wednesday, 25 June 2014

Setting up Squirrelmail with postfix and devcoot: errors: Authentication not enabled && Relay Access Denied

****************************************************************

issue 1
ERROR:
Message not send Server Replied
Transaction Failed
554.5.7.1 <email>: Relay Access Denied

Solution :
Check hostname of system by command
hostname
vim /etc/postfix/main.cf
check hostname in main.cf file it must be identical as hostname 
Check hostname in /etc/hosts

*********************************************************************

issue2
ERROR:
Message not send Server Replied
Temporary authentication failure
454 4.7.1<mail>:Relay access denied

solution:
change smtp_auth to none if it is login in
vim /etc/squirrelmail/config.php


*********************************************************************


issue3
ERROR:
Message not send Server Replied
Bad sequence of commands
503 5.5.1<mail>:Authentication not enabled 

solution:
change smtp_auth_mech to none if it is login in
vim /etc/squirrelmail/config.php


************************************************************************

issue4
ERROR: NIS lookup not set. NIS lookup disabled
it appears in maillog

Solution :
vim /etc/squirrelmail/main.cf
line number 382
uncomment
alias_maps = hash:/etc/aliases

*************************************************************************

Friday, 6 June 2014

vt-x is not available. (verr_vmx_no_vmx)

You might see this error when some day you run Virtual Box

vt-x is not available. (verr_vmx_no_vmx)

This error is due to occupied VT-X resource by some other program , process or service. Most common reason of this is due to Hyper-V on Windows. You can stop hyper-V services form component services or for permanent solution disable service or UNCHECK it from turn windows program on or off.




Restart. VirtualBox should be fine.

Tuesday, 25 March 2014

Restrict Root Access to server



Adding user with root privileges
sudo useradd -m testuser
sudo passwd testuser
sudo usermod -s /bin/bash testuser

Restart ssh
/etc/init.d/ssh restart

Check your access can ssh but not able to have root access
Open the file sudoers  
vim /etc/sudoers

Add the following lines below the root line in the file
testuser ALL=(ALL:ALL) ALL
write quite

Service ssh restart
/etc/init.d/ssh restart

Check again for root access. Got access.

Changing ssh port. Edit sshd_config file
vim /etc/ssh/sshd_confing
Port 22
change it to desired one

wq

service ssh restart

Check again with new port

ssh -p 220 testuser@SERVER_IP

Successfully logged in.

Restricting root user from direct login.
Edit sshd_config and add

PermitRootLogin no

and comment PermitRootLogin yes

service ssh restart



Now adding sftp users

create backup of sshd_config
Create new users with home directories
Create their passwords
Add it to group


FreeRadius PAP Authentication Issue : WARNING: Unprintable characters in the password. Double-check the shared secret on the server and the NAS! Using Post-Auth-Type Reject ().[pap] Passwords don't match

If you are seeing this in radius log

WARNING: Unprintable characters in the password.  Double-check the shared secret on the server and the NAS! Using Post-Auth-Type Reject ([pap] Passwords don't match).

 [pap] login attempt with password "5?q¦¦?!##+Y?E¦¦"
[pap] Using clear text password "mypassword"

Do nothing until this warning is disappeared. To troubleshoot this use following

1) Match your key as described in warning .(NAS shared secret and shared secret on other Service like VPN in my case )

2) If keys are same and still FreeRadius is NOT Authenticating then change your secret to some simple secret like ("mysecret"). This may be due to too long shared secret or data type conversion mismatch between your Radius server and Service Shared Secret.

NOTE: You have to change shared secret on three locations.

1) Radcheck database table in Radius Server
2) /etc/raddb/clients.conf (In case of CentOS)
3) /etc/openvpn/radiusplugin.cnf

This will solve your issue. For more understanding you can see Defining Shared Secret on official documentation of Radius Server. link


Wednesday, 22 January 2014

Install open VPN , PPTP and L2tp Client network manager ubuntu

apt-get install network-manager-openvpn
sudo apt-add-repository ppa:seriy-
pr/network-manager-l2tp
sudo apt-get update
sudo apt-get install network-manager-l2tp-gnome

http://forum.openvz.org/index.php?t=msg&goto=49760&
I've found that xt_tcpudp module seem to be included in the kernel packages of Debian 6, but not of CentOS 6. I don't know if it can be installed with some additional package (yum).


http://forum.openvz.org/index.php?t=msg&goto=8117
Hi,

iptables "MASQUERADE" isn't virtualized,
only listed iptables modules can be used in VE context:
(see man-page of vzctl)

iptable_filter,iptable_mangle, ipt_limit, ipt_multiport,
ipt_tos, ipt_TOS,ipt_REJECT, ipt_TCPMSS, ipt_tcpmss,
ipt_ttl, ipt_LOG, ipt_length, ip_conntrack, ip_conntrack_ftp,
ip_conntrack_irc, ipt_conntrack, ipt_state, ipt_helper,
iptable_nat, ip_nat_ftp, ip_nat_irc, ipt_REDIRECT xt_mac.
 



iptables -t nat -A POSTROUTING -j SNAT --to-source <venet's IP>
 
 
 http://sourceforge.net/p/ipsec-tools/bugs/70/
modprobe af_key 


http://superuser.com/questions/570612/how-do-i-get-l2tp-to-successfully-install-on-centos-5-9
http://lowendtalk.com/discussion/11171/implement-of-l2tp-in-an-openvz-container 


ifconfig.me
execute command without saving in history .
space and command  

Saturday, 14 December 2013

how to configure pptp and freeradius




pptp authentication using freeradius you can following tutorials.

For freeradius setup : http://safesrv.net/install-and-setup-freeradius-on-centos-5/
For pptpd setup      : http://safesrv.net/setup-pptp-and-freeradius-on-centos-5/

After radius server installation test radius server locally and remote server. If response is positive then you are done with radius server. Else add nas table to radius server if is it is already not included or not already configured.

Try not to jump on another server deployment util you are not completely deployed previous one.

If you are unable to communicate between user , VPN server and freeRADIUS server then check IPTABLES and port forwarding. And also check that in VPN server configuration ,  radius server ip is defined.
Also confirm that in freeRADIUS configuaration ,   VPN server ip is listed in clients.
After successfull setup of these two servers following are possible issues you may face.

Possible issue :
Issue 1 : Carefully read tutorial and do configuration of right files. Because some directories contains file names with little difference for example options.pptpd and options-pptpd.

Issue 2 : User requires some authentications like pap , chap , mschap etc. User sends authentication requests to VPN server and VPN sever forward this request to freeRADIUS server to authenticate user.

Authentication will only be successfull if user's required authentications matches with /etc/ppp/pptpd-options configuration. In /etc/ppp/options-pptpd  authentications are written like this require-pap refuse-pap etc.

Still having problem please read this freeradius official tutorial http://wiki.freeradius.org/guide/PopTop-HOWTO   .






pptp Unknown attribute 47. Modem hang up



You are setting up PPTP Using freeRADIUS server.
freeRADIUS server is ready to process requests. And PPTP is accepting connections.
Windows clients are working fine and browsing successfully.
Ubuntu PPTP clients connect to server but in less than 10 sec they disconnect.
Server logs:
Server log is showing modem hangup.
Unknown attribute 47.
Unknown attribute 48.
Solution:
This is client side error. The server is working fine. There is no need to check server.
This is maximum transmission unit error on client side. (MTU , the size of largest protocol data unit)
To solve this issue only change MTU of interface through which you are connected to internet.
Enter following command in terminal.
sudo ifconfig eth0 mtu 1400
Change eth0 to interface from which you are connected to internet. MTU value of 1400 at client side. PPTP is connected and not disconneting any more. No modem hang up error on client side.

openVPN Bad LZO decompression header byte

Scenario:
You have successfully deployed freeRADIUS and openVPN.
OpenVPN client successfully connects to openVPN server
Windows openVPN client can seccessfully connect to the server and can brwose sites successfully.

Issue:
But ubuntu clients can not browse sites successfully.
And also disconnects in less than 30 seconds.

Logs:
Used logs are
/var/log/messages
/etc/openvpn/1194.logs

/var/log/openvpn.log shows the basic issue.
*Bad LZO decompression header byte: 69*

Solution:
Before connecting openVPN client correct the openVPN configuration.
Check (Tick) lozo compression in advanced settings of vpnClient configuration in Ubuntu client.


Client can browse site successfully but IP of client not changing. L2TP


You have successfully deployed freeRADIUS and L2TP.
Windows L2TP client successfully connects to L2TP server

Issue:
Client can browse site successfully but IP of client not changing.

Solution
In /etc/racoon/psk.txt
There is given ( * ) which mentioned for Iphone or android clients. Give both l2tp server ip and * with secret key also.

Now connect to server. It should work now. :)



w3af : ImportError: cannot import name process_pdf




w3af Installing w3af.

- after cloaning w3af from git clone https://github.com/andresriancho/w3af.git running ./w3af shows install missing packages of OS and python.
- w3af generate script of missing requirements in /tmp/ directory.
- Missing packages installed by running script.
- some packages are not installed.
- pysvn and scapy installed manually by pip install http://link-to-package
Prolem:
after running ./w3af_console it shows pdf_process error at last.
ImportError: cannot import name process_pdf
Traceback (most recent call last):
File "./w3af_console", line 25, in <module>
from core.ui.console.console_ui import ConsoleUI
File "/home/w3af/core/ui/console/console_ui.py", line 42, in <module>
from core.controllers.w3afCore import w3afCore
File "/home/w3af/core/controllers/w3afCore.py", line 36, in <module>
from core.controllers.core_helpers.strategy import w3af_core_strategy
File "/home/w3af/core/controllers/core_helpers/strategy.py", line 30, in <module>
from core.data.url.extended_urllib import MAX_ERROR_COUNT
File "/home/w3af/core/data/url/extended_urllib.py", line 45, in <module>
from core.data.parsers.HTTPRequestParser import HTTPRequestParser
File "/home/w3af/core/data/parsers/HTTPRequestParser.py", line 26, in <module>
from core.data.request.factory import create_fuzzable_request_from_parts
File "/home/w3af/core/data/request/factory.py", line 29, in <module>
import core.data.parsers.parser_cache as parser_cache
File "/home/w3af/core/data/parsers/parser_cache.py", line 26, in <module>
import core.data.parsers.document_parser as DocumentParser
File "/home/w3af/core/data/parsers/document_parser.py", line 25, in <module>
from core.data.parsers.pdf import PDFParser, pdf_to_text
File "/home/w3af/core/data/parsers/pdf.py", line 26, in <module>
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter, process_pdf
ImportError: cannot import name process_pdf

Solution:
It is only due to this missing package phply

w3af plugins.grep.clamav: "No module named six"."

If you are getting this error on running ./w3af_console

Error while reading plugin options: "There was an error while importing plugins.grep.clamav: "No module named six"."

then
Solution :

apt-get install python-six :)

w3af not sending email , not even saving any configurations.


If w3af not saving any configurations then there is issue which can be resolved by recloaning w3af. And following instructions on console. Console might say to install phply. A command to install will also be there.

If w3af not sending email then make sure following.

Make sure mailutils and sendmail is installed.
Use sender domain.
Sender domain other than gmail. For example abc@yahoo.com.
Still not receiving email in gmail. Gmail might have black listed your ip. Change sender and receiver emails of yahoo domain.
Still having trouble.
Checking of logs is necessary.
/var/log/syslog
/var/log/mail.log

Saturday, 30 November 2013

w3af Discovery plugin missing. w3af version 1.6

May be you see this message on running latest cloned w3af. (version 1.6)
The profile you are trying to load (fast_scan) seems to be outdated, this is a common issue which happens when the framework is updated and one of its plugins adds/removes one of the configuration parameters referenced by a profile, or the plugin is removed all together.
So dont worry here is solution.

-- w3af installation guide is good document to study how to install w3af.
-- w3af installation needs several python plugins to work.
-- use pip or easy_install to install these packages.
-- Details of these packages are given in Guide.
-- pdfminer is also a python plugin required.
-- after installation when running ./w3af_console. w3af automatically console generate bash script to install remaining plugins.
-- the problem was in after running ./w3af_console , profiles --> use fast_scan w3af shows above message.
-- Searching the problem results in following link. You can also read from this link but i have also mentioned problem and solution in this post.
-- This message is usually due to that you have several attempts to install w3af on ubuntu.
--Problem was that latest cloned w3af use previous installation files which are in .w3af directory.
-- After removing this directory rm -r .w3af.. ./w3af_console works fine.
-- w3af installation is complete on ubuntu
-- w3af may say that again some plugin is missing. At least in my case it says that. But dont worry just install missing plugin from script automatically created by w3af in /tmp/ directory or read the message carefully it will guide you where is bash script placed by w3af.
-- simply run script using by moving to directory and entering ./dependency_fileName.sh. w3af should work now.
-- If you still have issue then you can also post new issue by registering into github and using this link. https://github.com/andresriancho/w3af/issues/144
click on new issue. write all used method of installation and python version ,installed python packages , gtk version , and error message as well. 



Monday, 11 November 2013

How to download Videos from ubuntu ..Donwload Manager for Ubuntu ,

Note : This method will not work for anonymous web browsing. 
To download videos form ubuntu and to use a good download manager for ubuntu follow these steps.
(1) Download Uget download manager from here. Download debian version for easy installation.
(2) Install FlashGot add-on in firefox from firefox add-on site.


Sunday, 10 November 2013

SFTP Server setup , with SFTP restricted Account , SFTP user Restricted to one directory only

Here is complete method to create setup SFTP server on ubuntu server. This method will

Setup SFTP server on ubunut server.
Create SFTP user.
SFTP user will be restricted to one directory only.
SFTP user will not have SSH Secure Shell Access.

SFTP server will access server using SSH. So to install SSH .

sudo apt-get install openssh-server

Edit   /etc/ssh/sshd_config with your favourit editor. I am using vim for this procedure and you can use yours like nano. Add this at the end of file. testuser is username of sftp user.

UsePAM yes
Match User testuser
ChrootDirectory %h
ForceCommand internal-sftp
X11Forwarding no
AllowTCPForwarding no

Save it and enter following commands to terminal.

To create testuser enter. -m flag will create root directory in /home/ by default. To set it to your desired directory use -d flag (e.g. useradd -d /home/user/myDirectory testuser).
useradd -m testuser

Add user to group sftp. (To create group sftp enter in terminal "groupadd sftp")
usermod -G sftp testuser

The following command is so much important. It defines the login shell of testuser. If it is not set then shell for test user will be default. Restrict user to its home directory only. This will also restrict user to access SSH access.
 usermod -s /bin/false testuser

Change owner so that he can have full access to his directory.
NOTE : This is root directory ROOT should be owner of this directory. To upload and download files create sub directory  with ("chown testuser:sftp /home/testuser/newDirectory")
 chown root:root /home/testuser

Change mod to 755 . Read , Write , execute for user. Read and execute for sftp group members. Read and execute for all other users.
 chmod 0755 /home/testuser

To set password for testuser enter.
passwd testuser

and do not forget to restart your sshd.
/etc/init.d/ssh restart

Test Your sftp setup

To test your sftp setup on LAN or WAN. Install filezilla on other system and enter the IP of your sftp server. From menu bar click on site manager and select sftp as file transfer. Leave port number blank, it will be default to 22. Enter user name and password for sftp user which you created on target machine. testuser in my case.



Troubleshooting :
Before testing remotely. Test newly created sftp user on localhost by entering this cammand

sftp testuser@localhost 

then enter password. If successful this error comes Request for subsystem 'sftp' failed on channel 0

comment subsystem line in /etc/ssh/sshd_config. And write this one  
Subsystem sftp internal-sftp
 
To understand this error visit this .

Comments , Suggestions , Questions and Corrections are Welcome :) 





Tuesday, 27 August 2013

How to Change Desktop Environment in Ubuntu 13.04

Changing Desktop Environment in Ubuntu is easy. Rather than installing Linux Mint for Cinnamon Desktop Environment. You can easily get Cinnamon Desktop Environment or any other Desktop Environment to Ubuntu. Like KDE , XFCE , GINOME , UNITY etc..

Default Desktop environment for ubuntu is Unity.

GINOME:
sudo apt-get install gnome 




CINNAMON:
sudo add-apt-repository ppa:gwendal-lebihan-dev/cinnamon-stable
sudo apt-get update
sudo apt-get install cinnamon


KDE:
 sudo add-apt-repository ppa:gwendal-lebihan-dev/cinnamon-stable
sudo apt-get update
sudo apt-get install cinnamon nemo




How to open specific Desktop Environment....

Reboot of log off computer ...

At Login Screen there will be an icon at User name in ubuntu 13.04. Click this icon and Select your desired Desktop Environment.