10 Ekim 2013 Perşembe

Vertex Color Shader in unity

Hi,
I have realized Unity3d does not have a shader for vertex colored models.

Since it is one of the easiest ways to color your model in Blender (Vertex Painting), you might need this shader:

Go to your assests folder - Create - Shader.
Give a name to your shader and paste the code below: (The name in code is "Vertex Colored", you can change it with your shader name).

Keep in mind, that you need create a material for your model if it is not created. Then you can choose this shader on material's shader list.

And make the ambient light white to see it properly. (Render Settings - Ambient Light)

Cheers


Vertex Color Shader Script

Source:
http://wiki.unity3d.com/index.php?title=VertexColor


Shader " Vertex Colored" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _SpecColor ("Spec Color", Color) = (1,1,1,1)
    _Emission ("Emmisive Color", Color) = (0,0,0,0)
    _Shininess ("Shininess", Range (0.01, 1)) = 0.7
    _MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader {
    Pass {
        Material {
            Shininess [_Shininess]
            Specular [_SpecColor]
            Emission [_Emission]    
        }
        ColorMaterial AmbientAndDiffuse
        Lighting On
        SeperateSpecular On
        SetTexture [_MainTex] {
            Combine texture * primary, texture * primary
        }
        SetTexture [_MainTex] {
            constantColor [_Color]
            Combine previous * constant DOUBLE, previous * constant
        } 
    }
}

Fallback " VertexLit", 1
}

8 Ekim 2013 Salı

Blogger - Add Code Highlight

If you like to highlight the codes you share in blogger, what you can do is:

Go to link
http://formatmysourcecode.blogspot.com/

Paste your code in there, press `format text` and get your html code.
Then, in your entry, go to `HTML` section and paste your code.

That's all,
SyntaxHighlighter and other highlighters were very frustrating for me..

3 Eylül 2013 Salı

Microsoft SQL Server, Error: 18456 – Login failed for user.

If you encounter this error while connecting to the SQL Server  SQL authentication, the solution is simpe.

Connect to the server with Windows Authentication

Just check 2 things:

1. Go to Security -> Logins and right click to the user -> Properties -> Status
Login section should be Enabled

2. Right click to the Database Engine, Go to Properties -> Security 
In Server Authentication section, make sure

SQL Server and Windows Authentication Mode is selected.

It would need a SQL Server restart, which you can do by:
Start - > Run - > Services.msc

Go to SQL Server  and Restart it.

Thats all !

22 Temmuz 2013 Pazartesi

Unity3d - Round double / float values

Hi,
To be able to round the values in unity csharp you need the code below:


float rawValue = 5.521f;
rawValue = Mathf.Round(rawvalue * 100f) / 100f);
//it should return 5.5



In order to increase decimals, just use 1000 or 10000 etc.

8 Temmuz 2013 Pazartesi

MS SQL Adding Unique Column / Columns

Hi,
I always keep forgetting this sql command,
if you have a table and you want to create unique columns use following statement:

ALTER TABLE dbo.tablename ADD CONSTRAINT constraintName UNIQUE (col1, col2, col3)

like:
ALTER TABLE dbo.User ADD CONSTRAINT uqUPE UNIQUE (username, phone, email)

This prevents you to insert a row with the same username AND phone AND email. (all of them should be same, only one or two can also be added)


You can also do the same thing for just one column. If you d like to have 3 columns to be unique separately, just create 3 statements for each column, so you ll have 3 constraint checks for each column.

Cheers,
Deniz

7 Haziran 2013 Cuma

Devexpress `Loading` panel hangs

I ve experienced this error and after couple of hours later I have realized that the error occurs only on Internet Explorer 10 !!

In order to quck fix it, you may activate the compatible view and you ll see the problem is resolved.

If you like to investigate the problem,
Just enable debugger for exporer and you ll see that you get an Javascript error on  postcallback.

Error is      __dopostback is undefined

In order to fix it you need to update your browser definiton files of your .Net framework



Here is the link: Just download proper fix

http://search.microsoft.com/en-us/supportresults.aspx?form=mssupport&q=browser%20definition%20files


That's all

17 Mayıs 2013 Cuma

HTTP Error 500.19 - Internal Server Error

If you install IIS 8 on Windows 8 you might experience this problem.

To resolve this:

Run cmd as Administrator, type:

cd C:\Windows\System32\InetSrv

Run both commands:

appcmd unlock config -section:system.webServer/handlers
appcmd unlock config -section:system.webServer/modules


That 's it

17 Nisan 2013 Çarşamba

Remote Desktop to Hyper V Windows Server

