Jmac Posted June 1, 2017 Share Posted June 1, 2017 I'm moving vertices in a very simple shader but for some reason the normals dont move with the vertices and I'm left with an odd effect. Any ideas what is causing this?Vertex Shader #include "shaders/common/torque.hlsl" struct Appdata { float3 position : POSITION; float tangentW : TEXCOORD3; float3 normal : NORMAL; float3 T : TANGENT; float2 texCoord : TEXCOORD0; }; struct Conn { float4 hpos : SV_Position; float2 texCoord : TEXCOORD0; }; Conn main( Appdata In, uniform float4x4 modelview : register(C0) ) { Conn Out; In.position.z += 20; Out.hpos = mul(modelview, float4(In.position, 1.0)); Out.texCoord = In.texCoord; return Out; } Pixel Shader #include "shaders/common/torque.hlsl" struct Conn { float4 hpos : SV_Position; float2 texCoord : TEXCOORD0; }; struct Fragout { float4 col : SV_Target0; }; Fragout main(Conn IN) { Fragout OUT; OUT.col = (255,255,255,1); return OUT; } What it looks like in game Quote Link to comment Share on other sites More sharing options...
Timmy Posted June 2, 2017 Share Posted June 2, 2017 I am not 100% sure i am understanding the question, normals are a direction vector and don't have a position. In your shader you are not even using the normals so kinda hard to gather exactly what it is you are trying to do. Going to need more info. Quote Link to comment Share on other sites More sharing options...
Jmac Posted June 2, 2017 Author Share Posted June 2, 2017 I'm trying to move the mesh vertices from the vertex shader in the z axis, I want to try to do the vertex translation on the gpu because of the amount I will need to move in a frame. The white color appears in the proper position but its somewhat transparent and there is that tan plane that appears at the original location that I'm assuming is another set of vertices with the normals for the object where. I don't exactly know why there are two planes or what they are to be honest.For instance when I put in object between the white and tan I can see it when I shouldn't but when it's under the tan portion I can't see it so im assuming the tan plane has some lighting attributes. Also when I view the white from an angle that the tan is not below it, it doesn't appear.post imagesI haven't been able to find much info on torques rendering system so if anyone could point me in the right direction it would be appreciated. Quote Link to comment Share on other sites More sharing options...
Timmy Posted June 2, 2017 Share Posted June 2, 2017 Unfortunately what you are seeing is a short coming of the t3d custom material system. In short what you want to do with the vertices can't be done how it works now. What happens is the object is rendered twice, once through the deferred bin (using a shadergen shader you can't change) and than it renders it again after the deferred pass using your custom material, this is why you see the object twice because you are obviously changing the vertex position only in that second pass.Just a couple of small things in ya pixel shader OUT.col = (255,255,255,1); should read OUT.col = float4(1.0,1.0,1.0,1.0); ya firstly need the type(float4) and the shaders use a float range for the color, although 255 is a perfectly valid number with HDR i'm guessing you really meant 255 as in 0-255 unsigned byte range so the value should be 1.0Hopefully that clears it up for you. Quote Link to comment Share on other sites More sharing options...
JeffR Posted June 2, 2017 Share Posted June 2, 2017 Hm, I'll take an eyeball on how the current water stuff does it, because being able to permute the vert positions is definitely something that should be possible in a custom mat. So if it's choking that hard, it needs a-looking. Quote Link to comment Share on other sites More sharing options...
Jmac Posted June 2, 2017 Author Share Posted June 2, 2017 Thanks Timmy that helped alot. I figured it had something to do with it being rendered twice but didnt exactly know how it worked. Quote Link to comment Share on other sites More sharing options...
Jmac Posted June 6, 2017 Author Share Posted June 6, 2017 Can anyone point me to where the deferred bin creates the shader for the first pass? Quote Link to comment Share on other sites More sharing options...
Azaezel Posted June 6, 2017 Share Posted June 6, 2017 https://github.com/GarageGames/Torque3D/blob/4b5fbc20cf3ce0c996de0376c5c043f95ec09e86/Engine/source/renderInstance/renderDeferredMgr.cpp#L598for shader featureshttps://github.com/GarageGames/Torque3D/blob/4b5fbc20cf3ce0c996de0376c5c043f95ec09e86/Engine/source/renderInstance/renderDeferredMgr.cpp#L647 for example.https://github.com/GarageGames/Torque3D/search?utf8=%E2%9C%93&q=MFT_DeferredSpecVars&type= for hookshttps://github.com/GarageGames/Torque3D/search?utf8=%E2%9C%93&q=DeferredSpecVarsHLSL&type= for proceedurally inserted code definitionshttps://github.com/GarageGames/Torque3D/blob/67aa2e0f4dfc92dd669d8c06531b4293325cfc1d/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp#L161 for target I/Ohttps://github.com/GarageGames/Torque3D/blob/4b5fbc20cf3ce0c996de0376c5c043f95ec09e86/Engine/source/renderInstance/renderDeferredMgr.cpp#L165-L188 for render target bindings Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.