c++ - how to render sprites as true spheres? -
i'm trying render fluid simulator liquid effect,
here render result:
but want result
here geometry , pixel shader
[maxvertexcount(4)] void maings(point gsps_input ginput[1],inout trianglestream<gsps_output> tristream) { float size = 0.065; matrix mv = view; float3 right = normalize(float3(mv._11,mv._21,mv._31)); float3 = normalize(float3(mv._12,mv._22,mv._32)); // float3 poseye = mul( float4(ginput[0].pos.xyz, 1.0),world).xyz; // float halfwidth = size/length(poseye); float halfheight = size/length(poseye); // float4 v[4]; v[0] = float4(ginput[0].pos + halfwidth*right - halfheight*up, 1.0f); v[1] = float4(ginput[0].pos + halfwidth*right + halfheight*up, 1.0f); v[2] = float4(ginput[0].pos - halfwidth*right - halfheight*up, 1.0f); v[3] = float4(ginput[0].pos - halfwidth*right + halfheight*up, 1.0f); // // gsps_output output; [unroll] for(int i=0; i<4; ++i) { // output.pos = mul(v[i], view); output.posw = (output.pos.xyz); output.pos = mul(output.pos, projection); output.tex = gquadtexc[i]; tristream.append(output); } tristream.restartstrip(); } //pixel shader float4 ps(gsps_output input) : sv_target { float3 n; n.xy = input.tex*float2(2.0f,-2.0f) + float2(-1.0f,1.0f); float mag = dot(n.xy, n.xy); if (mag > 1.0) { discard; } n.z = sqrt(1.0f-mag); n = n * 0.5 + 0.5; float4 pixelpos = float4(input.posw + n*(1/32), 1.0); float4 clipspacepos = mul(pixelpos, projection); float depthval = (clipspacepos.z / clipspacepos.w);
i found here this, it's not explanation link
Comments
Post a Comment