Hi,
By default installation of Hyper V - Windows Machine, you cannot access the machine with Remote Desktop (mstsc.exe)

There are mainly 2 steps in order to resolve this: (My case was Windows Server 2008 R2 machine)
- Allow RDP connections to Virtual machine
- Turn on Network Discovery

In order to do that, you need to do following:
- Connect to machine with Hyper v
- Right click My Computer - Properties
- Click on Remote Settings on the right hand side
- Set "Allow connections from computers running any version of Remote Desktop"
- Run "services.msc"
- Here be sure that the below services are enabled and running:
  • DNS Client
  • Function Discovery Resource Publication
  • SSDP Discovery
  • UPnP Device Host
- Open Network and Sharing Center (Just search on Start bar)
- Click "Change Advanced Sharing Settings"
- Select "Turn on Network Discovery"
-After you clicked OK, recheck if it is set correctly, because depending on the services above, it might not be running.

That't s all !

Now you can connect to your Hyper V machine with RDP
 

19 Mart 2013 Salı

Maximum request length exceeded

Hi,
You probably get this error while uploading or exporting a document on web pages.

In order to resolve this, you should add

<httpRuntime maxRequestLength="1048576" />

inside your web.config - system.web section.

This would allow you to increase the limit 1 GB,
With .Net 2.0 you can use 2097151 (2GB)

7 Şubat 2013 Perşembe

Sharepoint 2010 Access Denied Error for all users

Hi,
This problem cost me 2,5 days to figure it out.

I needed to change the service password of the server, after I did that (along with changing managed account pass, iis app pool passes and all services credentials) I could not login to one of my Web App !

I ve got "Access Denied" error even for admins..

Solution was to delete the Web App and creating a new one and associating the old content db with this new web app.

Steps:

- Delete Web App via Central Admin (Click Delete - On upcoming window choose delete IIS but NOT delete Content DB)
- Created new web App with same name but with different content_db name. (we are just going to replace it anyway)
- Make the new web App content db offline:  CA - Application Management - Manage Content Databases-Select the db, Make the Database Status- Offline
- Run the following stsadm command to bind the old content db:
stsadm -o addcontentdb -url http://yourwebapp:port -databasename yourcontentdb -databaseserver yoursqlserver
Thats all



Other solutions I ve tried:

- Check if db is read only: (CA - Application Management - Manage Content Databases-Select the db Check the status) or Run this SQL:
SELECT name, is_read_only
FROM sys.databases
- Check if Site Collection is read only  (locked) CA - Application Management - Configure quatas and locks
- Check if the IIS folders permissions are OK: Go to IIS folder of the WEb App, check the security tab and check if your user is in the admin users. (WPG ADMIN, Administrators, etc.)
- Check the IIS Application Pool user-passwords are OK
- Check the all the Services running have the right credentials (Run services.msc checked all the services using this account)
- Check if the user in Web App User Policy (Object Cache): CA - Application Management - Select web app - Select User Policy on Top - Check the reader and superuser accounts (there are plenty of links in google..)
- Check if another page in the Web App is working: Just check http://yoursite/_layouts/settings.aspx. If it is working fine for all users, then you ve got something wrong in your homepage. Probably a webpart or a custom control does not have sufficent permission.



Setting Object Cache Accounts in SharePoint 2010

Hi,

Just copy the code below, change the first 3 parameters, you are good to go !

Note:
If you use claims auth. you need to add "i:0#.w|" in front of your username like I did.

$wa = Get-SPWebApplication -Identity http://yoururl
$SuperUserAcc = "i:0#.w|WW300\w99s0700"
$SuperReaderAcc = "i:0#.w|WW930\w99s0700"
Function Set-WebAppUserPolicy($wa, $userName, $displayName, $perm)
{
    [Microsoft.SharePoint.Administration.SPPolicyCollection]$policies = $wa.Policies
    [Microsoft.SharePoint.Administration.SPPolicy]$policy = $policies.Add($userName, $displayName)
    [Microsoft.SharePoint.Administration.SPPolicyRole]$policyRole = $wa.PolicyRoles | where {$_.Name -eq $perm}
    If ($policyRole -ne $null) {
        $policy.PolicyRoleBindings.Add($policyRole)
    }
    $wa.Update()
}

$wa.Properties["portalsuperuseraccount"] = $SuperUserAcc
Set-WebAppUserPolicy $wa $SuperUserAcc "Super User (Object Cache)" "Full Control"
$wa.Properties["portalsuperreaderaccount"] = $SuperReaderAcc
Set-WebAppUserPolicy $wa $SuperReaderAcc "Super Reader (Object Cache)" "Full Read"
$wa.Update()