Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualgreenzone

Posted 19 June 2012 - 09:13 PM

now from what i understand of vertex shaders the main runs for every vertex. I am just not understanding what is happening here for some reason its like a snake i cant see that is sitting on my face. could some one explain what is happening here just a little bit perhaps?
[source lang="cpp"]cbuffer c_buffer{ float4x4 World; float4x4 WorldViewProj; float4x4 FinalTransforms[32];}struct VS_OUT{ float4 position : SV_POSITION;};VS_OUT VShader(float4 position : POSITION, float4 weights : BLENDWEIGHT, int4 boneIndices : BLENDINDICES){ VS_OUT output; float4 p = float4(0.0f, 0.0f, 0.0f, 1.0f); float lastWeight = 0.0f; int n = 3; for(int i = n; i > 0; i--) { lastWeight += weights[i]; p += weights[i] * mul(FinalTransforms[boneIndices[i]], position); } lastWeight = 1.0f - lastWeight; p += lastWeight * mul(FinalTransforms[boneIndices[0]], position); p.w = 1.0f; output.position = mul(WorldViewProj, p); return output;}[/source]


I should also add that i am using opengl and am used to using GLSL when it comes to shader so i am also a little puzzled by the way your reading in uniform variables. I assume that this "float4 position : POSITION, float4 weights : BLENDWEIGHT, int4 boneIndices : BLENDINDICES" is HLSL's way of reading in those variables?

#1greenzone

Posted 19 June 2012 - 09:07 PM

now from what i understand of vertex shaders the main runs for every vertex. I am just not understanding what is happening here for some reason its like a snake i cant see that is sitting on my face. could some one explain what is happening here just a little bit perhaps?
[source lang="cpp"]cbuffer c_buffer{         float4x4 World;         float4x4 WorldViewProj;         float4x4 FinalTransforms[32];}struct VS_OUT{         float4 position : SV_POSITION;};VS_OUT VShader(float4 position : POSITION, float4 weights : BLENDWEIGHT, int4 boneIndices : BLENDINDICES){         VS_OUT output;         float4 p = float4(0.0f, 0.0f, 0.0f, 1.0f);         float lastWeight = 0.0f;         int n = 3;         for(int i = n; i > 0; i--)         {                        lastWeight += weights[i];                        p += weights[i] * mul(FinalTransforms[boneIndices[i]], position);         }         lastWeight = 1.0f - lastWeight;         p += lastWeight * mul(FinalTransforms[boneIndices[0]], position);         p.w = 1.0f;         output.position = mul(WorldViewProj, p);         return output;}[/source]

PARTNERS