Skip to main content
GameDev.net gamedev.net
🔒 Locked

Texturecube .dds file

Started by ooooooooOoo Mar 30, 2009 at 7:19 PM 4 replies 2.9k views
Original Post
ooooooooOoo
ooooooooOoo
How do you create a texturecube .dds file for XNA? I've been attempting to use the Nvidia exporter for photoshop, but it crashes under both CS3 and CS4. There must be some other way of making them. I've killed off half the day searching without luck though.
MJP
MJP
You can use the DirectX Texture Tool that comes with the DX SDK to assemble a cubemap from 6 separate images. ATI's CubeMapGen can also do this, plus a whole of other stuff.
ooooooooOoo
ooooooooOoo
Quote:
Original post by MJP
You can use the DirectX Texture Tool that comes with the DX SDK to assemble a cubemap from 6 separate images. ATI's CubeMapGen can also do this, plus a whole of other stuff.


The SDK method sounds more straightforward than the Nvidia exporter. Thanks!
ooooooooOoo
ooooooooOoo
In the end I used the ATI app. It's really good, particularly compared to the Nvidia one.

Quick question so I don't have to start a new thread: I'm seeing some really odd stuff in my shaders relating to specular and fresnel. I have a hunch that I'm generating the eye position from the view matrix wrong. My first clue was when dot(Normal, Eye) changed depending on the angle of the model, rather than the camera. Pesky kids, I would have gotten away with it too, if it weren't for:

float3 Eye = mul(float3(0,0,-1), View);

I guess what I'm looking for is a float3 that would represent the orientation of the camera, discarding the position (I think). How SHOULD I be getting the camera position from the view?

Edit: scratch that, finally figured it out from some other shaders.

[Edited by - ooooooooOoo on March 31, 2009 8:36:45 AM]
MJP
MJP
I'll still answer for your benefit of for the benefit of anyone else in a similar problem...

The view matrix is actually the inverse of a transform representing the camera's position and orientation. So when you transform a vector it doesn't move the vector into world space, it moves it into view space.

To get camera position from the view matrix you can invert it (the transpose should be the inverse, since it should be orthogonal) and transform the vector <0, 0, 0>, or you can extract the X, Y, and Z coordinates from the ._41, ._42, and ._43 elements of the matrix.
ooooooooOoo
ooooooooOoo
It's pretty non-obvious which parts of the matrix need to be extracted, isn't it. That's where I got particularly stuck. Here's what I did in the end, all tidied up for copypasta:

struct VertexShaderOutput{    float4 Position : POSITION0;    float3 WorldView : TEXCOORD0;    float4 TransformedPosition : TEXCOORD1;};struct PixelShaderInput{    float4 Position : POSITION0;    float3 WorldView : TEXCOORD0;    float4 TransformedPosition : TEXCOORD1;};VertexShaderOutput VertexShader(VertexShaderInput In){    VertexShaderOutput Out;    Out.Position = mul(mul(mul(In.Position, World), View), Projection);    float3 PositionWorld = mul(In.Position, World).xyz;    Out.WorldView = ViewInverse[3].xyz - PositionWorld;    Out.TransformedPosition = Out.Position;    return Out;}float4 PixelShader(PixelShaderInput In) : COLOR0{	float3 Eye = In.WorldView;	float EyeDistance = length(Eye - In.TransformedPosition);	Eye = normalize(Eye);}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.