3ds Max - Max Script - Light mapping issue - rendered image is complete map not light map only

Wednesday, 28 December 2011 10:25 by Chad

I wanted to export the lighting component of a mesh as a light map for use in a game, so I've scripted a 3ds Max script to automate the creation of hundreds of lightmaps. However the generated image is as it appears in the render window - it is the complete map, not just the lighting component.

Your max script may look like the following - replace the lm.fileType with the full path instead of just the extension, do not pass in the outputFile to the render call.

local lm = LightingMap()
 lm.outputSzX = 100
 lm.outputSzY = 100
 lm.autoSzOn = off
 lm.fileType = ".png"
 lm.fileType = "C:\Full\Path\To\Output\Dir\Lightmap1.png"
 lm.shadowsOn = on
 lm.directOn = on
 lm.indirectOn = on
 lm.enabled = on
 
 bakeProps = obj.INodeBakeProperties
  bakeProps.bakeEnabled = true
  bakeProps.flags = 1
  bakeProps.bakeChannel = 3
  bakeProps.nDilations = 16
  bakeProps.addBakeElement lm
 
 local renderedMap = render \
  rendertype:#bakeSelected \
  outputwidth: lm.outputSzX \
  outputheight: lm.outputSzY \
  vfb:on \
  outputFile: outputPath\
  filterMaps:on \
  antiAliasFilter:(catmull_rom())

HLSL FX compiler error

Wednesday, 21 December 2011 01:28 by Chad

Issue

You have an array of texture coordinates and indexing into the array causes the following compiler error:

Error Error: error X8000: D3D10 Internal Compiler Error: Invalid Bytecode: Masks (and if pixel shader, also interpolation mode) on all input registers in an index range must be identical. Input register [1] does not match with others in the index range from 0 to 4. 

float2 uvs[4] = { IN.UV0, IN.UV1, IN.UV2, IN.UV3 };
 
 OUT.UVA = uvs[uvIndexA];
 OUT.UVB = uvs[uvIndexB];
 OUT.UVBlend = uvs[uvIndexBlend];
 OUT.UVLightmap = uvs[uvIndexLightmap];

One possible solution

Assign the input texture coordinate variables to local variables first.

float2 a = IN.UV0;
float2 b = IN.UV1;
float2 c = IN.UV2;
float2 d = IN.UV3;

float2 uvs[4] = { a, b, c, d };

OUT.UVA = uvs[uvIndexA];
OUT.UVB = uvs[uvIndexB];
OUT.UVBlend = uvs[uvIndexBlend];
OUT.UVLightmap = uvs[uvIndexLightmap];

Keyword not supported: 'metadata'.

Tuesday, 20 December 2011 15:06 by Chad

When upgrading to Entity Framework remember to put the providerName attribute on your connection string element in the web.config

<add name="FVLBEntities" 
	connectionString="metadata=res://*/DB.csdl|res://*/DB.ssdl|res://*/DB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=sqlserver;initial catalog=my_database;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" 
	providerName="System.Data.EntityClient"/>

Error inserting a new row/entity using EF4.x

Tuesday, 20 December 2011 11:04 by Chad

Error

Unable to update the EntitySet 'User' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.

Solution

Make sure your table has a primary key!

CustomActions appear twice in central admin

Monday, 19 December 2011 08:47 by Chad

Issue

You define a simple custom action so that it appears in Central Admin, however it is being displayed twice.

One possible fix

Retract, and completely remove the solution, change the featrure ID and redeploy.

The Project Item "xyz" cannot be deployed through a Feature with Farm scope.

Monday, 19 December 2011 08:41 by Chad

Issue

Setup:

A VS 2010 solution that contains a feature scoped at Farm. You add a new Module so you can get the Elements.xml file inside it. But when you try add the Elements.xml file to the feature it's not listed, it is when you change the scope to Web, but not as Farm.

Solution

Delete the module, re-add the Elements.xml as a new Blank Element. For some reason Visual Studio tracks the Elements.xml file and knows it came from a module, which for some reason isn't allowed to be added to a Farm scoped feature.

Disable paging on a SQL Reporting document

Monday, 12 December 2011 13:10 by Chad

Add the InteractiveHeight element to the Page element

 <Page>
    <PageHeight>29.7cm</PageHeight>
    <PageWidth>21cm</PageWidth>
    <LeftMargin>2cm</LeftMargin>
    <RightMargin>2cm</RightMargin>
    <TopMargin>2cm</TopMargin>
    <BottomMargin>2cm</BottomMargin>
    <ColumnSpacing>0.13cm</ColumnSpacing>
    <Style />
    <InteractiveHeight>0cm</InteractiveHeight>
  </Page>

Include (@using) a namespace in every page in an MVC site

Friday, 9 December 2011 14:35 by Chad

If you create some Url helper extensions and you'd like them to be immediately available on every page without needing to put @using at the top of every cshtml file you can:

Add an entry to the namespaces element in the web.config inside the Views folder:

/<project>/Views/Web.config

<system.web.webPages.razor>
	<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
	<pages pageBaseType="System.Web.Mvc.WebViewPage">
		<namespaces>
			<add namespace="System.Web.Mvc" />
			<add namespace="System.Web.Mvc.Ajax" />
			<add namespace="System.Web.Mvc.Html" />
			<add namespace="System.Web.Routing" />
			<add namespace="Company.Product.Site.Extensions"/>
		</namespaces>
	</pages>
</system.web.webPages.razor>

Can't login to MSSQL

Monday, 5 December 2011 14:38 by Chad

Issue

After just installing Microsoft SQL Server I could not login to it with either the local Administrator account or the sa account.

Solution

net stop MSSQLSERVER
start MSSQLSERVER /m
Open SQL Server Management Studio and login.
Use the Security tree to add or alter the appropriate users. Stop the single mode SQL process and start it back up again in normal mode.

Full-text Index is grayed out on a database in SQL Management Studio

Thursday, 1 December 2011 13:52 by Chad

EXEC sp_fulltext_database 'enable'