Skip to main content
gamedev.net
🔒 Locked

Vertex Shaders

Started by fleejay 1 reply 1k views
Original Post
fleejay
fleejay
Hi, I''m looking to write a (direct3d) vertex shader that transforms texture coordinates in a similar way to the D3DTSS_TEXCOORDINDEX renderstate mode D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR Basically I have an object to world matrix and I want to generate the environment mapping texture coords myself. This is not the same as spherical mapping. Does anyone have any ideas? Many Thanks Fleejay.
---Fleejay
S1CA
S1CA
Check out the DirectX 8.1 SDK, in particular the NEW spherical envmap sample which is implemented using a vertex shader.

PART of that shader calculates _exactly_ the same values as D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR does.

In short:

1. transform the vertex position and normal into camera space. Remember that if you have any non uniform scaling that the normal will need to be transformed by the transposed inverse of the matrix.

2. The reflected view vector is:
r = 2 (n.v) n - v
where:
n = the vertex normal
v = the view vector

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
fleejay
fleejay
Thankyou!
---Fleejay

Topic Locked

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

Sign in to reply to this topic.