Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hydra previewsuface display issue with displacement map #922

Closed
dongyifan opened this issue Jul 31, 2019 · 6 comments
Closed

Hydra previewsuface display issue with displacement map #922

dongyifan opened this issue Jul 31, 2019 · 6 comments

Comments

@dongyifan
Copy link

dongyifan commented Jul 31, 2019

I have a terrain build by maya, it looks like this

IMG_3647

The mesh is a simple plane, then use displacement map to get this result.

I try to get same result in Hydra with USD preview surface, but the result look like this

IMG_3648

This is my USD file code (The mesh is a simple plane, so I remove mesh vertex and uv data since it is very noise):

#usda 1.0

def Mesh "pPlaneShape1"
{
    uniform bool doubleSided = 1
    float3[] extent = [(-0.5, -1.110223e-16, -0.5), (0.5, 1.110223e-16, 0.5)]
    int[] faceVertexCounts = []
    int[] faceVertexIndices = []
    point3f[] points = []
    float2[] primvars:st = [](
        interpolation = "vertex"
    )
    int[] primvars:st:indices = []
    float3 xformOp:scale = (24, 24, 24)
    uniform token[] xformOpOrder = ["xformOp:scale"]
    rel material:binding = </initialShadingGroup>
}

def Material "initialShadingGroup"
{
    token inputs:frame:stPrimvarName = "st"
    token outputs:surface.connect = </lambert1.outputs:surface>
    token outputs:displacement.connect = </lambert1.outputs:displacement>
}

def Shader "lambert1"
{
    uniform token info:id = "UsdPreviewSurface"
    color3f inputs:diffuseColor.connect = </diffuseTexture.outputs:rgb>
    float inputs:displacement.connect = </displacementTexture.outputs:r>
    token outputs:surface
    token outputs:displacement
}

def Shader "stReader"
{
    uniform token info:id = "UsdPrimvarReader_float2"
    token inputs:varname.connect = </initialShadingGroup.inputs:frame:stPrimvarName>
    float2 outputs:result
}

def Shader "diffuseTexture"
{
    uniform token info:id = "UsdUVTexture"
    asset inputs:file = @./textures/diffuse.jpg@
    float2 inputs:st.connect = </stReader.outputs:result>
    float3 outputs:rgb
    float outputs:r
}

def Shader "displacementTexture"
{
    uniform token info:id = "UsdUVTexture"
    asset inputs:file = @./textures/displacement.png@
    float2 inputs:st.connect = </stReader.outputs:result>
    float outputs:r
}

Does hydra preview surface support displacement map, or is there something wrong in my USD file?

This is the USD file

plane_displacement.usda.txt

Diffuse map and displacement map

diffuse

displacement

@spiffmon
Copy link
Member

spiffmon commented Jul 31, 2019 via email

@dongyifan
Copy link
Author

Hi there! Apologies, most of us are at siggraph this week so responses may be a bit delayed. It would be helpful if you could actually attach the relevant portions of the usda file? Thanks! —spiff
On Tue, Jul 30, 2019 at 7:30 PM yifan @.***> wrote: I have a terrain build by maya, it looks like this [image: IMG_3647] https://user-images.githubusercontent.com/445204/62178878-22583200-b37d-11e9-89a0-e5de6085a919.jpg The mesh is a simple plane, then use displacement map to get this result. I try to get same result in Hydra with USD preview surface, but the result look like this [image: IMG_3648] https://user-images.githubusercontent.com/445204/62179013-8ed33100-b37d-11e9-9211-08d43c21e919.jpg This is my USD file [image: IMG_3660] https://user-images.githubusercontent.com/445204/62179062-c04bfc80-b37d-11e9-9ca8-e48eb729bee8.jpg Does hydra preview surface support displacement map, or is there something wrong in my USD file. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#922?email_source=notifications&email_token=ABPOU2CPLNEWLNE6NZZB3TTQCD2K7A5CNFSM4IIB36Z2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HCOO6RQ>, or mute the thread https://github.com/notifications/unsubscribe-auth/ABPOU2B4IBLZAEA7BDOS2LDQCD2K7ANCNFSM4IIB36ZQ .
-- --spiffiPhone

Thanks for your reply, I have already update the comment, please take a look.

I put USD code into it and attache USD file with textures. if you want to reproduce, just create a folder named textures and put diffuse and displacement map into it.

@jilliene
Copy link

jilliene commented Aug 2, 2019

Filed as internal issue #USD-5474

@poljere
Copy link
Contributor

poljere commented Aug 6, 2019

Looks like you have hit an issue in our current implementation of previewSurface.glslfx. While we are fixing it internally, you can work around it by changing /pxr/usdImaging/lib/usdShaders/shaders/previewSurface.glslfx line 51 to :

float texDisplacement = HdGet_displacement(HdGet_st(index).xy).x;

Thanks!

@dongyifan
Copy link
Author

Looks like you have hit an issue in our current implementation of previewSurface.glslfx. While we are fixing it internally, you can work around it by changing /pxr/usdImaging/lib/usdShaders/shaders/previewSurface.glslfx line 51 to :

float texDisplacement = HdGet_displacement(HdGet_st(index).xy).x;

Thanks!

Thanks for your support, This fix my problem.

@poljere
Copy link
Contributor

poljere commented Aug 6, 2019

Let's keep this open until we have a real fix for this issue, please remember that the workaround above will only work for texture coordinates coming from a primvar named "st".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants